SA-MP Forums Archive
Textdraw counting from 15:00 to 0:00 - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Textdraw counting from 15:00 to 0:00 (/showthread.php?tid=266265)



Textdraw counting from 15:00 to 0:00 - freshOrange - 04.07.2011

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.


Re: Textdraw counting from 15:00 to 0:00 - Laronic - 04.07.2011

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;
}



Re: Textdraw counting from 15:00 to 0:00 - freshOrange - 04.07.2011

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"


Re: Textdraw counting from 15:00 to 0:00 - Laronic - 04.07.2011

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


Re: Textdraw counting from 15:00 to 0:00 - Lorenc_ - 04.07.2011

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


Re: Textdraw counting from 15:00 to 0:00 - freshOrange - 04.07.2011

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


Re: Textdraw counting from 15:00 to 0:00 - Joe Staff - 04.07.2011

You have to show for each new player.


Re: Textdraw counting from 15:00 to 0:00 - freshOrange - 04.07.2011

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


Re: Textdraw counting from 15:00 to 0:00 - Jeffry - 04.07.2011

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

Jeffry


Re: Textdraw counting from 15:00 to 0:00 - freshOrange - 04.07.2011

PERFECT! This was the one I was looking for!