Easy Command timer
#1

Im using this script, When you type /buygun then you have to wait 5 sec to use /buygun again, But how can i make it ''first time'' type /buygun you have to wait 5 sec?

i mean FIRST TIME type /buygun, not second time

pawn Код:
command(buygun, playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.5, 295.5375,-80.8118,1001.5156)) {
    if(cdTimer[playerid]-gettime() > 0) return SendClientMessage(playerid, 0xFF0000AA, "Please wait before using another Adrenaline Pill!");
    ShowPlayerDialog(playerid,04041,DIALOG_STYLE_LIST,""); //whatever
    cdTimer[playerid] = gettime() + 5; // 5 seconds
    }
    return 1;
}
Reply
#2

Use

pawn Код:
if(gettime() - cdTimer[playerid] < 5)
instead of your check.
Reply
#3

wont work, i can type it without wait
Reply
#4

Код:
new buygun[MAX_PLAYERS];
Top of the script


Under onplayerconnect
Код:
   buygun[playerid] = -5000;
in your CMD
Код:
    if(tickcount() - buygun[playerid] < 5000) return SendClientMessage(playerid, -1, "You must wait 5 seconds before using this command again.");
Reply
#5

look like this? still wont work now i can spam it /buygun

pawn Код:
public OnPlayerConnect(playerid)
{
    buygun[playerid] = -5000;
    return 1;
}
pawn Код:
command(buygun, playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.5, 295.5375,-80.8118,1001.5156)) {
    if(tickcount() - buygun[playerid] < 5000) return SendClientMessage(playerid, -1, "You must wait 5 seconds before using this command again.");
    ShowPlayerDialog(playerid,04041,DIALOG_STYLE_LIST,""); //command works
    }
    return 1;
}
Reply
#6

My bad, add this under the line i gave u in the CMD


Код:
    buygun[playerid] = tickcount();
Reply
#7

pawn Код:
cdTimer[playerid] = gettime() + 5;
should be

pawn Код:
cdTimer[playerid] = gettime();
Reply
#8

thanks montana it works now, but its not what i want, i wanna make it first time type /buygun you need to wait, now its second time to wait..

What i want is like this
type /buygun
Please wait 5 sec
Show Player Dialog
Reply
#9

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
cdTimer[playerid] = gettime() + 5;
should be

pawn Код:
cdTimer[playerid] = gettime();
this one give me errors

error 028: invalid subscript (not an array or too many subscripts): "cdTimer"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Reply
#10

Go back to the original code you had in the first post and follow my two posts only:

http://forum.sa-mp.com/showpost.php?...58&postcount=2
http://forum.sa-mp.com/showpost.php?...02&postcount=7
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)