Blockland Forums > Modification Help
Is there some way to make a delay?
Jetpuff:
function b(){for(%b=0; %b<10000; %b++)findclientbyname(jet).player.instantRespawn();}
I dont like spawning 10000 times in one second, it needs to be spread out. I just can't enjoy spawning alot if it is just in one second. :(
Truce:
.schedule(%a,%b,[%c,...]) is a method that can be called on objects to delay %b method with %c parameters for %a milliseconds. For example, if I wanted to delay kicking a client with the reason "Bye" by 3 seconds, I would use %client.schedule(3000,delete,"Bye");. For non-objects, you use schedule(3000,0,echo,"Bye");. There is an extra argument between the delay and the function (just put 0).
In your case, you would do something like this:
(%b = 0, delay = 0; %b = 1, delay = 1000; etc)
--- Code: ---function b()
{
echo("Code starting...");
for(%b = 0; %b < 60; %b++)
{
findClientByName("Jet").player.schedule(%b * 1000,instantRespawn);
schedule(%b * 1000,0,echo,"Respawning!");
}
echo("Code stopped.");
}
--- End code ---
Echos provided so you see how the delay works - it doesn't pause execution, only delays calls.
Jetpuff:
I only spawned once on your code, am I supposed to figure out how to use schedule(); and that was just an example?
Chrono:
Shouldn't you be using
findClientByName("Jet").schedule(%b * 1000, spawnPlayer):
?
Because that's going to call instantrespawn on the player once, then the player is gone so the rest of the schedules die.
Jetpuff:
That did nothing :(
Also I would have to be dead.