new countdowntimer;
new count = 11;
if(!strcmp(cmdtext, "/start", true, 8))
{
if(isclanwarstarted == 0)
{
new string[128];
format(string, sizeof(string), "** Prepare yourself, a round is about to start!");
SendClientMessageToAll(COLOR_MESSAGE, string);
SetTimer("startcw", 5000, false);
isclanwarstarted = 1;
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerPlaySound(i, 1139, 0.0, 0.0, 0.0);
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "ERROR: A round is currently running active!");
PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
}
return 1;
}
forward startcw(i);
public startcw()
{
if(IsPlayerConnected(i))
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(gTeam[i] == TEAM_HOME || gTeam[i] == TEAM_AWAY)
{
count = 11;
countdowntimer = SetTimer("Countdown", 1000, true);
iDM[i] = 0;
First[i] = 0;
ResetPlayerWeapons(i);
SetPlayerInterior(i, 10);
GivePlayerWeapon(i, 31, 9999);
GivePlayerWeapon(i, 27, 9999);
GivePlayerWeapon(i, 24, 9999);
SetPlayerHealth(i, 100);
SetPlayerArmour(i, 100);
TogglePlayerControllable(i,0);
if(gTeam[i] == TEAM_HOME)
{
SetPlayerPos(i, -1131.9910,1057.6470,1346.4126);
SetPlayerFacingAngle(i, 270);
}
else if(gTeam[i] == TEAM_AWAY)
{
SetPlayerPos(i, -973.9210,1061.2968,1345.6729);
SetPlayerFacingAngle(i, 90);
}
}
}
}
}
forward Countdown();
public Countdown()
{
new str[128];
count--;
if(count < 1)
{
for(new i=0; i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i))
{
KillTimer(countdowntimer);
GameTextForPlayer(i,"~g~~h~GO!",1000,3);
PlayerPlaySound(i, 1057, 0, 0, 0);
TogglePlayerControllable(i, 1);
if(gTeam[i] == TEAM_HOME)
{
SendClientMessage(i, TEAM_HOME_COLOR, "** The round has been started, good luck!");
}
else if(gTeam[i] == TEAM_AWAY)
{
SendClientMessage(i, TEAM_AWAY_COLOR, "** The round has been started, good luck!");
}
}
}
return 1;
}
format(str, sizeof str, "~r~Round Begins in: ~h~~h~~h~%d", count);
for(new i=0; i<MAX_PLAYERS;++i)
{
GameTextForPlayer(i,str,1000,3);
PlayerPlaySound(i, 1056, 0, 0, 0);
}
return 1;
}
for(new i=0; i<MAX_PLAYERS; i++)
I don't understand when you say the timer is running in a loop, I see no timer running in a loop..
|
pawn Код:
|
forward countdown(amount);
public countdown(amount)
{
new l_2[2];
format(l_2, 2,"%i",amount);
if(amount > 0)
{
GameTextForAll(l_2, 1000, 5);
SetTimerEx("countdown",1000, false, "i", amount-1);
}
else GameTextForAll("Go Go Go !!!", 1000, 5);
}
//usage
countdown(99); // it gonna count til 0.
Check this code I explained the changes in comments.
|