Timer won't Countdown!!!
#1

I have a textdraw with a timer:
pawn Code:
new GameMinutes = 14;
new GameSeconds = 59;
new Text:Textdraw0;
Textdraw properties:
pawn Code:
Textdraw0 = TextDrawCreate(86.000000,427.000000,"15:00");
    TextDrawAlignment(Textdraw0,2);
    TextDrawBackgroundColor(Textdraw0,0x000000ff);
    TextDrawFont(Textdraw0,3);
    TextDrawLetterSize(Textdraw0,0.499999,2.000000);
    TextDrawColor(Textdraw0,0xffffffff);
    TextDrawSetOutline(Textdraw0,1);
    TextDrawSetProportional(Textdraw0,1);
    TextDrawSetShadow(Textdraw0,1);
Timer:
pawn Code:
SetTimer("GameTime",1000,1);
Timer function:
pawn Code:
public GameTime()
{
    if(GameSeconds > 0 || GameMinutes > 0)
    {
        GameSeconds--;
        if(GameSeconds <= -1)
        {
            GameMinutes--;
            GameSeconds=59;
        }
        new TimeString[14];
        format(TimeString,sizeof(TimeString),"%02d:%02d",GameMinutes,GameSeconds);
        TextDrawSetString(Textdraw0,TimeString);
    }
    if(GameSeconds == 0 && GameMinutes == 0)
    {
        OnGameModeExit();
    }
    return 1;
}
When I go ingame, all I see is 15:00 and they timer doesn't count down! Please help me!
Reply
#2

I know this is off-topic but couldnt you use the game clock?
Reply
#3

pawn Code:
new GameSeconds = 900; // 60s - min, 300s - 5min
public GameTime()
{
    new m = ((GameSeconds/60)%60);
    new s = (GameSeconds%60);
    new TimeString[14];
    format(TimeString,sizeof(TimeString),"%02d:%02d",m,s);
    TextDrawSetString(Textdraw0,TimeString);
    if(GameSeconds == 0) OnGameModeExit();
    GameSeconds--;
    return 1;
}
and TextDrawShowForAll or ForPlayer
Reply
#4

@a_big: No, it's a countdown timer until the end of the gamemode.
Reply
#5

Quote:
Originally Posted by a_big
View Post
I know this is off-topic but couldnt you use the game clock?
^^ That.

Just use TogglePlayerClock and use a timer to update the time every second or so.
Reply
#6

Jefff: It still doesn't count down :/
Reply
#7

Quote:
Originally Posted by Intoxicated
View Post
^^ That.

Just use TogglePlayerClock and use a timer to update the time every second or so.
Do you not get it? He said COUNTDOWN not the default GTA SA clock ..

Why not use gametext instead of textdraws? Then again other gametext may interfere with it.
Reply
#8

Where is TDShowFor ?
Reply
#9

Under OnPlayerConnect

pawn Code:
public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid, Textdraw0);
    return 1;
}
Reply
#10

Doubt this will work but, try setting it for max players:

pawn Code:
public GameTime()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GameSeconds > 0 || GameMinutes > 0)
        {
            GameSeconds--;
            if(GameSeconds <= -1)
            {
                GameMinutes--;
                GameSeconds=59;
            }
            new TimeString[14];
            format(TimeString,sizeof(TimeString),"%02d:%02d",GameMinutes,GameSeconds);
            TextDrawSetString(Textdraw0,TimeString);
        }
        if(GameSeconds == 0 && GameMinutes == 0)
        {
            OnGameModeExit();
        }
    }
    return 1;
}
Reply
#11

Nice try, but still no success!
Reply
#12

Try this:
pawn Code:
new GameSeconds = 1451;
new Text:Textdraw0;
pawn Code:
Textdraw0 = TextDrawCreate(86.000000,427.000000,"Loading..");
    TextDrawAlignment(Textdraw0,2);
    TextDrawBackgroundColor(Textdraw0,0x000000ff);
    TextDrawFont(Textdraw0,3);
    TextDrawLetterSize(Textdraw0,0.499999,2.000000);
    TextDrawColor(Textdraw0,0xffffffff);
    TextDrawSetOutline(Textdraw0,1);
    TextDrawSetProportional(Textdraw0,1);
    TextDrawSetShadow(Textdraw0,1);
pawn Code:
public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid, Textdraw0);
    return true;
}
pawn Code:
SetTimer("GameTime",1000,1);
pawn Code:
forward GameTime();
public GameTime()
{
    GameSeconds++;
    new TimeString[14];
    format(TimeString,sizeof(TimeString),"%i:%i",(GameSeconds/(60*60))%24,(GameSeconds/60)%60);
    //                                 Hours:Minutes
    TextDrawSetString(Textdraw0,TimeString);
    //In case you need a reset on completing 24 hours:
    if((GameSeconds/(60*60))%24 == 24) { GameSeconds = 0; }
    return true;
}
//You don't need GameMinutes here. No other stuff.
Reply
#13

None of the previous posts will fix your problem. You need to hide and re-display the textdraw each time you set a new string to it, or it won't update on the player's screen. You should hide it, set the string, then show it again.
pawn Code:
TextDrawHideForAll( Textdraw0 );
TextDrawSetString( Textdraw0, TimeString );
TextDrawShowForAll( Textdraw0 );
Reply
#14

Quote:
Originally Posted by Bakr
View Post
None of the previous posts will fix your problem. You need to hide and re-display the textdraw each time you set a new string to it, or it won't update on the player's screen. You should hide it, set the string, then show it again.
pawn Code:
TextDrawHideForAll( Textdraw0 );
TextDrawSetString( Textdraw0, TimeString );
TextDrawShowForAll( Textdraw0 );
Mine is tested and it works without it. (And I usually add that after string update though... Weird, lol.)
Reply
#15

Quote:
Originally Posted by Bakr
View Post
None of the previous posts will fix your problem. You need to hide and re-display the textdraw each time you set a new string to it, or it won't update on the player's screen. You should hide it, set the string, then show it again.
pawn Code:
TextDrawHideForAll( Textdraw0 );
TextDrawSetString( Textdraw0, TimeString );
TextDrawShowForAll( Textdraw0 );
No, the timer doesn't countdown, even after putting it in the timer like this:

pawn Code:
public GameTime()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GameSeconds > 0 || GameMinutes > 0)
        {
            GameSeconds--;
            if(GameSeconds <= -1)
            {
                GameMinutes--;
                GameSeconds=59;
            }
            new TimeString[14];
            format(TimeString,sizeof(TimeString),"%02d:%02d",GameMinutes,GameSeconds);
            TextDrawSetString(Textdraw0,TimeString);
            TextDrawHideForAll( Textdraw0 );
            TextDrawSetString( Textdraw0, TimeString );
            TextDrawShowForAll( Textdraw0 );
        }
        if(GameSeconds == 0 && GameMinutes == 0)
        {
            OnGameModeExit();
        }
    }
    return 1;
}
Reply
#16

Have you tried my method above?^
Reply
#17

Im trying it now.
Reply
#18

Quote:
Originally Posted by iPLEOMAX
View Post
Have you tried my method above?^
With your method, all I get is "Loading" in the bottom corner.
Reply
#19

You sure you have done everything correctly? (Look at mine in the screeny here, with seconds )

Reply
#20

Well, I copied and pasted your script so it should have worked. I honestly have no idea why it's doing this...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)