10 minute timer.
#1

Ok, I am making a Robbery System into my script.

I want to know how Imake a 10 minute timer and when I do the command it says:

you have 10 minutes left before robbing a store again.

Then when a minute goes down E.G: 1 minute has passed.

you have 9 minutes left before robbing a store again.

and so on and so on

The command:

pawn Код:
CMD:robshop(playerid, params[])
{
    if(!IsAt247(playerid))
    {
        SendClientMessage(playerid, COLOR_GRAD2, "   You're not in a 24-7!");
        return 1;
    }
    else if(PlayerInfo[playerid][pWantedLevel] == 6)
    {
        SendClientMessage(playerid, COLOR_GRAD2, "  You're Most Wanted.");
        return 1;
    }
    else if(PlayerInfo[playerid][pFaction] == 1 || PlayerInfo[playerid][pFaction] == 2)
    {
        SendClientMessage(playerid, COLOR_GRAD2, "  You're a Law Enforcement Officer, you cannot rob the store..");
        return 1;
    }
    else if(RobTimer[playerid] > 0) {
        format(string, sizeof(string), "You must wait %d seconds before speaking again in this channel.", RobTimer[playerid]);
        SendClientMessage(playerid, COLOR_GREY, string);
        return 1;
    }
    PlayerInfo[playerid][pWantedLevel]++;
    SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pWantedLevel]);
    SendClientMessage(playerid, COLOR_LIGHTRED, "You have comitted a crime, Robbery. (Reporter: CCTV)");
    return 1;
}
Reply
#2

Southclaw's Guide to the 'GetTickCount()' Function!
And how it can be used as an alternative for unnecessary timers!
Reply
#3

i recommend this --
https://sampforum.blast.hk/showthread.php?tid=254915
example usage --
pawn Код:
new last_used[MAX_PLAYERS];//on top

if( (gettime() - last_used[playerid]) < 60*10 /*10 miins*/)//in command
{
new str[100], tim = (gettime() -last_used[playerid]) / 60;
format(str, sizeof(str), "Still %i mins left to use it", tim);
return 1;
}

last_used[playerid] = gettime();//under when command was used succesfully
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)