24.06.2012, 05:43
Very simple
I simply copied his code and added it in as another GameText.
pawn Код:
// top
new Count, Timer[MAX_PLAYERS];
// goes under OnPlayerCommandText. It's a command for the count down
if (strcmp("/countdown", cmdtext, true) == 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
Timer[playerid] = SetTimerEx("CountDown", 1000, true, "d", playerid); // Declaring a timer to call the public CountDown every 1 second
for(new i; i < MAX_PLAYERS; i ++) // looping through all players
{
if(IsPlayerConnected(i)) // if connected
{
if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if they are in your range
{
new str[4];
Count = 5; // setting the countdown to 5 .. you can change that
format(str, sizeof(str), "%d", Count); // formatting a string to use it in GameTextForPlayer
GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
}
}
}
return 1;
}
forward CountDown(playerid);
public CountDown(playerid)
{
Count --; // decreasing Count by one
if(Count == 0) // if Count reaches 0
{
KillTimer(Timer[playerid]); // kill the cd timer
// your codes when the cd ends go here
GameTextForPlayer(i, "GO GO GO!!, 3000, 3);
return 1; // to stop it
}
// so it's not = 0
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z); // getting the player position again (he probably has moved!)
new str[4];
format(str, sizeof(str), "%d", Count); // formatting a string with the new decreased Count
for(new i; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if he is in your range
{
GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
}
}
}
return 1;
}