Jump to content
Ulmann

Dependence of the number of players to AI

Recommended Posts

Hello!

Really sorry If offtop, but I have a question.

Now I make my own cooperative mission and wanna delete/add squads according players, so, there is two sub-question:
1) How I can check players count?
2) How I can delete already installed on map squads of AI?

Thanks!

Share this post


Link to post
Share on other sites

a method i like to use is not to delete entire groups, but to trim them, so perhaps they have 5-6 units instead of 8.

 

https://community.bistudio.com/wiki/allPlayers

 

heres an example:

 

default number of units

E1964E0A530273628890EFFF611920ED4F933226

 

trimmed number of units

 

9261A9159F49DF1ABA3850CB263ED3B787060F3F

 

and a block of code to achieve something like that could look like this:

 

// init.sqf
if (isServer) then {
	_maxplayers = 10;
	_playerCount = count allPlayers;
	_multiplier = _playerCount / _maxplayers;	// example:   _multiplier = 4 / 10;
	private _grp = grpnull;
	private _grpcount = -1;
	private _newcount = -1;
	{
		if ((side _x) in [EAST]) then {
			_grp = _x;
			_grpcount = count (units _grp);
			_newcount = round (_grpcount * _multiplier);
			while {((count (units _grp)) > _newcount)} do {
				deleteVehicle ((units _grp) select ((count (units _grp)) - 1));
			};
		};
	} forEach allGroups;
};

 

 

  • Thanks 2

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

×