timer doesn't work!
#1

Код:
TimeS[playerid] = 00;
TimeM[playerid] = 3;
truckmission = SetTimerEx("Trucktimer",1000,true,"i",playerid);
I do a timer for seconds,minutues count down and it doesn't even set the string but the textdraw is there,
Код:
public TruckTimer()
{
	for(new i=0; i<MAX_PLAYERS;i++)
	{
	  if(TimeM[i] == 0 && TimeS[i] < 0)
	  {
			SendClientMessage(i,COLOR_ORANGE,"[INFO] Time ended, mission aborted.");
			gCheckPoint[i] = 0;
			InUse[i] = 0;
			times[i] = 0;
			TimeS[i] = 00;
			TimeM[i] = 00;
			TextDrawHideForPlayer(i,Timer[i][0]);
			TextDrawHideForPlayer(i,Timer[i][1]);
			TextDrawDestroy(Timer[i][0]);
			TextDrawDestroy(Timer[i][1]);
			DisablePlayerCheckpoint(i);
			KillTimer(truckmission);
      return 0;
		}
		else if(TimeS[i] > 00)
		{
		  new str[128];
		  TimeS[i]--;
		  format(str, sizeof(str), "%d:%d", TimeM[i],TimeS[i]);
			TextDrawSetString(Timer[i][1],str);
		}
		else if(TimeS[i] < 00)
		{
		  new str[128];
		  TimeS[i] = 59;
		  TimeM[i]--;
			format(str, sizeof(str), "%d:%d", TimeM[i],TimeS[i]);
			TextDrawSetString(Timer[i][1],str);
		}
	}
	return 1;
}
Reply
#2

You must TextDrawShowForPlayer after TextDrawSetString.
Reply
#3

Still the same, and it shows 3:0, but it should show 3:00
Reply
#4

You need to replace two zeros(00) with one(0).. and to make it 3:00, use %d:%02d.
Reply
#5

still doesn't work and it shows: 3:0. nothing more
Reply
#6

Since you're using settimerex, you probably need truckmission-timer for all players: truckmission[MAX_PLAYERS]
and you dont need to loop through all players in this timer:
pawn Код:
public TruckTimer(playerid)
{
  TimeS[playerid]--;
  if(TimeS[playerid] < 0)
  {
    TimeS[playerid] = 59;
    TimeM[playerid]--;
    if(TimeM[playerid] < 0)
    {
      SendClientMessage(playerid, COLOR_ORANGE, "[INFO] Time ended, mission aborted.");
      KillTimer(truckmission[playerid]);
      //the rest code
    }
  }
  new str[10];
  format(str, sizeof(str), "%d:%02d", TimeM[playerid], TimeS[playerid]);
  TextDrawSetString(Timer[playerid][1], str);
  TextDrawShowForPlayer(playerid, Timer[playerid][1]);
}
Reply
#7

Weird o_O, it still doesn't work:

pawn Код:
public TruckTimer()
{
    for(new i=0; i<MAX_PLAYERS;i++)
    {
      TimeS[i]--;
      if(TimeS[i] < 0)
        {
          TimeS[i] = 59;
          TimeM[i]--;
            if(TimeM[i] == 0 && TimeS[i] < 0)
          {
                SendClientMessage(i,COLOR_ORANGE,"[INFO] Time ended, mission aborted.");
                gCheckPoint[i] = 0;
                InUse[i] = 0;
                times[i] = 0;
                TimeS[i] = 0;
                TimeM[i] = 0;
                TextDrawHideForPlayer(i,Timer[i][0]);
                TextDrawHideForPlayer(i,Timer[i][1]);
                TextDrawDestroy(Timer[i][0]);
                TextDrawDestroy(Timer[i][1]);
                DisablePlayerCheckpoint(i);
                KillTimer(truckmission[i]);
          return 0;
            }
        }
        new str[128];
        format(str, sizeof(str), "%d:%02d", TimeM[i],TimeS[i]);
        TextDrawSetString(Timer[i][1],str);
        TextDrawShowForPlayer(i,Timer[i][1]);
    }
}
Reply
#8

You dont need to loop through all players Use the code I gave you.
Reply
#9

I tried without the loop, doesn't work too, i am doing a COUNTDOWN till 0:00 not 0 minutes and some seconds..
Reply
#10

Quote:
Originally Posted by 0ne
i am doing a COUNTDOWN till 0:00 not 0 minutes and some seconds..
The code I gave ends at 0:00..

Try gametext:
pawn Код:
new str[40];
format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~%d:%02d", TimeM[playerid], TimeS[playerid]);
GameTextForPlayer(playerid, str, 1200, 3);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)