Get your position (If you don't have a certain position for the cd) (GetPlayerPos), loop through all the connected players (Read about Loops), use IsPlayerInRangeOfPoint to detect if a player is in the range of the point you want (You might use the one we got by GetPlayerPos) then show the game text for that player (GameTextForPlayer). I'm here if ya get stuck, just ask.
|
// 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
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;
}
// 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;
}
// your codes when the cd ends go here
GameTextForPlayer(i, "GO GO GO!!, 3000, 3);
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : error 017: undefined symbol "i"
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : error 017: undefined symbol "GO"
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : error 017: undefined symbol "GO"
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : fatal error 107: too many error messages on one line
GameTextForPlayer(playerid, "GO GO GO!!", 3000, 3);