Textdraw counting from 15:00 to 0:00
#1

Hello,

Few weeks ago I found a great textdraw code which counted down, but now I'm unable to find it.

Basically, I need a textdraw which counts down from 15:00

Thanks.
Reply
#2

Untested
pawn Код:
//At top
new CD;
new CDTimer;

//OnGameModeInit
new Text:CDTextDraw;
CDTextDraw = TextDrawCreate(240.0, 580.0, "_");

//In your command (To start the count down)
CD = 15;
TextDrawShowForAll(CDTextDraw);
CDTimer = SetTimer("CountDown", 1000, true);

//Somewhere in ur script but now in any callbacks
forward CountDown();
public CountDown()
{
    if(CD != 0)
    {
        new string[6];
        format(string, sizeof(string), "%02d", CD);
        TextDrawSetString(CDTextDraw, string);
        CD --;
    }
    else
    {
        KillTimer(CDTimer);
        TextDrawSetString(CDTextDraw, "CD stopped");
    }
    return 1;
}
Reply
#3

pawn Код:
//Somewhere in ur script but now in any callbacks
forward CountDown();
public CountDown()
{
    if(CD != 0)
    {
        new string[6];
        format(string, sizeof(string), "%02d", CD);
        TextDrawSetString(CDTextDraw, string);
        CD --;
    }
    else
    {
        KillTimer(CDTimer);
        TextDrawSetString(CDTextDraw, "CD stopped");
    }
    return 1;
}
TextDrawSetString(CDTextDraw, string); = error 017: undefined symbol "CDTextDraw"
Reply
#4

Wops.
Add the
pawn Код:
new Text:CDTextDraw;
at top of your scritpt with the others, not in OnGameModeinit, my fault :P
Reply
#5

Delete
pawn Код:
new Text:CDTextDraw;
From OnGameModeInIt and place it on top of your script.
Reply
#6

Fixed, thanks!

Textdraw doesn't appear, I made it appear under public OnGameModeInit(), so it doesn't start every time from beginning for every new player.

pawn Код:
CDTextDraw = TextDrawCreate(240.0, 580.0, "_");
    CD = 15;
    TextDrawShowForAll(CDTextDraw);
    CDTimer = SetTimer("CountDown", 1000, true);
This is under OnGameModeInit
Reply
#7

You have to show for each new player.
Reply
#8

TextDrawShowForAll(CDTextDraw); doesn't it do the job if it's under OnGameModeInit()?
Reply
#9

http://forum.sa-mp.com/showpost.php?...0&postcount=10
Should help you.

Jeffry
Reply
#10

PERFECT! This was the one I was looking for!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)