Timer before spawn - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer before spawn (
/showthread.php?tid=268551)
Timer before spawn -
cloudysky - 12.07.2011
I've been having this bug when spawning and figured out that if I just let the map load before clicking spawn it fixes the problem. I want to add a timer for about 6 seconds when the player is on, OnPlayerRequestClass, which will not let them spawn until the six seconds have passed. Can anyone help me?
Re: Timer before spawn -
Calgon - 13.07.2011
You can return 0 in your OnPlayerRequestClass callback and initiate a timer to call SpawnPlayer() in '6 seconds'. An example of how to do this would be (as a snippet in your OnPlayerRequestClass callback):
pawn Код:
SetTimerEx("_timer_SpawnPlayer", 6000, false, "dd", playerid, classid);
return 0;
And as an external function (for the timer):
pawn Код:
forward _timer_SpawnPlayer(playerid, classid);
public _timer_SpawnPlayer(playerid, classid) {
SetSpawnInfo() // You'll have to update this code yourself, to reflect the classes you've scripted. You can use the classid variable as a reference to which class the player chose
return SpawnPlayer(playerid);
}