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



Timer issues - SalmaN97 - 12.11.2015

i did this code it should send a warning message every 10 seconds and save player position and after 20 seconds there should be an explosion in the save x y z position of player

but i am not gettibg warning message and the explosion happen on my player even if i leave the old position where i get a warning.

this is my code

PHP Code:
// at the to
new Float:Pos[3][MAX_PLAYERS];
// gamemodeint
    
SetTimer("Airstrikemsg"100001); 
PHP Code:
public Airstrikemsg()
{
    
SendClientMessageToAll(-1"clear your position airstike coming!");
    for(new 
i=0;i<MAX_PLAYERS;i++)
    if(
IsPlayerConnected(i))
    {
        
GetPlayerPos(i,Pos[0][i],Pos[1][i],Pos[2][i]);
    }
    
SetTimer("Airstrikestart"200001);
    return 
1;
}
public 
Airstrikestart(playerid)
{
    
CreateExplosion(Pos[0][playerid], Pos[1][playerid], Pos[2][playerid], 71000.0);
    return 
1;




Re: Timer issues - PrO.GameR - 12.11.2015

Airstrikestart has a playerid argument, therefore it should be called with SetTimerEx("Airstrikestart", 20000, 1,"i",playerid);
Oh and well you don't have any playerid in Airstrikemsg, so if you want to airstrike a specific player, you should do it with i, or remove the playerid argument from airstrikestart and loop thru all players and blow them up.


Re: Timer issues - SalmaN97 - 12.11.2015

Quote:
Originally Posted by PrO.GameR
View Post
Airstrikestart has a playerid argument, therefore it should be called with SetTimerEx("Airstrikestart", 20000, 1,"i",playerid);
Oh and well you don't have any playerid in Airstrikemsg, so if you want to airstrike a specific player, you should do it with i, or remove the playerid argument from airstrikestart and loop thru all players and blow them up.
my problem is that i am not getting the warning mission warning mission is at airstrikemsg


Re: Timer issues - RyanMaster - 19.11.2015

Try this.
PHP Code:
forward Airstrikemsg();
public 
Airstrikemsg() 

    
SendClientMessageToAll(-1"clear your position airstike coming!"); 
    
SetTimer("Airstrikestart"20000false); 
    return 
1

forward Airstrikestart();
public 
Airstrikestart() 

    for(new 
i=0;i<MAX_PLAYERS;i++) 
    {
        if(
IsPlayerConnected(i)) 
        {
            
GetPlayerPos(i,Pos[0][i],Pos[1][i],Pos[2][i]); 
            
CreateExplosion(Pos[0][i], Pos[1][i], Pos[2][i], 71000.0);
        } 
    }
    return 
1