[HELP] CoolDown Timer
#1

Need some help making a cooldown timer on 40 seconds so it only can be used one time in 40 secs
can't really get it working here's the code. would appreciate some help, thanks

pawn Код:
if(strcmp(cmd, "/neon", true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, 1471.4198,-1497.0950,13.5469))
        {

            ShowPlayerDialog(playerid, 8899, DIALOG_STYLE_LIST, "Pick Neon Color", "Blue\nRed\nGreen\nWhite\nPink\nYellow\nRemove All Neon", "Select", "Cancel");
            PlayerPlaySound(playerid, 1133, 0.0, 0.0, 7.0);
        }
        return 1;
    }
Reply
#2

pawn Код:
//At the top somewhere, outside a function:
new CoolDown[MAX_PLAYERS];
new CoolTimer;
 //Your Command:
if(strcmp(cmd, "/neon", true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, 1471.4198,-1497.0950,13.5469))
        {
           if(CoolDown[playerid] == 0)
           {
                  ShowPlayerDialog(playerid, 8899, DIALOG_STYLE_LIST, "Pick Neon Color", "Blue\nRed\nGreen\nWhite\nPink\nYellow\nRemove All Neon", "Select", "Cancel");
                   PlayerPlaySound(playerid, 1133, 0.0, 0.0, 7.0);
                  CoolTimer = SetTimerEx("CoolDown", 40*1000, true, "i", playerid);
            }
        else return SendClientMessage(playerid, 0xFF0000AA, "You cannot use this again for 40 seconds!");
        }
        return 1;
    }

//at the bottom:

public CoolDown(playerid)
{
     if(CoolDown[playerid] == 0) return CoolDown[playerid] = 1;
     else
     {
          CoolDown[playerid] = 0;
          KillTimer(CoolTimer);
     }
}
Not tested, but its the basic concept
Reply
#3

Well thanks man i putted it in there right places but im getting some errors here:

pawn Код:
(47804) : error 021: symbol already defined: "CoolDown"
(47807) : error 010: invalid function or declaration
(47806) : error 010: invalid function or declaration
// thats the "public cooldown"

(13792) : warning 204: symbol is assigned a value that is never used: "CoolTimer"
//Thats in the /neon code
is there anyone who can help out please
Reply
#4

pawn Код:
forward CoolDown(playerid); // above the public
That will fix the function declaration.

For the rest: they could be related to that one error. If you get more errors, post the line of the error and the lines above and below.
Reply
#5

Getting same errors bro just this time, one extra hmm.

pawn Код:
(47804) : error 021: symbol already defined: "CoolDown" // One of these again..
(47804) : error 021: symbol already defined: "CoolDown"
(47807) : error 010: invalid function or declaration
(47806) : error 010: invalid function or declaration
// thats the "public cooldown"

(13792) : warning 204: symbol is assigned a value that is never used: "CoolTimer"
//Thats in the /neon code
PLEASE SOME HELP HERE!
Reply
#6

Make sure you don't have anything named "CoolDown" in your script elsewhere, if you do, rename these ones. Also make sure the public and variables are OUTSIDE everything else.
Reply
#7

Checked now 10 times and been changing around on it.
public and variables are outside everything else.
and there's nothing else in my script called "cooldown"

:/
Reply
#8

Can anyone atleast tell me the name of this i asume its not "CoolDown Timer" since i can't find it on Wiki Samp or here would appreciate it thanks.
Reply
#9

There isn't a name for it, I just whipped it up for you. The function is called SetTimerEx if that's what you're looking for. Its basically a modified anti-spam system. If you're looking for something like that, just search "anti spam" on the forum.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)