SA-MP Forums Archive
How would I go about making this 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: How would I go about making this timer? (/showthread.php?tid=322627)



How would I go about making this timer? - rangerxxll - 03.03.2012

I'm trying to make a timer, so at the end of.. let's stay, 5 minutes a new map appears, and the game starts. I'd like some text that counts down from 300 seconds. How would I go, to make this possible?


Re: How would I go about making this timer? - Ballu Miaa - 03.03.2012

You can use this Countdown Timer and edit it a bit according to your usage. You can code your function!
pawn Код:
forward CountDown(playerid, seconds);
public CountDown(playerid, seconds)
{
    new string[50];
    if(seconds > 0)
    {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        PlayerPlaySound(playerid, 1056, X, Y, Z);
        format(string, sizeof(string), "~R~%d", seconds);
        GameTextForPlayer(playerid, string, 1000, 3);
        seconds = seconds -1;
        SetTimerEx("CountDown", 1000, 0, "ii", playerid, seconds);
        return 1;
    }
    if(seconds == 0)
    {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        PlayerPlaySound(playerid, 1057, X, Y, Z);
        TogglePlayerControllable(playerid, 1);
        return 1;
    }
    return 1;
}