[help!]i wanna make a cooldown
#1

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?
Reply
#2

bump :@ tooooo shooooooort
Reply
#3

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] --;        
        }    
    }
}
Reply
#4

<ignore>
Reply
#5

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.
Reply
#6

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?
Reply
#7

ok thanks kylesmith =)
Reply
#8

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 ...
Reply
#9

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.
Reply
#10

Because his is more reliable.
Change pvars into normal variables, and the code is optimised
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)