Timer problem
#1

Ok I have this code that I got from old post :

PHP код:
new TimeTimeMTimeS;
new 
Text:Textdraw0
PHP код:
Textdraw0 TextDrawCreate(605.0,25.0,"5:00");
TextDrawBackgroundColor(Textdraw00x000000AA);
TextDrawFont(Textdraw03);
TextDrawLetterSize(Textdraw00.5,1.5);
TextDrawAlignment(Textdraw0,3);
TextDrawSetOutline(Textdraw02);
TextDrawSetProportional(Textdraw01);
TextDrawColor(Textdraw0,0xFFFFFFFF);
TimeM 5;
TimeS 0;
Time SetTimer("UpdateTime",1000true); 
PHP код:
TextDrawShowForPlayer(playeridTextdraw0); 
PHP код:
forward UpdateTime();
public 
UpdateTime()
{
  new 
Str[34];
  
TimeS --;
  if(
TimeM == && TimeS == 0)
  {
    
KillTimer(Time);
  }
  if(
TimeS == -1)
  {
    
TimeM--;
    
TimeS 59;
  }
  
format(Strsizeof(Str), "%02d:%02d"TimeMTimeS);
  
TextDrawSetString(Textdraw0Str);
  return 
1;

I want to make the textdraw start countdown from 5 minutes.But when I try IG its start from 4:30.
Reply
#2

Can you kindly explain more?
I can't understand what you mean.
Reply
#3

Ive got all this code from old topic how to make timer textdraw.So I copy all of them and tried it in my server and its work.But as I know from that old post,I only need to change the
PHP код:
TimeM 5;
TimeS 0
to change the minutes and seconds.But when I tried it to change to 5 the textdraw start the countdown from 4:30.Thats the problem.
Reply
#4

PHP код:
TimeM 5;
TimeS 30
Reply
#5

I tried it but it start at 5:02 but when I change the
PHP код:
TimeS 24 
its start at 5:00 By the way,thanks.
Reply
#6

it could be the reason that you put this in OnGameModeInit and it starts when you start the server not when you join the server
put a printf("%d:%d",TimeM,TimeS); under your textdraw create and in the updatetimer to see exactly if it countdowns right or not.
Reply
#7

Nah my problem is its start at 5:02
Reply
#8

Time units are relative and any unit can be converted to another. It is common knowledge that a minute is 60 seconds. Hence, 5 minutes is 5 x 60 = 300 seconds. So why two variables?

It then becomes:
PHP код:
forward UpdateTime();
public 
UpdateTime()
{
  if(--
TimeS <= 0)
  {
    
KillTimer(Time);
  }
    
  new 
Str[34];
  
format(Strsizeof(Str), "%02d:%02d"TimeS 60TimeS 60);
  
TextDrawSetString(Textdraw0Str);
  return 
1;

Obviously set TimeS to 300 seconds (= 5 minutes).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)