SA-MP Forums Archive
[Help] TextDraw timer - 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)
+--- Thread: [Help] TextDraw timer (/showthread.php?tid=124628)



[Help] TextDraw timer - Flake. - 31.01.2010

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


Re: [Help] TextDraw timer - Jeffry - 31.01.2010

Shall it count down secounds?
Or mins?


Re: [Help] TextDraw timer - Flake. - 31.01.2010

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


Re: [Help] TextDraw timer - Flake. - 31.01.2010

anyone? have one


Re: [Help] TextDraw timer - Jeffry - 31.01.2010

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


Re: [Help] TextDraw timer - [HiC]TheKiller - 31.01.2010

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



Re: [Help] TextDraw timer - Jeffry - 31.01.2010

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



Re: [Help] TextDraw timer - Flake. - 31.01.2010

thanks guys this is great


Re: [Help] TextDraw timer - biltong - 16.03.2010

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.


Re: [Help] TextDraw timer - Vince - 23.11.2010

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.