settimer in a callback that uses player definition. - 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: settimer in a callback that uses player definition. (
/showthread.php?tid=658703)
settimer in a callback that uses player definition. -
SapMan - 10.09.2018
If I use this, the function may not work or generate a bug? I already compile and it did not give me errors, I just want to know if it would give me some bug, or it will not be the right thing, or it is not a recommended way.
I have something like that:
PHP код:
TimerTest[MAX_PLAYERS];
public Test_One()
{
TimerTest[playerid] = SetTimer("Test_Two", 5000, false); //here I do not define the definition of the player
return 1;
}
public Test_Two(playerid) //definition of the player
{
//code
//Example: Player[playerid][Variable] = 1;
return 1;
}
Re: settimer in a callback that uses player definition. -
Alteh - 10.09.2018
nothing will happen.
Re: settimer in a callback that uses player definition. -
iHollyZinhO - 10.09.2018
It do not works, because there is a parameter missing.
Re: settimer in a callback that uses player definition. -
Shinja - 10.09.2018
You need to forward the functions
You will get error undefined symbol (playerid) in Test_One
So you'd better use SetTimerEx
PHP код:
new TimerTest[MAX_PLAYERS];
forward Test_One(playerid);
public Test_One(playerid)
{
TimerTest[playerid] = SetTimerEx("Test_Two", 5000, false, "i", playerid);
return 1;
}
forward Test_Two(playerid);
public Test_Two(playerid)
{
//code
//Example: Player[playerid][Variable] = 1;
return 1;
}