Author Topic: Playertype Recalling  (Read 466 times)

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.

Code: [Select]
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);
}
}

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

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?

      schedule(%minutes * 60000, 0, recallPlayerType, %this, %playerType, 2);
60000 is a minute, therefore the %minutes would be a minute per 1. Removing the * 60000 would put it in milliseconds.

Right right, I'm stupid. Sorry..