Timer for command??? - 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: Timer for command??? (
/showthread.php?tid=185625)
Timer for command??? -
<Weponz> - 25.10.2010
How to set a timer for a command so you can only do it once every 2 mins?
Re: Timer for command??? -
BMUK - 25.10.2010
Top
pawn Code:
new usedcommand[MAX_PLAYERS];
OnConnect..
pawn Code:
usedcommand[playerid] =0;
OnDisConnect..
pawn Code:
usedcommand[playerid] =0;
InYourCommand..
pawn Code:
usedcommand[playerid] =10; // 10 seconds?
InYourCommand..
pawn Code:
if(usedcommand[playerid]) return SendClientMessage(playerid,COLOR,"Plz Wait");
GameModeInit..
pawn Code:
SetTimer("loltimer",1000,1);
EndOfScript..
pawn Code:
public loltimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(usedcommand[i] > 0)
{
usedcommand[i] --;
}
}
}
Re: Timer for command??? -
<Weponz> - 25.10.2010
Thanks,Works Perfectly!
Re: Timer for command??? -
SampStunta - 25.10.2010
2 Topics meaning 1 things...
[/sigh]
Re: Timer for command??? -
sampVaz - 06.11.2010
Wouldn't you need to make a forward function for "loltimer"?
Re: Timer for command??? -
ViruZZzZ_ChiLLL - 06.11.2010
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/command", cmdtext, true, 9) == 0)
{
if(GetPVarInt(playerid,"WAITBEFOREUSINGITAGAIN")>GetTickCount())return SendClientMessage(playerid,Colour,"ERROR : You must wait before using a command");
SetPVarInt(playerid,"WAITBEFOREUSINGITAGAIN",GetTickCount()+5000); // 1000 = 1 secs
// Put some codes here
}
return 1;
}
Same goes to dcmd and zcmd
EDIT : Oh shi... Better look at the time and date next time >.>
Re: Timer for command??? -
<Weponz> - 06.11.2010
lol how long ago did i post this xD
Re: Timer for command??? -
Mean - 06.11.2010
Sigh, use SetTimerEx