Forum Jump :

Author Message

Posts: 89

Level: Member

Country: in
In-game name:

#196164 Posted at 2017-02-06 02:25        
i have corrected the errors in previous post now the script is able to select single units with keypress.

To use this script press windows left key once and then a select any single unit by pressing any F2,F3...F12 within 5 seconds.Once "unit selected" hint appears a visual marker will appear and will be placed at any structure height/level near the player's position, the selected unit will then move to the visual markers position.This script allows units in group to move to any buildings floor levels or inside structures.You can also use classname "Sign_arrow_down_large_EP1" as markericon in selectunit.sqf.

create init.sqf,selectunit.sqf,setunitpos.sqf and place in mission folder-

sleep 1;
_display = findDisplay 46;
_display displaySetEventHandler ["KeyDown","_nil = _this execVM ""selectUnit.sqf"""];

titleText ["Press windows Left key once to activate script","plain down"];


_handled = false;

sleep 0.1;
switch (_this select 1) do
// KEY windows Left 
case 219: 
markerIcon = "Sign_sphere100cm_EP1" createVehicle [0,0,0];
_handled = true;
titleText ["Select any unit (F2,F3,F4..F12) once & point cursor towards position to move unit to position!","plain down"];

sleep 1;
hintsilent "select any single unit in 5 seconds!";

sleep 1;
hintsilent "select unit in 5";
sleep 1;
hintsilent "select unit in 4";
sleep 1;
hintsilent "select unit in 3";
sleep 1;
hintsilent "select unit in 2";
sleep 1;
hintsilent "select unit in 1";
sleep 1;

SquadUnits = groupSelectedUnits player;
unit = Squadunits select 0; 

sleep 1;//Exit script if selected AI is in vehicle.
if (vehicle unit!= unit) exitwith {hintsilent "Selected unit cannot move while in vehicle!,call script again!";deletevehicle markerIcon;};

sleep 1;//Exit script if no AI unit is selected.
if (isNil "unit") exitwith {hintsilent "No unit selected,call script again!";deletevehicle markerIcon;};

hintsilent "unit selected!";

moveai = [markerIcon,unit] execVM "setunitpos.sqf";
waituntil {scriptdone moveai};

hintsilent "Select other units!";

_marker = _this select 0;
_selectedunit = _this select 1;

sleep 1;
_marker attachTO [player,[0,3,1.3]];
sleep 5;
_marker setvelocity [0,0,0];
detach _marker;
_marker setPosATL getPosATL player;
_marker setposATL (player modelToWorld [0,3,0]);

sleep 0.1;//order AI to move to marker.
_selectedunit lookat _marker;
_selectedunit dowatch _marker;
_selectedunit domove getposATL _marker;
_selectedunit setspeedmode "FULL";

sleep 1;
waituntil {unitready _selectedunit};
_selectedunit lookat objnull;
_selectedunit dowatch objnull;
deletevehicle _marker;

This post was edited by warbird (2017-02-09 19:15, ago)