(HELP) comande with timer
#3

pawn Код:
if(strcmp(cmd, "/searchgun", true) == 0)
{
    SetTimer("searchgun", 300000,false); //searchgun will be called in 5 minutes! (Player gets the weapon in 5 min)
}
//-------------------------------------
public searchgun()
{  
    SendClientMessage(playerid,YELLOW,"you have found a gun / ammo");
    GivePlayerWeapon(playerid,22,100);
}
} //Only one bracked is open!
If you want to allow the command only every 5 minutes you can set a variable for the player that he used this command:

pawn Код:
if(strcmp(cmd, "/searchgun", true) == 0)
{
    if(PlayerVar[playerid][searchedgun] == 0) //Check if he used the command less than 5 minutes ago
    {
        SendClientMessage(playerid,YELLOW,"you have found a gun / ammo");
        GivePlayerWeapon(playerid,22,100);
        SetTimerEx("searchgun", 300000, false, "i", playerid); //Use SetTimerEx to pass the playerid
        PlayerVar[playerid][searchedgun] = 1; //Set that he used the command
    }
    else SendClientMessage(playerid,YELLOW,"you have to wait 5 minutes until you can use this command again");
}
//-------------------------------------
public searchgun(playerid)
{  
    PlayerVar[playerid][searchedgun] = 0; //Reset the variable after 5 minutes
}
Should work like this, haven't tried it.
Reply


Messages In This Thread
(HELP) comande with timer - by Amine_Mejrhirrou - 02.02.2011, 12:05
Re: (HELP) comande with timer - by Steven Paul - 02.02.2011, 12:12
AW: (HELP) comande with timer - by !Phoenix! - 02.02.2011, 12:32
Re : (HELP) comande with timer - by Amine_Mejrhirrou - 02.02.2011, 12:58
Re: (HELP) comande with timer - by alpha500delta - 02.02.2011, 13:18
AW: (HELP) comande with timer - by !Phoenix! - 02.02.2011, 13:28

Forum Jump:


Users browsing this thread: 2 Guest(s)