18.05.2020, 01:25
You can have something like this or just loop all connected players and check if they're in range with the countdown issuer using IsPlayerInRangeOfPoint by getting the issuer's position and comparing it to other players
PHP Code:
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
public countdown()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetDistanceBetweenPlayers(playerid, i) < 100.0) // your range
{
if(CountDown == 6) GameTextForAll("~p~Starting...", 1000, 6);
CountDown--;
if(CountDown == 0)
{
GameTextForAll("~g~GO~ r~!", 1000, 6);
CountDown = -1;
for(new i = 0; i < MAX_PLAYERS; i++) {
TogglePlayerControllable(i, true);
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
}
return 0;
}
else
{
new text[7]; format(text, sizeof(text), "~w~%d", CountDown);
for(new i = 0; i < MAX_PLAYERS; i++) {
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
TogglePlayerControllable(i, false);
}
GameTextForAll(text, 1000, 6);
}
SetTimer("countdown", 1000, 0);
}
}
return 0;
}