[Help] TextDraw timer
#1

Hey can anyone help me with a TextDrawTimer

i would like one that counts down from 20 mins does anyone have on or a code or smth

Thanks: Flake
Reply
#2

Shall it count down secounds?
Or mins?
Reply
#3

Quote:
Originally Posted by Jeffry
Shall it count down secounds?
Or mins?
i would like it to be seconds
Reply
#4

anyone? have one
Reply
#5

I will try to make one. But i dont know if it works.
Reply
#6

Here ya go:

pawn Код:
//Where ever you are creating the TD
new Text:Textdraw0;
Textdraw0 = TextDrawCreate(17.000000, 429.000000, "20:00");
TextDrawBackgroundColor(Textdraw0, 65535);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, 16777215);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);

//Showing the TD
TextDrawShowForPlayer(playerid, Textdraw0);

//Updating the TD
new Time, TimeM = 20, TimeS = 0;
Time = SetTimer("UpdateTime", 1000, true);


forward UpdateTime();
public UpdateTime()
{
  new Str[34];
  TimeS --;
  if(TimeM == 0 && TimeS == 0)
  {
    KillTimer(Time);
  }
  if(TimeS == -1)
  {
    TimeM--;
    TimeS = 59;
  }
  if(TimeS<10)
  {
    format(Str, sizeof(Str), "%d:0%d, TimeM, TimeS);
  }
  if(TimeS>9)
  {
    format(Str, sizeof(Str), "
%d:%d, TimeM, TimeS);
  }
  TextDrawSetString(Textdraw0, Str);
  return 1;
}
Reply
#7

Rofl, you were faster then me.

But at this is a mistake:

pawn Код:
if(TimeS<10)
  {
    format(Str, sizeof(Str), "%d:0%d, TimeM, TimeS); // <== Missing "
  }
  if(TimeS>9)
  {
    format(Str, sizeof(Str), "%d:%d, TimeM, TimeS); // <== Missing "
  }
MUst be this:

pawn Код:
if(TimeS<10)
  {
    format(Str, sizeof(Str), "%d:0%d", TimeM, TimeS);
  }
  if(TimeS>9)
  {
    format(Str, sizeof(Str), "%d:%d", TimeM, TimeS);
  }
Reply
#8

thanks guys this is great
Reply
#9

Quote:
Originally Posted by [HiC
TheKiller ]
Here ya go:

pawn Код:
//Where ever you are creating the TD
new Text:Textdraw0;
Textdraw0 = TextDrawCreate(17.000000, 429.000000, "20:00");
TextDrawBackgroundColor(Textdraw0, 65535);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, 16777215);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);

//Showing the TD
TextDrawShowForPlayer(playerid, Textdraw0);

//Updating the TD
new Time, TimeM = 20, TimeS = 0;
Time = SetTimer("UpdateTime", 1000, true);


forward UpdateTime();
public UpdateTime()
{
  new Str[34];
  TimeS --;
  if(TimeM == 0 && TimeS == 0)
  {
    KillTimer(Time);
  }
  if(TimeS == -1)
  {
    TimeM--;
    TimeS = 59;
  }
  if(TimeS<10)
  {
    format(Str, sizeof(Str), "%d:0%d, TimeM, TimeS);
  }
  if(TimeS>9)
  {
    format(Str, sizeof(Str), "
%d:%d, TimeM, TimeS);
  }
  TextDrawSetString(Textdraw0, Str);
  return 1;
}
I got more errors that I'v ever had with this. Please explain exact;y where everything needs to go, that's where I'm confused.
Reply
#10

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
pawn Код:
if(TimeS<10)
  {
    format(Str, sizeof(Str), "%d:0%d", TimeM, TimeS);
  }
  if(TimeS>9)
  {
    format(Str, sizeof(Str), "%d:%d", TimeM, TimeS);
  }
Gotta love how everyone always seems to do that.
You can get rid of that if structure completely by using the right format values.

pawn Код:
format(Str, sizeof(Str) "%02d:%02d", TimeM, TimeS);
Will always output two digits, no matter the values.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)