SA-MP Forums Archive
How to - 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)
+--- Thread: How to (/showthread.php?tid=367570)



How to - DizzY2306 - 10.08.2012

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


Re: How to - CentyPoo - 10.08.2012

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..


Re: How to - leonardo1434 - 10.08.2012

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



Re: How to - [MM]RoXoR[FS] - 10.08.2012

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



Re: How to - DizzY2306 - 10.08.2012

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+