Blockland Forums > Modification Help
Playertype Recalling
(1/1)
Mr.Noßody:
I need help with a very specific strand of code. I'm looking for a code for a one use item that changes your player-type, but can then change your player-type back to the last one you had after a set amount of time. Ive been trying a bunch of stuff to no avail so I'm turning here for help.

Basically, I'm looking for a code that can recall the player-type you had before, after the item changes it. I'm not even sure if this is even possible.

Need some help here.
Munkey:

--- Code: ---function player::recallPlayerType(%this, %playerType, %stage)
{
if(isObject(%this) && %stage == 1)
{
%minutes = 5;
%this.oldDatablock = %this.getDatablock().getName();
%this.changeDataBlock("playertypename");
schedule(%minutes * 60000, 0, recallPlayerType, %this, %playerType, 2);
}
else if(isObject(%this) && %stage == 2)
{
%this.changeDatablock(%this.oldDatablock);
}
}
--- End code ---

Wrote that in like 30 seconds, not tested, but that's how you would do it.

Also look at the mushroom:
http://forum.returntoblockland.com/dlm/viewFile.php?id=923
Mr.Noßody:
Yes yes, the mushroom. I already have a working resizing item, its the swapping of player-types that confuses me.

Ill test the code sometime tomorrow.
Thank you.

Edit: Wait, is that time interval in minuets?
Orthone:

--- Quote from: Munkey on November 06, 2011, 11:21:25 PM ---      schedule(%minutes * 60000, 0, recallPlayerType, %this, %playerType, 2);

--- End quote ---
60000 is a minute, therefore the %minutes would be a minute per 1. Removing the * 60000 would put it in milliseconds.
Mr.Noßody:
Right right, I'm stupid. Sorry..
Navigation
Message Index

Go to full version