Timer!! - 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)
+--- Thread: Timer!! (
/showthread.php?tid=580952)
Timer!! -
ironmen - 09.07.2015
Hello!
Can anyone help me with a tutorial on how to make timers!
Thanks!
Ironmen!
Re: Timer!! -
iTakelot - 09.07.2015
I hope this helps!
Re: Timer!! -
JaydenJason - 09.07.2015
SetTimerEx;
Quote:
Sets a timer to call a function after the specified interval. This variant ('Ex') can pass parameters (such as a player ID) to the function.
|
Lets say you have this somewhere in your script;
Код:
forward SaveUser(playerid); public SaveUser(playerid)
{
//code blabla
}
And you want to use that in a timer, you can use SetTimerEx because "This variant ('Ex') can pass parameters (such as a player ID) to the function."
Код:
SetTimerEx("SaveUser", 10000, false, "i", playerid);
would call SaveUser on "playerid" (SaveUser(playerid)), but "SetTimer" can't pass parameters (" "i", playerid "), it's usually used as a global timer (I use it as a "OnVehicleUpdate", similar to OnPlayerUpdate) and can't be something for one player only. (it can but it;s not smart)
If you want to make a timer for that "SaveUser" you could simply do the following;
Код:
CMD:saveuser(playerid, params[])
{
SetTimerEx("SaveUser", 30000, false, "i", playerid); (sets timer to call "SaveUser" after 30000 ms(30 seconds), doesn't repeat, sets the parameter as an "i"nteger and the integer would be "playerid)
SendClientMessage(playerid, -1, "Your account will save in 30 seconds.");
return 1;
}
But if you made a timer you need a function for the timer somewhere (first parameter in SetTimerEx),
like;
Код:
forward SaveUser(playerid); public SaveUser(playerid)
{
INI_ParseFile(blabla... //code
return 1;
}
Re: Timer!! -
ironmen - 09.07.2015
Thanks but didn't understand!!
Please help!
Re: Timer!! -
liquor - 09.07.2015
Well, if you didn't understand you could look for an english language course close to you. I know it seems rude but there aren't many ways to put this other than
https://sampwiki.blast.hk/wiki/SetTimer