Problem with Text draws
#1

Ok, I am working on a clock for my game mode, so I made this function

pawn Код:
public UpdateClock()
{
    TextDrawDestroy(ClockText);

    new str[5];
    new tmphour;
    new tmpminute;
    new tmpsecond;
    gettime(tmphour, tmpminute, tmpsecond);
   
    if(tmphour <= 12)
    {
      if(tmpminute < 10)
      {
            format(str, sizeof(str), "%d:0%d", tmphour, tmpminute);
        }
      if(tmpminute >= 10)
      {
            format(str, sizeof(str), "%d:%d", tmphour, tmpminute);
        }
    }
    if(tmphour > 12)
    {
      if(tmpminute < 10)
      {
            format(str, sizeof(str), "%d:0%d", tmphour - 12, tmpminute);
        }
      if(tmpminute >= 10)
      {
            format(str, sizeof(str), "%d:%d", tmphour - 12, tmpminute);
        }
    }
   
    ClockText = TextDrawCreate(557, 30, str);
    TextDrawSetOutline(ClockText, 1);
    TextDrawFont(ClockText, 2);
    TextDrawColor(ClockText, 0xffffffff);

    for(new i=0; i<=GetMaxPlayers(); i++)
    {
        TextDrawShowForPlayer(i, ClockText);
    }
    if(tmphour <= 12)
    {
        printf("ServerTime:%d:%d", tmphour, tmpminute);
    }
    if(tmphour > 12)
    {
        printf("ServerTime:%d:%d", tmphour - 12, tmpminute);
    }
    return 1;
}
I have set the UpdateClock inside one of my timer functions that is called every minute. I know this works because my second timer works and they are exactly the same other than the interval on the second is 1000 and on the minute it is 100000.

So, I know this function is called because the clock does show up. But the problem is that it doesnt update. I include the TextDrawDestroy and I Create a whole new text draw with a new format, but it always stays the same.

Any one got any ideas? If you need more areas of the code to figure it out, just ask.
Reply
#2

since i got my problems with it too...
n ppl sumtimes help n then not....
i kno that u should use TextdrawSetString to update it...
Reply
#3

I will try that and update you if it works.

Update: TextDrawSetString works. Thanks your awesome.

I also just realized my minute timer was set to go off every hour :P
Reply
#4

no problem
watch my thread n please try to help k?
Reply
#5

Where is your thread?

Update: im such a noob, I just realized I called my Minute timer "MintueTimer" instead of "MinuteTimer"
Reply
#6

http://forum.sa-mp.com/index.php?topic=92529.0 my thread
n btw u got msn if ye pm me it or post it here^_^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)