View Full Version : Textdraws disappearing

17/08/2014, 11:41 AM
I got a little problem with my textdraws.
Every time one is created, it will disappear like shown in the video below.

Here's the code

at the top
new Text:clock;

here's the timer
public TimerSec()
new hour, minute, sek, string[128];
gettime(hour, minute, sek);
format(string, sizeof string, "%s%d:%s%d", (hour < 10) ? ("0") : (""), hour, (minute < 10) ? ("0") : (""), minute);
TextDrawSetString(clock, string);
foreach(new i : Player)
TextDrawShowForPlayer(i, clock);
return 1;

and here's ongamemodeinit
clock = TextDrawCreate(547, 28, "_");
TextDrawFont(clock, 1);
TextDrawLetterSize(clock, 0.4, 1.2);
TextDrawColor(clock, 0xffffffff);
TextDrawSetShadow(clock, 0);
TextDrawSetOutline(clock, 1);
TextDrawAlignment(clock, 0);
TextDrawBackgroundColor(clock, 0x000000ff);
TextDrawSetProportional(clock, 1);

17/08/2014, 11:46 AM
Just one question? Why do you loop every single player when you can use:

Show us the timer? And things around timer?

17/08/2014, 11:57 AM
That's gotta be one of the most bizzare scripts I've ever seen. I didn't (can't) watch the video so also no idea why it would disappear, TextDrawHide* or TextDrawDestroy on a conflicting ID might cause this.

So, things to correct, in your "TimerSec" public, why loop through all online players when you can use TextDrawShowForAll, also your format was that "most bizzare" thing to me, you can make it simpler:

format(string, sizeof(string), "%02d:%02d", hour, minute);

The "%02d" will format a number to only 2 decimals (the "2d" part) and a "0" in front signifies pad with zeroes if not long enough, e.g. "09:08" for 9:08AM.

Edit: MicroD was faster, I was writing this "wall of text".

17/08/2014, 12:14 PM
So turns out, that one of my other textdraws was messing up the rest of them.
Got it fixed.
I loop, because i want that textdraw only to be shown for the players that are logged in. (forgor that line)