[help!]i wanna make a cooldown -
mladen - 28.10.2010
hy can som1 tell me how to make a cooldown i have airstrikes fs but i wanna to make that can be used every 3 minutes any help?
Re: [help!]i wanna make a cooldown -
mladen - 28.10.2010
bump :@ tooooo shooooooort
Re: [help!]i wanna make a cooldown -
Kyle - 28.10.2010
CREDIT TO BMUK AS THIS WAS DONE ONLY A FEW TOPICS AGO!
Top
pawn Код:
new usedcommand[MAX_PLAYERS];
OnConnect..
pawn Код:
usedcommand[playerid] =0;
OnDisConnect..
pawn Код:
usedcommand[playerid] =0;
InYourCommand..
pawn Код:
usedcommand[playerid] =10; // 10 seconds?
InYourCommand..
pawn Код:
if(usedcommand[playerid]) return SendClientMessage(playerid,COLOR,"Plz Wait");
GameModeInit..
pawn Код:
SetTimer("loltimer",1000,1);
EndOfScript..
pawn Код:
public loltimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(usedcommand[i] > 0)
{
usedcommand[i] --;
}
}
}
Re: [help!]i wanna make a cooldown -
LarzI - 28.10.2010
<ignore>
Re: [help!]i wanna make a cooldown -
Kyle - 28.10.2010
No? Becuse he might want to add more timers in the public. It works fine as I did it, No need to make it more confusing for him.
Re: [help!]i wanna make a cooldown -
LarzI - 28.10.2010
No you didn't make it fine, actually.
Cuz what happens (ignore my code, that's wrong too) is that you set that variable to 10 everytime the command is called, so if a player tries to spam it, he would have to wait ANOTHER 10 seconds.
If he haven't waited precisely 10 seconds or more, he will have to wait another 10 seconds..
And you want to stop the decreasement. Why continue a loop for 30 minutes when it's no longer used?
Re: [help!]i wanna make a cooldown -
mladen - 28.10.2010
ok thanks kylesmith =)
Re: [help!]i wanna make a cooldown -
iJumbo - 28.10.2010
pawn Код:
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"wait 3 minutes");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+180000);
put this at the top of command ...
Re: [help!]i wanna make a cooldown -
Kyle - 28.10.2010
Quote:
Originally Posted by gigi1223
pawn Код:
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"wait 3 minutes"); SetPVarInt(playerid,"CMDABUSE",GetTickCount()+180000);
put this at the top of command ...
|
mladen, Ignore this person. Mine works so why change it.
Re: [help!]i wanna make a cooldown -
LarzI - 28.10.2010
Because his is more reliable.
Change pvars into normal variables, and the code is optimised