BEAKSBY 11 Posted August 26, 2014 Hi All, After watching BangaBob's / H8er's video (BTW...thanks for the video tutorial!) on AttachTo and BIS_fnc_MP I deciced to use his approach for my script. I wanted to addAction to the object (in this case _gun1) instead of the player in the initPlayerLocal.sqf But I want _gun1 to have the addAction so any player in MP from either side, to access the addAction based on certain conditions. I thought the script below would ensure it works on the server so all players will see the addAction...but it's not working? StaticWeaponDrop.sqf ////////////////////////////////////////////////////////// // ...code that creates _gun1 with createVehicle...// ///////////////////////////////////////////////////////// if (isServer) then { [[_gun1],"BEAKS_addAction",true,true] call BIS_fnc_MP; }; BEAKS_addAction = { _gun1 = (_this select 0); _gun1 setVariable ["reinforce",true]; _gun1 addAction ["REINFORCE EMPLACEMENT",{call BEAKS_ReinforceStaticWeapon}, nil, 9, true, true, "","(_target getVariable ""reinforce"") && (_target distance _this ) < 5 && !(alive ((crew _target) select 0))"]; }; BEAKS_ReinforceStaticWeapont = { _gun1 = (_this select 0); _gun1 setVariable ["reinforce",false]; // addAction should not be available [_gun1] execVM "ReinforceStaticWeapon.sqf"; // _gun1 setVariable ["reinforce",true] inside ReinforceStaticWeapon.sqf to make the addAction available again }; Share this post Link to post Share on other sites
buliwyf 4 Posted August 26, 2014 Typo maybe? first: BEAKS_ReinforceStaticWeapon second: BEAKS_ReinforceStaticWeapont Share this post Link to post Share on other sites
bangabob 45 Posted August 27, 2014 _gun1 addAction ["REINFORCE EMPLACEMENT",{call BEAKS_ReinforceStaticWeapon}, nil, 9, true, TRUE, "","(_target getVariable ""reinforce"") && (_target distance _this ) < 5 && !(alive ((crew _target) select 0))"]; Im glad you found the video useful :D Try replacing your addaction arguments with this. Priority is Max 6 (Not 9). And you don't want 'hide-on-use' TRUE. So i have replaced that argument with FALSE. Give it a go. _gun1 addAction ["REINFORCE EMPLACEMENT",{call BEAKS_ReinforceStaticWeapon}, nil, 6, true, FALSE, "","(_target getVariable ""reinforce"") && (_target distance _this ) < 5 && !(alive ((crew _target) select 0))"]; Share this post Link to post Share on other sites
zodd 14 Posted August 27, 2014 You are declaring the functions after they are being called - try and move the function definitions to before the calling part eg BEAKS_addAction = { _gun1 = (_this select 0); _gun1 setVariable ["reinforce",true]; _gun1 addAction ["REINFORCE EMPLACEMENT",{call BEAKS_ReinforceStaticWeapon}, nil, 9, true, true, "","(_target getVariable ""reinforce"") && (_target distance _this ) < 5 && !(alive ((crew _target) select 0))"]; }; BEAKS_ReinforceStaticWeapont = { _gun1 = (_this select 0); _gun1 setVariable ["reinforce",false]; // addAction should not be available [_gun1] execVM "ReinforceStaticWeapon.sqf"; // _gun1 setVariable ["reinforce",true] inside ReinforceStaticWeapon.sqf to make the addAction available again }; if (isServer) then { [[_gun1],"BEAKS_addAction",true,true] call BIS_fnc_MP; }; The other thing you could do is precompile the functions in your init.sqf (or script package init file) eg: initBEAKS.sqf BEAKS_addAction = compile preprocessFileLineNumbers "AwesomeMod\Functions\GunAddAction.sqf"; BEAKS_ReinforceStaticWeapon = compile preprocessFileLineNumbers "AwesomeMod\Functions\GunReinforce.sqf"; AwesomeMod\Functions\GunAddAction.sqf _gun1 = (_this select 0); _gun1 setVariable ["reinforce",true]; _gun1 addAction ["REINFORCE EMPLACEMENT",{call BEAKS_ReinforceStaticWeapon}, nil, 9, true, true, "","(_target getVariable ""reinforce"") && (_target distance _this ) < 5 && !(alive ((crew _target) select 0))"]; AwesomeMod\Functions\GunReinforce.sqf _gun1 = (_this select 0); _gun1 setVariable ["reinforce",false]; // addAction should not be available [_gun1] execVM "ReinforceStaticWeapon.sqf"; // _gun1 setVariable ["reinforce",true] inside ReinforceStaticWeapon.sqf to make the addAction available again (also the typo as Buliwyf pointed out) Share this post Link to post Share on other sites
BEAKSBY 11 Posted August 27, 2014 Thanks Guys! With you advice, in the end I decided to add the addAction the player instead, as there will be only a few players in the MP game I'm creating (max 4 Vs 4) and shouldn't be to taxing on the system whereas there could be dozens of StaticWeapons with the addAction. I did use some techniques from your video however BangaBob/H8er. I have not fully tested it all out yet but here's what I used. in the initPlayerLocal.sqf player setVariable ["addAction", TRUE, TRUE]; player addAction ['<t size=''0.85''>REINFORCE EMPLACEMENT </t>' + '<t size=''0.85'' color=''#ff0000''>$25 </t>', {player setVariable ["addAction", FALSE, TRUE]; [cursorTarget] execVM "ReinforceStaticWeapon.sqf"}, nil, 6, true, true, "", "_allowAddAction = player getVariable ""addAction""; (cursortarget iskindof 'staticWeapon') && (cursortarget distance _this ) < 5 && !(alive gunner cursorTarget) && alive cursorTarget && _allowAddAction"]; and then in ReinforceStaticWeapon.sqf I've added at the end of the script sleep 5; player setVariable ["addAction", TRUE, TRUE]; // Cannot call addAction for REINFORCE EMPLACEMENT until this script is done Thanks for you help and keep up the good videos...BangaBob/H8er please continue to elaborate on all the details for scripting & editing in your videos (10-15 minutes is worth the watching if it's instructive!) Share this post Link to post Share on other sites
jinker 20 Posted August 27, 2014 I don't know if it will help, but when I use spawnObject with FNC_MP I have to refer to the object as (object1 select 0) since its returned as an array. Share this post Link to post Share on other sites