SA-MP Forums Archive
How to make countdown time? - 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 to make countdown time? (/showthread.php?tid=477441)



How to make countdown time? - nuriel8833 - 24.11.2013

I tried searching but I cant find a tutorial that explains how to make a countdown (i.e 4:00 , 3:59 , 3:59 ..)


Re: How to make countdown time? - DobbysGamertag - 24.11.2013

Reply number 3 should help you out somewhat: https://sampforum.blast.hk/showthread.php?tid=315000


Re: How to make countdown time? - nuriel8833 - 24.11.2013

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Reply number 3 should help you out somewhat: https://sampforum.blast.hk/showthread.php?tid=315000
but its not counding down as a clock,I mean its counding down as 5..4..3..2..1.. and I need it to counddown like 4:00,3:59,3:58


Re: How to make countdown time? - erminpr0 - 24.11.2013

use 2 vars, one to store the minutes and otherone for seconds, and when secs get to the 0 --the minutes and set seconds to 59.. I am not in mood to code it, if you didn't understand I'll show you later xD


Re: How to make countdown time? - ReD_HunTeR - 24.11.2013

what u need that for? , Map changing after the counts end?


Re: How to make countdown time? - Zues - 24.11.2013

Quote:
Originally Posted by IceCube!
Посмотреть сообщение
pawn Код:
new Time[MAX_PLAYERS];
new FunctionTimer[MAX_PLAYERS];

forward function(playerid);
public function(playerid)
{
     new string, Min, sec;
     if(Time[playerid] > 0)
     {
            Time[playerid] --;
            sec = ((Time[playerid] * 1000));
            Minutes = ((Time[playerid] * 1000) / 60);
            format(string, sizeof(string), "%s:%s", Min, sec);
            TextDrawSetString(TextDrawDefine,  string);
     }
     else KillTimer(FuntionTimer[playerid]);
     return 1;
}

CMD:mycommand(playerid, params[])
{
          //code
          FuntionTimer[targetid/playerid] = SetTimerEx("function", 1000, true, "i", playerid);
          return 1;
}
Do you mean something like this?


Re: How to make countdown time? - Opah - 24.11.2013

pawn Код:
new mins;
new secs;

new CTTimer;//On Top Of Your Script



forward CT(playerid);
public CT(playerid)
{
    if(mins + secs > -1)
    {
        if(secs > -1)
        {
            new str[10];
            format(str,10,"%i:%i",mins,secs);
            GameTextForPlayer(playerid,str,500,6);
            secs = secs - 1;
        }
        else
        {
            mins = mins - 1;
            secs = 59;
            new str[10];
            format(str,10,"%i:%i",mins,secs);
            GameTextForPlayer(playerid,str,500,6);
            secs = secs - 1;
        }
    }
    else
    {
        GameTextForPlayer(playerid,"GO !",500,6);
        KillTimer(CTTimer);
    }
    return 1;
}


    //put this where you want to start the timer
    mins = 0;//change it with the value of minutes
    secs = 3;//change it with the value of seconds
    CTTimer = SetTimerEx("CT",1000,1,"iii",playerid);



Re: How to make countdown time? - nuriel8833 - 24.11.2013

Quote:
Originally Posted by BlackBomb
Посмотреть сообщение
what u need that for? , Map changing after the counts end?
aha,but the 2 guys in the above have already helped me,thank you very much!