How to set a timer so a command can be used only one every 50 seconds.
#1

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.
Reply
#2

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;
}
Reply
#3

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

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
Reply
#5

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

becouse i like pvars and is to easy to understand ...
Reply
#7

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

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

I agree with gigi
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)