I have been using a script provided by Shaanig03 that allows a player to spawn squadmates in the vehicle that they are in, it fills commander driver and gunner roles with AI squadmembers, it does not fill passenger seats, the problem i an having is some of the vehicles im using have 8 gunner seats to the script is spawning a full squad of ten. I am trying to figure out a way to limit the amount of sqaudmembers to 3 or 4 to help save some performance.
I have this so far, but it does not seem to be working. I am very new to Scripting
_maxSquadSize = 3;
checkSquadSize = {
private["_playerGroup"];
_playerGroup = group player;
_numUnits = count units _playerGroup;
while {_numUnits > _maxSquadSize} do {
_unitToRemove = units _playerGroup select (_numUnits - 1);
_unitToRemove leaveVehicle;
deleteVehicle _unitToRemove;
_numUnits = count units _playerGroup;
};
};