(HELP) comande with timer
#1

hi all . i would like to know how can i make a /comand that we wan us every (5min) for example
is that posible to make somethink like that
Quote:

forward searchgun();

public OnPlayerCommandText(playerid, cmdtext[])
Quote:

if(strcmp(cmd, "/searchgun", true) == 0)
{
SetTimer("searchgun", 300000,false);
}

public searchgun()
Quote:

public searchgun()
{
SendClientMessage(playerid,YELLOW,"you have found a gun / ammo");
GivePlayerWeapon(playerid,22,100);
}
}

so can some one help me to corect that if ther is any error pls ?
Reply
#2

what the hell? I don't understand what are you trying to tell? There is also a NON-ENGLISH section
Reply
#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
#4

thanks !Phoenix!
Reply
#5

Anyone noticed you both forgot
pawn Код:
return 1;
Reply
#6

Oh yeah I didn't noticed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)