DukeVenator 0 Posted January 27, 2019 Hay all! Currently smashing my head against the wall trying to figure this out! So at the moment we are running advanced sling loading but what we want to do is make a script that when a vehicle is sling loaded and it is on a list to change the mass to a different value thats on the list. But Changes the value back to the default value upon detaching from the ropes? Struggling to make this a script. Share this post Link to post Share on other sites
Mr H. 402 Posted January 27, 2019 What you ask for will require that you detect when the rope is attached and when the rope is detached, the rest is easy but this part is quite tricky (use eventhandlers:https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#RopeAttach ) when attaching (in the eh) store the variable on the object yourobject addEventHandler ["RopeAttach", { params ["_object1", "_rope", "_object2"]; _object1 setVariable ["OrgMass",getMass _object1,true]; _object1 setMass YOURNEWMASS; }]; and when the rope is detached yourobject addEventHandler ["RopeBreak", { params ["_object1", "_rope", "_object2"]; _object1 setMass (_object1 getVariable "OrgMass"); }]; I suggest adding the EH to all vehicles at mission startup from script Now for the table of masses to keep I would declare them in a class in the mission description.ext Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted January 27, 2019 Something like this: TAG_fnc_handleSlingMass = { params ["_chopper"]; _chopper addEventHandler ["RopeAttach",{ params ["_chopper", "_rope", "_slingLoad"]; _massArray = [["B_Quadbike_01_F",50],["B_T_Boat_Transport_01_F",100]];//quadbike will have 50 mass, boat will have 100 during slingloaded state _vehClasses = _massArray apply {_x#0}; _vehMasses = _massArray apply {_x#1}; _index = _vehClasses find typeOf _slingLoad; _slingLoaded = _slingLoad getVariable ["TAG_fnc_slingLoaded",false];//this is needed because EH fires for every attached rope, so you prevent overwriting the actual mass with the replacement mass if (_index > -1 AND !_slingLoaded) then { _slingLoad setVariable ["TAG_fnc_slingLoaded",true]; _slingLoad setVariable ["TAG_fnc_oldMass",getMass _slingLoad]; _slingLoad setMass _vehMasses#_index; }; }]; _chopper addEventHandler ["RopeBreak",{ params ["_chopper", "_rope", "_slingLoad"]; _oldMass = _slingLoad getVariable ["TAG_fnc_oldMass",200];//200 will be used as a default value _slingLoad setMass _oldMass; }]; true }; _handleMass = [chopper] call TAG_fnc_handleSlingMass; //to test on quadbike named test: onEachFrame {hintSilent format ["Current Mass:%1\nStored Mass: %2",getMass test,test getVariable ["TAG_fnc_oldMass",-1]]}; Cheers 2 Share this post Link to post Share on other sites
DukeVenator 0 Posted January 27, 2019 1 hour ago, Grumpy Old Man said: Something like this: TAG_fnc_handleSlingMass = { params ["_chopper"]; _chopper addEventHandler ["RopeAttach",{ params ["_chopper", "_rope", "_slingLoad"]; _massArray = [["B_Quadbike_01_F",50],["B_T_Boat_Transport_01_F",100]];//quadbike will have 50 mass, boat will have 100 during slingloaded state _vehClasses = _massArray apply {_x#0}; _vehMasses = _massArray apply {_x#1}; _index = _vehClasses find typeOf _slingLoad; _slingLoaded = _slingLoad getVariable ["TAG_fnc_slingLoaded",false];//this is needed because EH fires for every attached rope, so you prevent overwriting the actual mass with the replacement mass if (_index > -1 AND !_slingLoaded) then { _slingLoad setVariable ["TAG_fnc_slingLoaded",true]; _slingLoad setVariable ["TAG_fnc_oldMass",getMass _slingLoad]; _slingLoad setMass _vehMasses#_index; }; }]; _chopper addEventHandler ["RopeBreak",{ params ["_chopper", "_rope", "_slingLoad"]; _oldMass = _slingLoad getVariable ["TAG_fnc_oldMass",200];//200 will be used as a default value _slingLoad setMass _oldMass; }]; true }; _handleMass = [chopper] call TAG_fnc_handleSlingMass; //to test on quadbike named test: onEachFrame {hintSilent format ["Current Mass:%1\nStored Mass: %2",getMass test,test getVariable ["TAG_fnc_oldMass",-1]]}; Cheers Edit: don't mind me having a derp moment Share this post Link to post Share on other sites
DukeVenator 0 Posted January 27, 2019 Okay script set to run when ever the server is called Now is there any way to have that array include types? Example If MBT then > Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted January 27, 2019 6 minutes ago, DukeVenator said: Okay script set to run when ever the server is called Now is there any way to have that array include types? Example If MBT then > Not sure what you mean, filtering by classNames is already in there. Cheers Share this post Link to post Share on other sites
DukeVenator 0 Posted January 27, 2019 Just now, Grumpy Old Man said: Not sure what you mean, filtering by classNames is already in there. Cheers Sigh missed that this is why I shouldn't be trying to code at 4am in the morning.... Thank you for your help! Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted January 27, 2019 19 minutes ago, DukeVenator said: Sigh missed that this is why I shouldn't be trying to code at 4am in the morning.... Thank you for your help! Daytime doesn't matter. Coffee does. Spoiler Spoiler Spoiler Cheers Share this post Link to post Share on other sites
DukeVenator 0 Posted January 27, 2019 I'll go get some more coffee then :) Share this post Link to post Share on other sites