I need help with a command, to teleport 5 players
#1

I am making an arena in which the command is / arena and is as follows:

one player makes the command and is waiting, and when a player 5 makes this command, all five will be teleported to the arena. But something is wrong and only the 5th player is teleported

The code

pawn Код:
if(strcmp(cmd, "/arena", true) == 0) {
   if (gPublicEnemy == playerid){
   SendClientMessage(playerid, COLOR_GRAD1, " ");
   return 1;
   }
   new interior = PlayerInfo[playerid][pInt];
   new location = PlayerInfo[playerid][pLocal];
   if(location < 255)
   {
   //SendClientMessage(playerid, COLOR_RED,"");
   return 1;
   }
   if(interior == 6)//Interior(6) Jail
   {
   SendClientMessage(playerid, COLOR_RED," You are in jail");
   return 1;
   }
   if(vfightpl[playerid] == 1)
   {
   SendClientMessage(playerid, COLOR_RED," You are in stand by");
   return 1;
   }
   if(vfight == 0)
   {
   vfight = 1;
   vfightpl[playerid] = 1;
   antiheal[playerid]=1;
   return 1;
   }
   if(vfight == 1)
   {
   vfight = 2;
   vfightpl[playerid] = 2;
   return 1;
   }
   if(vfight == 2)
   {
   vfight = 3;
   vfightpl[playerid] = 3;
   return 1;
   }
   if(vfight == 3)
   {
   vfight = 4;
   vfightpl[playerid] = 4;
   return 1;
   }
   if(vfight == 4)
   {
   vfight = 5;
   vfightpl[playerid] = 5;
   
   for(new i = 0; i < MAX_PLAYERS; i++)
            {
            if(IsPlayerConnected(i))
            {
            if(vfightpl[i] == 1)
            {
            SetPlayerPos(playerid,55.7527,2602.4304,16.4844);
            SetPlayerFacingAngle(playerid,200.1634);
            GivePlayerWeapon(playerid, 4, 1);
            GivePlayerWeapon(playerid, 27, 1000000);
            GivePlayerWeapon(playerid, 29, 1000000);
            GivePlayerWeapon(playerid, 30, 1000000);
            GivePlayerWeapon(playerid, 34, 1000000);
            GivePlayerWeapon(playerid, 24, 1000000);
            }
           
            if(vfightpl[i] == 2)
            {
            SetPlayerPos(playerid,159.5226,2446.6265,16.4725);
            SetPlayerFacingAngle(playerid,354.4381);
            GivePlayerWeapon(playerid, 4, 1);
            GivePlayerWeapon(playerid, 27, 1000000);
            GivePlayerWeapon(playerid, 29, 1000000);
            GivePlayerWeapon(playerid, 30, 1000000);
            GivePlayerWeapon(playerid, 34, 1000000);
            GivePlayerWeapon(playerid, 24, 1000000);
            }
           
            if(vfightpl[i] == 3)
            {
            SetPlayerPos(playerid,359.5411,2542.7529,16.6590);
            SetPlayerFacingAngle(playerid,156.3893);
            GivePlayerWeapon(playerid, 4, 1);
            GivePlayerWeapon(playerid, 27, 1000000);
            GivePlayerWeapon(playerid, 29, 1000000);
            GivePlayerWeapon(playerid, 30, 1000000);
            GivePlayerWeapon(playerid, 34, 1000000);
            GivePlayerWeapon(playerid, 24, 1000000);
            }
           
            if(vfightpl[i] == 4)
            {
            SetPlayerPos(playerid,470.8924,2467.8413,24.9349);
            SetPlayerFacingAngle(playerid,55.1191);
            GivePlayerWeapon(playerid, 4, 1);
            GivePlayerWeapon(playerid, 27, 1000000);
            GivePlayerWeapon(playerid, 29, 1000000);
            GivePlayerWeapon(playerid, 30, 1000000);
            GivePlayerWeapon(playerid, 34, 1000000);
            GivePlayerWeapon(playerid, 24, 1000000);
            }
           
            if(vfightpl[i] == 5)
            {
            SetPlayerPos(playerid,406.0203,2448.7781,16.5000);
            SetPlayerFacingAngle(playerid,2.7700);
            GivePlayerWeapon(playerid, 4, 1);
            GivePlayerWeapon(playerid, 27, 1000000);
            GivePlayerWeapon(playerid, 29, 1000000);
            GivePlayerWeapon(playerid, 30, 1000000);
            GivePlayerWeapon(playerid, 34, 1000000);
            GivePlayerWeapon(playerid, 24, 1000000);
            }
           
            }
            }
           
           

   return 1;
   }
   return 1;
}
I have more things but i think the error is there
Reply
#2

Replace all of the "playerids" under the loop with "i"
Reply
#3

replace by "i"?
Reply
#4

Yea, he just said replace by "i" so of course...
Reply
#5

lol, my english sucks :P
Reply
#6

Jonybomb, Grim_ is saying to Create the variable line, MAX_PLAYERS = i.

let me explain, MAX_PLAYERS Pulls every playerid in your server. When you make MAX_PLAYERS equal to i, i becomes max players, and it pulls every player to that one variable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)