Hello There, Guest! Login or Register


Time on commands
#1
Hi all,

I have a question, how i must put a time limit on a command?
So if i use /taxi, that i must wait 1 min before i can use it again?

Grtz and Thnx,

Dimplex
Reply
#2
Use the function, GetTickCount();

Code:
new WaitDelay[MAX_PLAYERS],
    String[32];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext,"/test"))
    {
        new waittime = gettime() - WaitDelay[playerid];

        if (waittime < 5)
        {
            format(String, sizeof(String), "You need to wait %d seconds!", 5 - waittime);
            SendClientMessage(playerid, 0xFF0000FF, String);
        }
        else
        {
            SendClientMessage(playerid, 0x00FF00FF, "Ok!");
            WaitDelay[playerid] = gettime();
        }
        return true;
    }
    return false;
}
Reply