Jump to content
Sign in to follow this  
cityfamer

how to delete a specific AI from my squad?

Recommended Posts

For example, I have 5 AIs in my group and I want to delete the third AI from my group. How to wirte the script for that?

Share this post


Link to post
Share on other sites

In the mission editor writing

Remove = [group this] execVM "Remove_Unit.sqf";

in the init field of the group leader where you like to remove the 3. unit.

Remove_Unit.sqf

_group = _this select 0;

_unit = units _group select (count units _group - 3);

deleteVehicle _unit;

Edited by SNKMAN

Share this post


Link to post
Share on other sites

A little correction to the above:

Since SNKMAN wrote the script execution line like Remove = [group this] execVM "Remove_Unit.sqf"; you can change the first line of the script to _group = _this select 0;

That way the same script will work regardless of which group it is used on.

Also I think he did a little error with the selection of who to remove. If the group for example counts 4 units his script would remove the the #2 one (4 - 3 = 1. The list of units would look like [soldier1,soldier2,soldier3,soldier4]. solder2 would be the one at index=1 in that array, and not soldier3). :)

Edit:

A more elaborate version of the script could be:

Remove_Unit.sqf

_group = _this select 0;
_number = _this select 1;

if (_number > count units _group) exitWith {hint "Cannot remove unit. Number out of bounds."};

_unit = units _group select (_number - 1);

deleteVehicle _unit;

Run the above script with remove = [group this,X] execVM "Remove_Unit.sqf"; where X is the number of the unit want to remove.

Edited by Inkompetent

Share this post


Link to post
Share on other sites

Also you may want to do a check if (_number > count units _group) exitWith {}; to avoid trying to delete units that don't exist.

Share this post


Link to post
Share on other sites

Thank you so much SNKMAN, galzohar and Inkompetent. I searched the internet for a long time but without solution.

Share this post


Link to post
Share on other sites

Your welcome cityfamer.

The result of 3 minds is a pretty good solution. ;)

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  

×