Las Venturas Playground
Time on commands - Printable Version

+- Las Venturas Playground (https://forum.sa-mp.nl)
+-- Forum: Miscellaneous (https://forum.sa-mp.nl/forum-4.html)
+--- Forum: Gaming (https://forum.sa-mp.nl/forum-27.html)
+--- Thread: Time on commands (/thread-8422.html)



Time on commands - Dimplex - 05-01-2008

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


Re: Time on commands - Jay - 05-01-2008

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