Countdown for racers only trouble
#1

Uhm, im trying to make this countdown only work for people in races, I do like: CountTimer2(11); it just says "GO!" This is my code
Код:
stock CountTimer2(seconds)
{
  for(new i=0; i < MAX_PLAYERS; i++)
  {
	  if(Racing[i] == 1)
	  {
		  if (seconds > 0)
		  {
		    format(string,6,"~w~%d",seconds-1);
		    GameTextForPlayer(i, string,1100,4);
		    SoundForAll(1056);
     		CountTimer2(seconds-1);
		    break;
		  }
		  else if (seconds == 0)
		  {
		  	GameTextForPlayer(i, "~r~go!",2000,4);
		   	SoundForAll(1057);
		   	break;
		  }
		}
	}
}
Reply
#2

pawn Код:
#include <a_samp>

#undef MAX_PLAYERS
#define MAX_PLAYERS 10

new
    bool:Racing[MAX_PLAYERS] = {true,...};
   
public OnFilterScriptInit()
{
    SetTimerEx("CountTimer2",3000,false,"d", 10);
    return 1;
}

forward CountTimer2(seconds);
public CountTimer2(seconds)
{
    new
        string[6];
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(Racing[i] == true)
        {
            if(seconds == 0)
            {
                GameTextForPlayer(i, "~r~go!",2000,4); //print("Go");
//              SoundForAll(1057);
            } else {
                format(string,6,"~w~%d",seconds); //print(string);
                GameTextForPlayer(i, string,1000,4);
//              SoundForAll(1056);
            }
        }
    }
    if(seconds > 0)
    {
        seconds--;
        SetTimerEx("CountTimer2",1000,false,"d", seconds);
    }
}
Reply
#3

Don't know what exactly the guy above me means, but this is the problem:
There is no actual time between every time the function is called.
When the function is called, it directly recalls it if seconds is greater then 0, theres no time between it.
So it looks like it only shows go, but actually it shows 10, 9, 8, 7,6, 5, 4, 3, 2, 1 and Go all in less then a second.
So what you need to do is add an extra timer if seconds is greater then 0
Hope you understand what I mean and good luck!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)