(HELP) comande with timer - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: (HELP) comande with timer (
/showthread.php?tid=219839)
(HELP) comande with timer -
Amine_Mejrhirrou - 02.02.2011
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
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 ?
Re: (HELP) comande with timer -
Steven Paul - 02.02.2011
what the hell? I don't understand what are you trying to tell? There is also a NON-ENGLISH section
AW: (HELP) comande with timer -
!Phoenix! - 02.02.2011
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.
Re : (HELP) comande with timer -
Amine_Mejrhirrou - 02.02.2011
thanks !Phoenix!
Re: (HELP) comande with timer -
alpha500delta - 02.02.2011
Anyone noticed you both forgot
AW: (HELP) comande with timer -
!Phoenix! - 02.02.2011
Oh yeah I didn't noticed