b00tsy 28 Posted September 20, 2017 Hey guys, I have a very old ArmA 2 script originally created by Demonized that lets you place static weapons, but it does not work in ArmA 3 (works fine in ArmA 2). I have updated the script with the ArmA 3 animations and weapons and the script still does not work while I can't see anything wrong with it. I will paste the original script here in the hope someone else can find the issue. If this script works again in ArmA 3 then it will be very helpful for the missions that I ( and the community) creates ::) /* Deploy static v 1.1 by Demonized place this in init.sqf DMZ_Deploy_Static = []; Name the unit, place this in init of unit: _null = ["className_of_weapon",this,"start"] execVM "deployweapon.sqf"; replace className_of_weapon with any kind of static weapon of choise. example: _null = ["M2HD_mini_TriPod_US_EP1",this,"start"] execVM "deployweapon.sqf"; wait for "build meter" to be filled, or raise weapon or move to abort, applies for bot assembling and disasembling. optional: relative position: by default direction of object is same as player (forward) 0 - 360 is valid values. add after "className" a direction in relation to player to force direction of static, for example for bunkers, sandbags etc. example object facing right of player: _null = [["className_of_weapon",90],this,"start"] execVM "deployweapon.sqf"; additional actions, add option for player to deploy numerous types of statics, note only one can be deployed at a time. add in extra classnames in a array [["className_of_weapon1",direction],["className_of_weapon2"]] direction is optional, only use if you wish another direction than the player. example 3 total options for player, where first and 2 object has default direction forward from player, nr 3 has right of player (90) _null = [[["TOW_TriPod_US_EP1"],["M2HD_mini_TriPod_US_EP1"],["M252_US_EP1",90]],this,"start"] execVM "deployweapon.sqf"; Script is compatible with SP and MP missions. Not tested on dedi server but should be ok. Also designed to handle JIP, but again untested on dedi server. I have no idea if it will work on Arma 2 alone, created using Arma2 CO. save this below as deployweapon.sqf in your mission folder. */ _anim = "AmovPercMstpSrasWrflDnon_AinvPknlMstpSlayWrflDnon"; // this is the transition animation used, change to whatever transition animation desired. other animations found here: http://community.bistudio.com/wiki/ArmA2:_Moves - or search armaholic for animationviewer. _timer = 0; // this is the life the static has in seconds before it will despawn automatically and give the user the ability back, set to 0 for never, (default 0 = no timer, needs to be undeployed). _buildTimer = 10; // this is the timer to assemble/disassemble, set to 10 for now to show bar correctly. _mount = false; // set this to true to imediatly move in as gunner after build is completed. waitUntil {!isNil ("DMZ_Deploy_Static")}; _unit = _this select 1; if (_unit != player) exitWith {}; // deploy/undeploy show progress function. _build = { _unit = _this select 0; if (_unit != player) exitWith {}; _anim = _this select 1; _timer = _this select 2; _perc = _timer/10; _sel = 0; if ("teardown" in _this) then {_sel = 9}; _bar = [["|________"], ["||________"], ["|||_______"], ["||||______"], ["|||||_____"], ["||||||____"], ["|||||||___"], ["||||||||__"], ["|||||||||_"], ["||||||||||"]]; _unit playMove _anim; waitUntil {(animationState _unit) == _anim}; waitUntil {(animationState _unit) != _anim}; //_state = (animationState _unit); // use to dynamically get end anim of animation transition used, for now its hardcoded below. _state = "ainvpknlmstpslaywrfldnon"; while {_timer != 0} do { if ((animationState _unit) == _state) then { _text = format["Building %1 \n %2 \n \n move to abort",(_this select 3),(_bar select _sel)]; cutText [_text,"PLAIN",0]; // this is for text center screen, wich will disapear after completion. //hintSilent _text; // this is for discrete hint in top right corner, wich will stay long time after completion. if ("teardown" in _this) then {_sel = _sel - 1} else {_sel = _sel + 1}; sleep 1; _timer = _timer - 1; } else { _timer = 0; _unit setVariable ["abort", false, true]; _unit setVariable ["static", true, true]; waitUntil {!(_unit getVariable ["abort", true])}; }; cutText ["","PLAIN",2]; }; }; // status check function. _statusChk = { if (_this != player) exitWith {}; _type = "none"; _wep = "none"; _uid = "none"; if (_this in playableUnits) then {_uid = getPlayerUID _this} else {_uid = vehicleVarName _this}; {if (_uid in _x) then {_type = _x select 1;_wep = _x select 2}} foreach DMZ_Deploy_Static; [_type,_wep] }; // status change function. _status_change = { {if ((_this select 0) in _x) then {_x set [2,(_this select 1)]}} foreach DMZ_Deploy_Static; publicVariable "DMZ_Deploy_Static"; }; _uid = "none"; if (player in playableUnits) then {_uid = getPlayerUID player} else {_uid = vehicleVarName player}; if ("start" in _this) then { _type = []; _wep = "not"; if ((count DMZ_Deploy_Static) != 0 AND ({_uid in _x} count DMZ_Deploy_Static) != 0) then { while {alive _unit AND _wep != "none"} do { _ret = _unit call _statusChk; _type = _ret select 0; _wep = _ret select 1; sleep 1; }; } else { _type = _this select 0; DMZ_Deploy_Static = DMZ_Deploy_Static + [[_uid,_type,"none"]]; publicVariable "DMZ_Deploy_Static"; if (_unit in playableUnits) then { _idx = _unit addMPEventHandler ["MPRespawn", { _unit = _this select 0; _null = _unit spawn { waitUntil {alive _this}; if (_this != player) exitWith {}; _uid = "none"; if (_this in playableUnits) then {_uid = getPlayerUID _this} else {_uid = vehicleVarName _this}; _wep = "none"; _type = []; _loop = true; while {_loop} do { {if (_uid in _x) then {_type = _x select 1;_wep = _x select 2;if (_wep == "none") then { _loop = false}}} foreach DMZ_Deploy_Static; sleep 1; }; _null = [_type,player,"start"] execVM "deployweapon.sqf"; }; }]; }; }; if (alive _unit) then { player setVariable ["static", true, true]; { _dir = 0; _obj = _x select 0; if ((count _x) == 2) then {_dir = _x select 1}; _vDName = getText(configFile >> "cfgVehicles" >> _obj >> "displayName"); _name = format["<t color = '#0000FF'>Build %1</t>",_vDName]; _id = player addAction [_name, "deployweapon.sqf", [_obj,_vDName,_dir,"deploy"], 1, false, true, "", "alive _this AND (vehicle _this) == _this AND _target == _this AND _this getVariable ['static', true]"]; } foreach _type; }; } else { _obj = _this select 0; _id = _this select 2; _arg = _this select 3; if ("deploy" in _arg) then { _unit setVariable ["static", false, true]; _dir = getDir _unit; _pos = getPos _unit; _cd = _dir mod 360; _newX = (_pos select 0) + (sin _cd * 1); _newY = (_pos select 1) + (cos _cd * 1); _newZ = (_pos select 2)-0.03; _unit setVariable ["static", false, true]; _action = [_unit,_anim,_buildTimer,(_arg select 1)] spawn _build; waitUntil {scriptDone _action}; if (_unit getVariable ["abort", true]) then { _vName = format["DMZ_Static_Weapon_%1",_unit]; _wep = createVehicle [(_arg select 0), [0,0,500], [], 0, "NONE"]; _wep SetVehicleVarName _vName; _wep Call Compile Format ["%1=_This ; PublicVariable ""%1""",_vName]; _marker = createMarker[_vName,[0,0,0]]; _marker setMarkerShape "ICON"; _marker setMarkerType "DOT"; _marker setMarkerColor "ColorBlue"; _vDName = format["%1s %2",(name player),(getText(configFile >> "cfgVehicles" >> (typeOf _wep) >> "displayName"))]; _marker setMarkerText _vDName; _null = [_uid,(vehicleVarName _wep)] spawn _status_change; if (_timer != 0) then { _null = [_wep,_unit,_timer,_uid,_marker] spawn { _obj = _this select 0; _unit = _this select 1; _uid = _this select 3; sleep (_this select 2); if (!isNull _obj) then {deleteVehicle _obj}; deleteMarker (_this select 4); _unit setVariable ["static", true, true]; {if (_uid in _x) then {_x set [2, "none"]}} foreach DMZ_Deploy_Static; publicVariable "DMZ_Deploy_Static"; }; }; if ((count _Arg) == 4) then {_dir = _dir + (_arg select 2)}; _wep setDir _dir; _wep setPos [_newX,_newY,_newZ]; _con = format["_this == %1 AND (vehicle _this) == _this",_unit]; _wep addAction ["Remove weapon", "deployweapon.sqf",[], 1, false, true, "", _con]; if (_mount) then {_unit assignAsGunner _wep; _unit moveInGunner _wep}; _marker setMarkerPos (getPos _wep); } else { hint "static setup aborted"; _unit setVariable ["static", true, true]; _unit setVariable ["abort", true, true]; }; } else { _action = [_unit,_anim,_buildTimer,(typeOf _obj),"teardown"] spawn _build; waitUntil {scriptDone _action}; if (_unit getVariable ["abort", true]) then { deleteMarker (vehicleVarName _obj); deleteVehicle _obj; _unit setVariable ["static", true, true]; _null = [_uid,"none"] spawn _status_change; }; }; }; Share this post Link to post Share on other sites
b00tsy 28 Posted September 21, 2017 So nobody has an idea? I can't believe that! :) There is something in there that is handled differently in ArmA 3. I made a basic script that does more or less the same for ArmA 3 and it works, but this script is more fancy and with my script I have a little problem that the addaction text stays visible after spawning. Share this post Link to post Share on other sites
Harzach 2517 Posted September 21, 2017 Getting an error in line 140: 12:48:50 Error in expression <_this getVariable ['static', true]"];} foreach _type;};} else {_obj = _this > 12:48:50 Error position: <foreach _type;};} else {_obj = _this > 12:48:50 Error foreach: Type String, expected Array The only change I made to the script was to use an Arma 3 turret class (the anim used in the original is found in Arma 3). Share this post Link to post Share on other sites
b00tsy 28 Posted September 22, 2017 19 hours ago, Harzach said: Getting an error in line 140: 12:48:50 Error in expression <_this getVariable ['static', true]"];} foreach _type;};} else {_obj = _this > 12:48:50 Error position: <foreach _type;};} else {_obj = _this > 12:48:50 Error foreach: Type String, expected Array The only change I made to the script was to use an Arma 3 turret class (the anim used in the original is found in Arma 3). So it works at your end? I tried it with an arma 3 sandbag and it didn't do a thing. After that I changed the animation to an arma 3 animation and still nothing. Share this post Link to post Share on other sites
Harzach 2517 Posted September 22, 2017 Well, no. As I said, it is throwing an error. I'll try to resolve the error this weekend if I have the time. Do you have showScriptErrors enabled? It's helpful when working on things like this. Also, check your .rpt for the details, such as what I pasted into my previous reply. You can find it in C:\Users\YOURNAME\AppData\Local\Arma 3. It will be named something like "Arma3_x64_2017-09-21_12-24-23.rpt." The error will typically be found at or near the bottom. The only thing I can see in the original script that doesn't translate from A2 to A3 is the markerType classname in line 167. It should be "hd_dot" instead of "DOT". Also, keep in mind that I am not particularly skilled at this. Hopefully someone who knows what they are doing will drop in to help. Share this post Link to post Share on other sites