SA-MP Forums Archive
playerid in 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: playerid in timer (/showthread.php?tid=417099)



playerid in timer - Yako - 19.02.2013

Hello I have script like this:

Код:
forward Something()
public Something()
{
new name[25];
new string[128];
switch(random(5))
{
case 0: name = "xxx";
case 1: name = "xxx";
case 2: name = "xxx";
case 3: name = "xxx";
case 4: name = "xxx";
}
format(string,sizeof(string),"* %s just did %s",GetPlayerNameEx(playerid),name);
ProxDetector(10.0, playerid, string, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN, COLOR_GREEN);
return 1;
}
I want to know how to get playername by id because now it says that undefined symbol playerid. When I do it with this:
Код:
for(new i;MAX_PLAYERS>i;i++)
{
Then it shows the string that many times as players in server. I need only to show only one player action


Re: playerid in timer - MP2 - 19.02.2013

Use SetTimerEx to pass arguments to a timer. See the wiki.


Re: playerid in timer - DaRk_RaiN - 19.02.2013

pawn Код:
SetTimerEx("MyTimer",50000,0,"i",playerid);
forward MyTimer(playerid);
public MyTimer(playerid)
{
//bla bla
}



Re: playerid in timer - Yako - 20.02.2013

Thank you it works, I have added +rep both of you