SA-MP Forums Archive
10 minute timer. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: 10 minute timer. (/showthread.php?tid=527809)



10 minute timer. - JordanDoughty - 24.07.2014

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



Re: 10 minute timer. - Beckett - 24.07.2014

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



Re: 10 minute timer. - BroZeus - 24.07.2014

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