settimer in a callback that uses player definition.
#1

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

nothing will happen.
Reply
#3

It do not works, because there is a parameter missing.
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)