SA-MP Forums Archive
How to set a timer so a command can be used only one every 50 seconds. - 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: How to set a timer so a command can be used only one every 50 seconds. (/showthread.php?tid=186258)



How to set a timer so a command can be used only one every 50 seconds. - Haydz - 28.10.2010

I had no idea on what to search, i don't want you to post the code just tell me what i need to do and post some wiki pages that will help me, thanks.


Re: How to set a timer so a command can be used only one every 50 seconds. - Seven. - 28.10.2010

Wrote something for you quickly. Hope you see how it works a bit :P
pawn Код:
new DoCMDagain[MAX_PLAYERS] = 0;

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(command,7,cmdtext);
    return 0;
}

dcmd_command(playerid,params[])
{
    if(DoCMDagain[playerid] == 0) return SendClientMessage(playerid,color,"You can only use this command each 50 seconds!");
    //execute
    //your
    //command
    DoCMDagain[playerid] = 0;
    SetTimerEx("CommandAvailibleAgain",5*10000,false,"i",playerid);
    return true;
}

forward CommandAvailibleAgain(playerid);
public CommandAvailibleAgain(playerid)
{
    DoCMDagain[playerid] = 1;
    SendClientMessage(playerid,color,"You can use the command again!");
    return true;
}



Re: How to set a timer so a command can be used only one every 50 seconds. - Kyle - 28.10.2010

Check here:
https://sampforum.blast.hk/showthread.php?tid=186263


Re: How to set a timer so a command can be used only one every 50 seconds. - iJumbo - 28.10.2010

pawn Код:
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"wait 50 sec");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+50000);
idk if 50000 is 50 sec xD


Re: How to set a timer so a command can be used only one every 50 seconds. - Brian_Furious - 28.10.2010

Quote:
Originally Posted by gigi1223
Посмотреть сообщение
idk if 50000 is 50 sec xD
I think its 50minutes


Re: How to set a timer so a command can be used only one every 50 seconds. - iJumbo - 28.10.2010

becouse i like pvars and is to easy to understand ...


Re: How to set a timer so a command can be used only one every 50 seconds. - Kyle - 28.10.2010

Normal vars are infact faster than pvars. Why use them :/. They seem more complex than normal vars.


Re: How to set a timer so a command can be used only one every 50 seconds. - iJumbo - 28.10.2010

wtf any one have a method of scripting ... if i like pvars i like pvars and u like normal vars ....


Re: How to set a timer so a command can be used only one every 50 seconds. - Brian_Furious - 28.10.2010

I agree with gigi