How to set a timer to start 20 seconds after the player spawns? - 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: How to set a timer to start 20 seconds after the player spawns? (
/showthread.php?tid=112930)
How to set a timer to start 20 seconds after the player spawns? -
Nakash - 11.12.2009
I am having a problem with a weapon saver,the system saves the weapons and puts them into the players .ini,then when i relog it spawns them back,the problem is when i set a timer (I want to set a timer that will save the weapon's ammo and the guns on you.) sometimes when i log it removes the weapons,i guess it is because the timer starts before the player gets the weapons,then i want the timer to have a little delay.
OnPlayerSpawn()
SetTimer("saveweapon",1000,1);
I don't want to change the SetTimer time,i just want it to have a delay before the player gets the weapons.
Re: How to set a timer to start 20 seconds after the player spawns? -
Abernethy - 11.12.2009
Create another
function that sets the that timer (saveweapon). Then OnPlayerSpawn set a timer (new one) for 20 seconds that calls the
function (the one you created).
Untested
pawn Код:
// Top of script
forward DelayTimer(/*playerid*/);
public DelayTimer(/*playerid*/)
{
/*new
name[20];
GetPlayerName(playerid, name, 20);
printf("[Update] Player %s has spawned, and retreived their weapons!", Name);*/
SetTimer("saveweapon", 1000, true);
return true;
}
public OnPlayerSpawn(playerid)
{
SetTimer("DelayTimer(/*playerid*/)", 20000, false); // My bad =P
return true;
}
Re: How to set a timer to start 20 seconds after the player spawns? -
Nakash - 11.12.2009
Quote:
Originally Posted by Aber▲
Create another function that sets the that timer (saveweapon). Then OnPlayerSpawn set a timer (new one) for 20 seconds that calls the function (the one you created).
|
Thanks
I thought about that!
Re: How to set a timer to start 20 seconds after the player spawns? -
Abernethy - 11.12.2009
Quote:
Originally Posted by Uniqueee
Quote:
Originally Posted by Aber▲
Create another function that sets the that timer (saveweapon). Then OnPlayerSpawn set a timer (new one) for 20 seconds that calls the function (the one you created).
|
Thanks
I thought about that!
|
Glad you got it, even I got confused in that post.
Re: How to set a timer to start 20 seconds after the player spawns? -
Nakash - 11.12.2009
Quote:
Originally Posted by Aber▲
Quote:
Originally Posted by Uniqueee
Quote:
Originally Posted by Aber▲
Create another function that sets the that timer (saveweapon). Then OnPlayerSpawn set a timer (new one) for 20 seconds that calls the function (the one you created).
|
Thanks
I thought about that!
|
Glad you got it, even I got confused in that post.
|
Thanks again but it didn't work..the timer starts again when OnPlayerSpawn callback runs.
I did SetClientMessage too and it printed the message,i have added a command /wep and
it shows the new weapons that the player gets when the timer is ON,and
i gave myself a weapon and checked it after 2 secs and it saved it.
I tried your code too,but still the same problem :[
EDIT:
ah lol,you put the DelayTimer in OnPlayerSpawn without any timer ;p
lemme check if your code works now.
EDIT2:
It worked,thanks!