SA-MP Forums Archive
[HELP] CoolDown 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] CoolDown Timer (/showthread.php?tid=216974)



[HELP] CoolDown Timer - Chalwa - 26.01.2011

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;
    }



Re: [HELP] CoolDown Timer - randomkid88 - 26.01.2011

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


Re: [HELP] CoolDown Timer - Chalwa - 26.01.2011

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


Re: [HELP] CoolDown Timer - randomkid88 - 26.01.2011

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.


Re: [HELP] CoolDown Timer - Chalwa - 26.01.2011

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!


Re: [HELP] CoolDown Timer - randomkid88 - 26.01.2011

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.


Re: [HELP] CoolDown Timer - Chalwa - 26.01.2011

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"

:/


Re: [HELP] CoolDown Timer - Chalwa - 27.01.2011

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.


Re: [HELP] CoolDown Timer - randomkid88 - 27.01.2011

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.