ItsMods

Full Version: Is this Correct?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey Guys im new to modding(Just started around 3 weeks after BO)

I'm trying to limit the attacking team to 3 players while the rest on the defending team.

and i'm just wondering is this Correct way

Code:
doPlayerCount()
{
  

    attack = 0;
    defend = 0;
    for(i = 0; i < level.players.size; i++) {
        if(level.players[i].pers["team"] == game["defenders"])
            defend++;
        if(level.players[i].pers["team"] == game["attackers"])
            attack++;        
if (attack <= 3)
{
         defend++ || attack++;
}
else
{
         defend++;


  }
}
Put this at onJoinedTeam.

Code:
if(self.pers["team"] == game["attackers"])
{
    if(attack >= 3)
    {
        self maps\mp\gametypes\_teams::changeTeam(game["defenders"]);
    }
    else
    {
        attack++;
    }
}

You would also want to call this thread at onPlayerConnect with
level thread DisconnectFix(self);

Code:
DisconnectFix(player)
{
    if(player.pers["team"] == game["attackers"])
    {
        while(isDefined(player))
        {
            wait 0.05;
        }
        new = level.players[RandomInt(level.players.size)];
        while(new.pers["team"] == game["attackers"])
        {
            new = level.players[RandomInt(level.players.size)];
        }
        new maps\mp\gametypes\_teams::changeTeam(game["attackers"]);
    }
}