Forum Jump :

Author Message


Posts: 89
Rank:


Level: Member

Country: in
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-09-28 01:14        
     
Hello , this is a simple script to add/remove any friendly AI unit using addaction to player group or squad.In this script you can add or remove infantry units,vehicles & even helicopters to player group.This script is useful for missions in which one needs additional units under player command , to replace units lost in battle and also to use vehicles as transport or support.

In player's init place code-
selectAI = this addaction ["Open selectAI menu","selectAI.sqf"];

In mission folder place these sqf's named as below-

selectAI.sqf
_player = _this select 0;

hintSilent "AI selection menu opened!";
sleep 1;

hintSilent "Use cursor to select unit!";
sleep 1;

_player removeAction selectAI;
sleep 0.1;

hintSilent "";

sleep 1;
AddAI = _player addaction ["select any AI", "selection.sqf",1];
removeAI = _player addaction ["Remove any AI", "selection.sqf",2];
closeMenu = _player addaction ["Close select/remove menu", "selection.sqf",3];

exit;

selection.sqf
// Script to add/remove any type of AI units to player group.

_player = _this select 0;
_selectanyAI = _this select 3;

sleep 1;
switch (_selectanyAI) do
{
case 1: // Select AI units.
{
hintSilent "Use cursor to select unit!";

sleep 5;
_SelectUnit = cursorTarget;
if (!alive _SelectUnit) exitwith {hintsilent "unit cannot be selected!"};
if (isNull _SelectUnit) exitWith {hintSilent "unit not found!"};
if (!(side _SelectUnit == playerside)) exitwith {hintsilent "selected unit not of player side!"};

sleep 2;
hintSilent "";

sleep 1;
[_selectUnit] join _player;

sleep 0.1;
hintsilent "Selected unit joined player group!";

exit;

};
case 2://remove AI from group.
{
hintSilent "Use cursor to select unit to leave group!";

sleep 5;
_selectUnit = cursorTarget;
if (!alive _SelectUnit) exitwith {hintsilent "unit cannot be selected!"};
if (isNull _selectUnit) exitWith {hintSilent "unit not found!"};

sleep 2;
hintSilent "";

sleep 1;
[_selectUnit] join grpnull;

sleep 0.1;
hintsilent "Selected unit removed from player group!";

exit;

};
case 3: //remove addaction from player.
{
_player removeaction AddAI;
_player removeaction removeAI;
_player removeaction closeMenu;

sleep 0.1;
selectAI = _player addaction ["Open select menu","selectAI.sqf"];
hint "selection menu closed!";
};
};

Using scroll menu open selectAI menu and select using addaction options as described below-
"Select any AI" - Use cursor to point at unit u want to select to add to player group/squad.
"Remove any AI" - Use cursor to point at unit u want to remove from player group/squad.
"Close select/remove menu" - This closes addaction menu.

NOTE - The selected unit should be of player side (BLUFOR or OPFOR) only.

This post was edited by warbird (2016-09-28 23:16, ago)