timer after command
#1

How can i add a timer so
. Vip use command /kitvip.
How can i make a timer so person cant use command after like 20min
Reply
#2

pawn Code:
new Temp[MAX_PLAYERS];

//OnPlayerConnect:
Temp[playerid] = 0;

//Begin the command
if(gettime() - Temp[playerid] < 20)  return SendClientMessage(playerid, 0xFF0000FF, "Wait time is up");
Temp[playerid] = gettime();



change the 20 to the value you want
Reply
#3

Simple. Create a variable, which saves the time of using the command.

pawn Code:
new KITVIP_TICKER[MAX_PLAYERS];
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/kitvip", cmdtext, true, 10) == 0)
    {
        if((gettime() - KITVIP_TICKER[playerid]) < ((1000 * 60) * 20)) return SendClientMessage(playerid, -1, "Please wait before using this command again.");

        KITVIP_TICKER[playerid] = gettime();
        // The command
        return 1;
    }
    return 0;
}
Don't forgot to reset variable after quit. (OnPlayerDisconnect)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)