Timer!!
#1

Hello!
Can anyone help me with a tutorial on how to make timers!
Thanks!
Ironmen!
Reply
#2

I hope this helps!
Reply
#3

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;
}
Reply
#4

Thanks but didn't understand!!
Please help!
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)