SA-MP Forums Archive
Countdown for racers only trouble - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Countdown for racers only trouble (/showthread.php?tid=128627)



Countdown for racers only trouble - Eazy_Efolife - 18.02.2010

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



Re: Countdown for racers only trouble - smeti - 18.02.2010

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



Re: Countdown for racers only trouble - Rzzr - 18.02.2010

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!