Guest User

Untitled

a guest
Jul 21st, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.28 KB | None | 0 0
  1. new countdowntimer;
  2. new count = 11;
  3.  
  4. public OnPlayerCommandText(playerid, cmdtext[])
  5. {
  6.     if(!strcmp(cmdtext, "/start", true))
  7.     {
  8.         if(isclanwarstarted == 0)
  9.         {
  10.             new string[128];
  11.             format(string, sizeof(string), "** Prepare yourself, a round is about to start!");
  12.             SendClientMessageToAll(COLOR_MESSAGE, string);
  13.             SetTimer("startcw", 5000, false);
  14.             isclanwarstarted = 1;
  15.             for(new i = 0; i < MAX_PLAYERS; i++)
  16.             {
  17.                 PlayerPlaySound(i, 1139, 0.0, 0.0, 0.0);
  18.             }
  19.         }
  20.         else
  21.         {
  22.             SendClientMessage(playerid, COLOR_ERROR, "ERROR: A round is currently running active!");
  23.             PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
  24.         }
  25.         return 1;
  26.     }
  27.     return 0; // filterscript
  28. }
  29.    
  30.    
  31.    
  32.  
  33. forward startcw(); // removed i since it's not needed in any way plus you cannot pass vars via SetTimer, only SetTimerEx
  34. public startcw()
  35. {
  36.     // removed if(IsPlayerConnected(i)) it has to be inside the loop not here
  37.     for(new i=0; i<MAX_PLAYERS; i++)
  38.     {
  39.         // Look the following two lines are so important when you use for loops to loop through players
  40.         if(!IsPlayerConnected(i) || IsPlayerNPC(i)) // if i is not connected or is a npc
  41.             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)
  42.  
  43.         // here i is a connected player and not a npc so do your codes
  44.         if(gTeam[i] == TEAM_HOME || gTeam[i] == TEAM_AWAY)
  45.         {
  46.             /*
  47.             count = 11;
  48.             countdowntimer = SetTimer("Countdown", 1000, true);
  49.  
  50.             //I took those ^ 2 lines out of here and added them outside the loop.
  51.             // If you want to know why read Nero_3D's post
  52.            
  53.             */
  54.             iDM[i] = 0;
  55.             First[i] = 0;
  56.             ResetPlayerWeapons(i);
  57.             SetPlayerInterior(i, 10);
  58.             GivePlayerWeapon(i, 31, 9999);
  59.             GivePlayerWeapon(i, 27, 9999);
  60.             GivePlayerWeapon(i, 24, 9999);
  61.             SetPlayerHealth(i, 100);
  62.             SetPlayerArmour(i, 100);
  63.             TogglePlayerControllable(i,0);
  64.  
  65.             if(gTeam[i] == TEAM_HOME)
  66.             {
  67.                 SetPlayerPos(i, -1131.9910,1057.6470,1346.4126);
  68.                 SetPlayerFacingAngle(i, 270);
  69.             }
  70.             else if(gTeam[i] == TEAM_AWAY)
  71.             {
  72.                 SetPlayerPos(i, -973.9210,1061.2968,1345.6729);
  73.                 SetPlayerFacingAngle(i, 90);
  74.             }
  75.         }
  76.     }
  77.     // Here they are
  78.     count = 11;
  79.     countdowntimer = SetTimer("Countdown", 1000, true);
  80.     return 1;
  81. }
  82.  
  83. forward Countdown();
  84. public Countdown()
  85. {
  86.     new str[128];
  87.     count--;
  88.     if(count < 1)
  89.     {
  90.         for(new i=0; i<MAX_PLAYERS;++i)
  91.         {
  92.             if(IsPlayerConnected(i))
  93.             {
  94.                 KillTimer(countdowntimer);
  95.                 GameTextForPlayer(i,"~g~~h~GO!",1000,3);
  96.                 PlayerPlaySound(i, 1057, 0, 0, 0);
  97.                 TogglePlayerControllable(i, 1);
  98.                 if(gTeam[i] == TEAM_HOME)
  99.                 {
  100.                     SendClientMessage(i, TEAM_HOME_COLOR, "** The round has been started, good luck!");
  101.                 }
  102.                 else if(gTeam[i] == TEAM_AWAY)
  103.                 {
  104.                     SendClientMessage(i, TEAM_AWAY_COLOR, "** The round has been started, good luck!");
  105.                 }
  106.             }
  107.         }
  108.         return 1;
  109.     }
  110.     format(str, sizeof str, "~r~Round Begins in: ~h~~h~~h~%d", count);
  111.     for(new i=0; i<MAX_PLAYERS;++i)
  112.     {
  113.         GameTextForPlayer(i,str,1000,3);
  114.         PlayerPlaySound(i, 1056, 0, 0, 0);
  115.     }
  116.     return 1;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment