Jump to content
Sign in to follow this  
roby7979

Balance Teams in MP TvT

Recommended Posts

Hi all,i m try to make balance teams in my mission...from Opfor and Blufor,there is some script for make it automatic? thank you

Share this post


Link to post
Share on other sites

Balance ai or player

Sent from my SM-G925T using Tapatalk

Share this post


Link to post
Share on other sites

I'm also needing this.I'll let you know if I find anything

Share this post


Link to post
Share on other sites

Ok I've found this 

discription.ext 

class Header
{
 gameType = COOP;            //DM, Team, Coop, ...
 minPlayers = 1;             //min # of players the mission supports
 maxPlayers = 10;            //Max # of players the mission supports
 playerCountMultipleOf = 1;
};

playerCountMultipleOf

The game server would set the maximum amount of players based on bandwidth and eventually this parameter. The default is 2, so it means the mission will try to balance the game to multiples of 2 (2 vs 2, 4 vs 4, etc.) and you did not end up with a team mission with 5 maximum players(2 vs 3 is unfair?). Coop type missions use 1, Team type missions use 2(default).

Share this post


Link to post
Share on other sites

I need some to confirm if this works as I had to edit due to it was only using EAST and WEST. I had to add the 

variable "_indyCount"

AutoBalance.sqf

 

private ["_bluforCount", "_opforCount", "_indyCount", "_friendlyCount", "_enemyCount"];

_bluforCount = 0;
_opforCount = 0;
_indyCount = 0;

{ 

  {

	if (((getPlayerUID _x) != "")) then {

		if (side player == west) then {
		
		_bluforCount = (_bluforCount + 1);

		} else {

		 _opforCount = (_opforCount + 2);

		} else {
		
		 _indyCount = (_indyCount + 2);
        
		};

	};

  } forEach units _x;

} forEach allGroups;





if ((playerSide == west)) then {

_friendlyCount = _bluforCount;
_enemyCount = _opforCount, _indyCount;

} else {

_friendlyCount = _opforCount;
_enemyCount = _bluforCount, _indyCount;

} else {
_friendlyCount = _indyCount;
_enemyCount = _bluforCount, _opforCount;
};




if (((_friendlyCount - _enemyCount) > 1)) then {

   sleep 10;

player enableSimulation false;
titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR TO OPFOR RATIO SHOULD BE 2/1, CHANGING TEAMS...", "BLACK FADED", 999];

sleep 10;

endMission "END6";

I'm worried this part will cause errors. 

if ((playerSide == west)) then {

_friendlyCount = _bluforCount;
_enemyCount = _opforCount, _indyCount;

} else {

_friendlyCount = _opforCount;
_enemyCount = _bluforCount, _indyCount;

} else {
_friendlyCount = _indyCount;
_enemyCount = _bluforCount, _opforCount;
};

if someone can help us would be great.

Share this post


Link to post
Share on other sites

Also where and what is the best the execVM this script? 

Share this post


Link to post
Share on other sites

You can't write if (..) then {..} else {...} else {...};  // too much else! no chance to visit the last one!

And _friendlyCount = _enemyCount = _opforCount, _indyCount; // has no sense!

 

There are some more efficient codes for your topic, but for a general case, I suggest you a faster code (exit on first true answer):

Call {

  if (something true here ) exitWith {some code};

  if (something else  true here ) exitWith {some other code};

  if (something else  true here ) exitWith {some other code};

  if (something else  true here ) exitWith {some other code};

 here code by defaut (optional);

};

 

But right now, what you need is :

west countSide allPlayers; East countSide allPlayers; .... or allUnits if some Ais....

 

then a loop to compare the result and make you code. No time to develop. See you later.

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, pierremgi said:

You can't write if (..) then {..} else {...} else {...};  // too much else! no chance to visit the last one!

And _friendlyCount = _enemyCount = _opforCount, _indyCount; // has no sense!

 

There are some more efficient codes for your topic, but for a general case, I suggest you a faster code (exit on first true answer):

Call {

  if (something true here ) exitWith {some code};

  if (something else  true here ) exitWith {some other code};

  if (something else  true here ) exitWith {some other code};

  if (something else  true here ) exitWith {some other code};

 here code by defaut (optional);

};

 

But right now, what you need is :

west countSide allPlayers; East countSide allPlayers; .... or allUnits if some Ais....

 

then a loop to compare the result and make you code. No time to develop. See you later.

Ok so just checking if something like this will work before I continue? 

private ["_bluforCount", "_opforCount", "_indyCount"];

_bluforCount = 0;
_opforCount = 0;
_indyCount = 0;

Call
{
    if (((getPlayerUID _x) != "") && (side _x == WEST)) exitWith 
    {
	
      _bluforCount = (_bluforCount + 1);
  
    } forEach units _x;
	
    if (((getPlayerUID _x) != "") && (side _x == EAST)) exitWith 
    {
  
     _opforCount = (_opforCount + 1);
	 
	} forEach units _x;
	
	if (((getPlayerUID _x) != "") && (side _x == resistance)) exitWith 
    {
  
     _indyCount = (_indyCount + 1);
	 
	} forEach units _x;
};

then if this is ok I want continue with like

if ((playerSide == west)) then {
   if (((_bluforCount - _opforCount) > 1)) then {

   sleep 10;

   player enableSimulation false;
   titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR TO OPFOR RATIO SHOULD BE 2/1, CHANGING TEAMS...", "BLACK FADED", 999];

   sleep 10;

   endMission "END6";
  };
};

I would end up doing that 2 times for each side so what way would be best? maybe after endMission 

} else { if (((_bluforCount - _indyCount) > 1)) then { code };};

and do this for each side? 

Share this post


Link to post
Share on other sites

like this ?

 

private ["_bluforCount", "_opforCount", "_indyCount"];

_bluforCount = 0;
_opforCount = 0;
_indyCount = 0;

Call
{
    if (((getPlayerUID _x) != "") && (side _x == WEST)) exitWith 
    {
	
      _bluforCount = (_bluforCount + 1);
  
    } forEach units _x;
	
    if (((getPlayerUID _x) != "") && (side _x == EAST)) exitWith 
    {
  
     _opforCount = (_opforCount + 1);
	 
	} forEach units _x;
	
	if (((getPlayerUID _x) != "") && (side _x == resistance)) exitWith 
    {
  
     _indyCount = (_indyCount + 1);
	 
	} forEach units _x;
};
  
  if ((playerSide == WEST)) then {
   if (((_bluforCount - _opforCount) > 1)) then {

   sleep 10;

   player enableSimulation false;
   titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR/OPFOR/INDY RATIO SHOULD BE 1/1/1, CHANGING TEAMS...", "BLACK FADED", 999];

   sleep 10;

   endMission "END6";

   } else { if (((_bluforCount - _indyCount) > 1)) then {
   
   sleep 10;

   player enableSimulation false;
   titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR/OPFOR/INDY SHOULD BE 1/1/1, CHANGING TEAMS...", "BLACK FADED", 999];

   sleep 10;

   endMission "END6";
  }; 
};
  
  if ((playerSide == EAST)) then {
   if (((_opforCount - _bluforCount) > 1)) then {

   sleep 10;

   player enableSimulation false;
   titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR/OPFOR/INDY RATIO SHOULD BE 1/1/1, CHANGING TEAMS...", "BLACK FADED", 999];

   sleep 10;

   endMission "END6";

   } else { if (((_opforCount - _indyCount) > 1)) then {
   
   sleep 10;

   player enableSimulation false;
   titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR/OPFOR/INDY RATIO SHOULD BE 1/1/1, CHANGING TEAMS...", "BLACK FADED", 999];

   sleep 10;

   endMission "END6";
  }; 
};  
  
  if ((playerSide == resistance)) then {
   if (((_indyCount - _bluforCount) > 1)) then {

   sleep 10;

   player enableSimulation false;
   titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR/OPFOR/INDY RATIO SHOULD BE 1/1/1, CHANGING TEAMS...", "BLACK FADED", 999];

   sleep 10;

   endMission "END6";

   } else { if (((_indyCount - _opforCount) > 1)) then {
   
   sleep 10;

   player enableSimulation false;
   titleText ["YOU ARE UNBALANCING TEAMS, BLUFOR/OPFOR/INDY RATIO SHOULD BE 1/1/1, CHANGING TEAMS...", "BLACK FADED", 999];

   sleep 10;

   endMission "END6";
  }; 
};  

 

Share this post


Link to post
Share on other sites

Frankly, take time to write your problem before writing code  :don8:

 

in initPlayerLocal.sqf :


 

if ( ( west countSide allPlayers > ( (east countSide allPlayers) max (resistance countSide allPlayers))+1) or ( east countSide allPlayers > ( (west countSide allPlayers) max (resistance countSide allPlayers))+1) or ( resistance countSide allPlayers > (( east countSide allPlayers) max (west countSide allPlayers))+1) ) then {

    player enableSimulation false;
   ["<t color='#ff0000' size = '.8'>Warning!<br />YOU ARE UNBALANCING TEAMS, BLUFOR/OPFOR/INDY RATIO SHOULD BE 1/1/1, CHANGE TEAMS...</t>",-1,-1,10,1,0] spawn BIS_fnc_dynamicText;
   uisleep 10;
   ["END6",false,10] call BIS_fnc_endMission;
};

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites

@pierremgi I like you following me around ! you teach me a lot mate ! 

 

Cheers

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×