How to
#1

Hello guys...im wondering how to make one command and make it usable every 30 secs.
So if i do /command and i want do /command again i need to w8 30 secs.
Thanks
I use: sscanf,zcmd,foreach,asamp,ysi
Reply
#2

pawn Код:
new cmdcooldown[MAX_PLAYERS];
forward cooldown(playerid);

public cooldown(playerid)
{
      cmdcooldown[playerid] = 0;
      return 1;
}

CMD:something(playerid, params[])
{
      if(cmdcooldown[playerid] == 1) return SendClientMessage(playerid, -1, "You can't use this command so soon.");
      //your command
      cmdcooldown[playerid] = 1;
      SetTimer("cooldown", 30000, false);
      return 1;
}
Try something like this..
Reply
#3

Here.. this way is better.
pawn Код:
new delay[MAX_PLAYERS];

CMD:test(playerid,params[])
{
    if(gettime() < delay[playerid]) return SendClientMessage(playerid,-1,#You have to wait 30 seconds.);
    delay[playerid] = gettime() + 30;
    return 1;
}
Reply
#4

@CentyPoo it wont work, you will need to use SetTimerEx

@DizzY2306

pawn Код:
CMD:command(playerid,params[])
{
    new time=gettime();
    if((time-GetPVarInt(playerid,"cTime"))<30) return SendClientMessage(playerid,-1,"Wait for 30 seconds");
    SetPVarInt(playerid,"cTime",time);
    SendClientMessage(playerid,-1,"CMD used");
    return 1;
}
public OnPlayerConnect(playerid)
{
    SetPVarInt(playerid,"cTime",0);
    return 1;
}
Reply
#5

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
Here.. this way is better.
pawn Код:
new delay[MAX_PLAYERS];

CMD:test(playerid,params[])
{
    if(gettime() < delay[playerid]) return SendClientMessage(playerid,-1,#You have to wait 30 seconds.);
    delay[playerid] = gettime() + 30;
    return 1;
}
Yep you are right, it is better...thanks so much, rep+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)