So guys, I made it like this :
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));
}
PHP Code:
forward countdown(playerid);
public countdown(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetDistanceBetweenPlayers(playerid, i) < 200.0)
{
if(CountDown == 6) GameTextForPlayer(i, "~p~Starting...", 1000, 6);
CountDown--;
if(CountDown == 0)
{
GameTextForPlayer(i, "~g~GO~ r~!", 1000, 6);
CountDown = -1;
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);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
TogglePlayerControllable(i, false);
GameTextForPlayer(i, text, 1000, 6);
}
SetTimer("countdown", 1000, 0);
}
}
return 0;
}
CMD:countdown(playerid, params[]) {
if(PlayerInfo[playerid][Level] >= 4) {
if(CountDown == -1) {
CountDown = 6;
SetTimer("countdown", 1000, 0);
return CMDMessageToAdmins(playerid, "COUNTDOWN");
} else return SendClientMessage(playerid, red, "ERROR: Countdown in progress");
} else return SendClientMessage(playerid, red, "ERROR: You are not a high enough level to use this command");
}
And when i start the countdown, nothing happened. It just sends me the "CMDMessageToAdmins(playerid, "COUNTDOWN");". No one sees the countdown, me nor my friends. Even they're beside me
And I made a duel countdown like this :
PHP Code:
forward duelTimer(playerid);
public duelTimer(playerid)
{
/*if(DuelCD[dueler1] == 6) {
GameTextForPlayer(dueler1, "~p~Starting...", 1000, 6);
GameTextForPlayer(dueler2, "~p~Starting...", 1000, 6);
}*/
DuelCD[dueler1]--;
if(DuelCD[dueler1] == 0)
{
GameTextForPlayer(dueler1, "~g~go get em~ r~!", 1000, 6);
GameTextForPlayer(dueler2, "~g~go get em~ r~!", 1000, 6);
//DuelCD[dueler1] = -1;
TogglePlayerControllable(dueler1, true);
TogglePlayerControllable(dueler2, true);
PlayerPlaySound(dueler1, 1057, 0.0, 0.0, 0.0);
PlayerPlaySound(dueler2, 1057, 0.0, 0.0, 0.0);
return 0;
}
else
{
new text[7]; format(text, sizeof(text), "~w~%d", CountDown);
PlayerPlaySound(dueler1, 1056, 0.0, 0.0, 0.0);
PlayerPlaySound(dueler2, 1056, 0.0, 0.0, 0.0);
TogglePlayerControllable(dueler1, false);
TogglePlayerControllable(dueler2, false);
GameTextForPlayer(dueler1, text, 1000, 6);
GameTextForPlayer(dueler2, text, 1000, 6);
SetCameraBehindPlayer(dueler1);
SetCameraBehindPlayer(dueler2);
}
SetTimer("duelTimer", 1000, 0);
return 0;
}
And I call it like this in somewhere.
PHP Code:
SetTimer("duelTimer", 1000, 0);
But idk why, countdown isn't "5,4,3,2,1" but it goes like "-1,-1,-1,-1,-1"
How to fix this guys?