SA-MP Forums Archive
Timers - 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: Timers (/showthread.php?tid=446058)



Timers - Mr.Valdez - 24.06.2013

I completely have no clue how SetTimer works and i can't wrap my head around how the samp wiki explains it, i dont understand how to put it into a command etc. could anyone explain it with examples please? it will be much appreciated.


Re: Timers - dEcooR - 24.06.2013

SetTimer("message", 1000, false);

message - your name of your function ( need a public + forward )

1000 - the timer of 1000 miliseconds ( 1 second )

false -its repeating,if the timer should repeatedly or only once

SetTimerEx - Is setting the timer with more parameters,example for one player

i really dont know how to explain this in other version .. i think wiki it says good xd


Re: Timers - introzen - 24.06.2013

I'll try to explain from what I believe you ask for.

pawn Code:
new timer = SetTimerEx("KickInactivePlayers",1000*60*10,true,playerid);

forward KickInactivePlayers(playerid);
public KickInactivePlayers(playerid)
{
     if(!IsPlayerActive(playerid)) Kick(playerid);
     return 1;
}
Where "1000*60*10" is actually:
Code:
1000 milliseconds * 60 (= 1 minute) * 10 (= 10 minutes)
Anytime you need to cancel this timer, just use:

pawn Code:
KillTimer(timer);
And ofcourse you'd have to state a function for:
pawn Code:
IsPlayerActive(playerid)
Hope it helps!


Re: Timers - Mr.Valdez - 24.06.2013

thanks <3


Re: Timers - introzen - 24.06.2013

Quote:
Originally Posted by Mr.Valdez
View Post
thanks <3
No problem