[SOLVED finaly :D] Really need help with countdown timer
#3

It seems ok, but i've simplified it a bit. Try it now.
Before the countdown starts, the values should be as so:

pawn Code:
Tmin = [whatever minute you want];
Tsec = 0;
pawn Code:
public SetCountDown(minutes, seconds, Float:x, Float:y)
{
   Timer = TextDrawCreate(x, y, "00:00");
   TextDrawTextSize(Timer,636.000000,824.000000);
   TextDrawAlignment(Timer, 2);
   TextDrawFont(Timer,3);
   TextDrawLetterSize(Timer,0.499999,1.800000);
   TextDrawColor(Timer,0xffffffff);
   TextDrawSetProportional(Timer,2);
   TextDrawSetShadow(Timer,1);
   TextDrawSetOutline(Timer, 1);

   Tmin = minutes;
   Tsec = seconds; // should be "0" if you want the whole minute

   TTimer = SetTimer("TimerSet",1000,1);
   return 1;
}

Here is the "TimerSet" callback that is repeated 1000 ms

public TimerSet()
{
    new string[5];
    Tsec--;
    if(Tsec <= 0)
    {
        Tsec = 59;
        Tmin--;
        if(Tmin <= 0)
        {
            OnCountDownEnd(); // Time's Up
        }
    }
    format(string, 5, "%d:%d",Tmin, Tsec);
    TextDrawSetString(Timer, string);
    ///TextDrawShowForAll ?
}
Also, aren't you supposed to be showing the textdraw once you've formatted the string? maybe the textdraw is being shown every 10 seconds in another timer or callback.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)