Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new countdowntimer;
- new count = 11;
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/start", true))
- {
- 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;
- }
- return 0; // filterscript
- }
- forward startcw(); // removed i since it's not needed in any way plus you cannot pass vars via SetTimer, only SetTimerEx
- public startcw()
- {
- // removed if(IsPlayerConnected(i)) it has to be inside the loop not here
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- // Look the following two lines are so important when you use for loops to loop through players
- if(!IsPlayerConnected(i) || IsPlayerNPC(i)) // if i is not connected or is a npc
- continue; // skip and won't execute the following codes (No need to execute them since i is not connected at all or is a npc)
- // here i is a connected player and not a npc so do your codes
- if(gTeam[i] == TEAM_HOME || gTeam[i] == TEAM_AWAY)
- {
- /*
- count = 11;
- countdowntimer = SetTimer("Countdown", 1000, true);
- //I took those ^ 2 lines out of here and added them outside the loop.
- // If you want to know why read Nero_3D's post
- */
- 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);
- }
- }
- }
- // Here they are
- count = 11;
- countdowntimer = SetTimer("Countdown", 1000, true);
- return 1;
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment