Forum Jump :

Author Message

Posts: 1589

Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 61
In-game name: Kobayashi Maru

#196165 Posted at 2017-02-06 03:29        
Wow! Not sure you tested your code before..

if (!isServer) exitWith {}; // no sense as in SP/hosted player is in server, in MP dedicated, there is no player on server.
if (!hasInterface) exitWith {}; // preferable, but be sure there will be no code for a dedi server (or HC) below this line.
sleep 1; // wath for?
waitUntil {!isNull (findDisplay 46)}; // preferable
(findDisplay 46) displaySetEventHandler ["KeyDown","_nil = _this execVM ""selectUnit.sqf"""]; // works also
titleText ["Press windows Left key once to activate script","plain down"];


if (!isServer) exitWith {}; // no sense
private _handled = false; // see below, added a line because this variable is worthy to avoid script repetition while maintaining the key down...
sleep 0.1; // what for?
switch (_this select 1) do // mono case? --> use if .. then..
// KEY windows Left 
case 219: 
markerIcon = "Sign_sphere100cm_EP1" createVehicle [0,0,0];
_handled = true; // missing line. Now your script returns true and script doesn't repeat if key stays down.
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!"; // a loop could be fine below.

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; // what for?
if (vehicle unit!= unit) exitwith {hintsilent "Selected unit cannot move while in vehicle!,call script again!";deletevehicle markerIcon;};

sleep 1; // what for?
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; // what for?
_marker attachTO [player,[0,3,1.3]];
sleep 5;
_marker setvelocity [0,0,0]; // useless.
detach _marker;
_marker setPosATL getPosATL player; // useless because the line below
_marker setposATL (player modelToWorld [0,3,0]); // So 3 meters in front of player?? Where is the cursor? I was waiting for something like an "onEachFramed" screenToWorld [0.5,0.5] 

sleep 0.1;
_selectedunit lookat _marker; // what for?
_selectedunit dowatch _marker; // useless if the line above
_selectedunit domove getposATL _marker;
_selectedunit setspeedmode "FULL";

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

exit; // useless