[Help]How to use SetTimerEx - 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: [Help]How to use SetTimerEx (
/showthread.php?tid=107390)
[Help]How to use SetTimerEx -
Tigerbeast11 - 09.11.2009
Hi guys!
I just worked out to pass the "playerid" param, i need to use SetTimerEx... I read this wiki, but Im a beginner so I didnt understand most of it :S
If someone could explain it better for me plz?
https://sampwiki.blast.hk/wiki/SetTimerEx
Re: [Help]How to use SetTimerEx -
Tigerbeast11 - 09.11.2009
Anyone?
Re: [Help]How to use SetTimerEx -
dice7 - 09.11.2009
The whole point of SetTimerEx is for passing values from one function to another
https://sampwiki.blast.hk/wiki/SetTimerEx
SetTimerEx("message", 1000, false, "d", 1);
"message" is the string name of the function you will call
1000 is how much time it needs to pass for the function to be called (in miliseconds)
False (or true) is the type of timer. Being false it will only call "message" once, being true it will call it every interval
"d" is the type of variable to pass. In this case an integer. Check the wiki page for other types to send
The number 1 is what it will be passed. Because I used "d" or "%d" for the format to pass it will pass it as an integer
Example
pawn Код:
//somewhere in the script
SetTimerEx("message", 1000, false, "d", 1);
//on the bottom of the script
forward message(number);
public message(number)
{
printf("The symbol 'number' is %d", number);
//This will display "The symbol 'number' is 1"
//That is because SetTimerEx passed the number 1 to the function
//If it would be SetTimerEx("message", 1000, false, "d", 167); then the output would be
//This will display "The symbol 'number' is 1"
}
Ingame example
pawn Код:
//under OnPlayerDeath(playerid, killerid, reason)
SetTimerEx("KillMessage", 1000, false, "dds", playerid, killerid, reason); //there are 2 'd' because I'm passing two integers. The 's' means string
//on the bottom of the script
forward KillMessage(playerid, killerid, string);
public KillMessage(playerid, killerid, string)
{
printf("Playerid %d was killed by playerid %d. Reason: %s", playerid, killerid, string);
//This will display "Playerid 0 was killed by playerid 1. Reason: blahblah" if playerid is really 0 and killerid 1
}
Re: [Help]How to use SetTimerEx -
Tigerbeast11 - 10.11.2009
Cheers! This really helped!