SoloZone 1 Posted February 3, 2015 Hi All, I am creating a MP sandbox. I have a SQF that creates 6 Land Towers. Which will be destroyed later once a trigger is satisfied. Below is how I set the towers Handle Damage to indestructible. It works, no issue there. for [{_x=1},{_x<=_z},{_x=_x+1}] do { _tower = createVehicle ["Land_Cargo_Tower_V1_F", getpos start, [], 0, "CAN_COLLIDE"]; _tower addEventHandler ["HandleDamage", {false}]; _tower SetVehicleVarName (towerarray select _y); _tower call compile format["%1 = _this ; PublicVariable ""%1""",towerarray select _y]; alltowers = alltowers + [_tower];publicvariable "alltowers"; _y=_y+1; sleep 1; }; Later in the game I have a player Addaction when they find an object, which allows them to remove the HandleDamage. Well it does that too...in another script tied to the addaction. _matchtower addEventHandler ["HandleDamage", {_this select 2}]; _matchtower setdamage .75; Here is where its getting fishy and doesn't work. The building is now @ .75, in the below section I hint the damage and its .75 until I shoot a rocket at the building. Once I hit the building it gets reset to 0 and becomes indestructible again????? while {alive _matchtower} do { _tdamage = getdammage _matchtower; FOCK_GHint = parseText format ["%1 Damage %2",_matchtower,_tdamage];publicVariable "FOCK_GHint";hint FOCK_GHint; sleep 1; }; some background, the first code, only Dedicated is creating the buildings, not sure if this matters.. by thought I'd add. Any help in my concept would be greatly appreciated. Share this post Link to post Share on other sites
jshock 513 Posted February 3, 2015 Ummm, use allowDamage instead of a HandleDamage EH? Share this post Link to post Share on other sites
SoloZone 1 Posted February 3, 2015 Thanks jshock, tried that and its still the same? I thought I did try that before.. Share this post Link to post Share on other sites
jshock 513 Posted February 3, 2015 So the following idea doesn't work?(psuedo): _tower allowDamage false; //some action _obj addAction ["Allow tower damage",{whateverTower allowDamage true; whateverTower setDamage 0.75;}]; Share this post Link to post Share on other sites
SoloZone 1 Posted February 4, 2015 exactly.. its the weirdest. The only difference is the addaction runs a script. This script determines the tower is nearest to the player and then does the allow damage true; setdamage 0.75 I know the script is kicking off cause the action will reduce the damage to .75 (I hint it to see) and I take a shot at it and it brings it back to 0 and won't allow damage. Share this post Link to post Share on other sites
killzone_kid 1329 Posted February 4, 2015 you have to cancel damage protection on the same PC you set it Share this post Link to post Share on other sites
SoloZone 1 Posted February 4, 2015 when I create the towers(6) and assigning allowdamage to false, im using if (!IsServer) exitWith {}; so I am assuming only the Server initiates it. When the player uses the action and it kicks off the script, it too is if (!IsServer) exitWith {}; so only the server would be executing the cancel damage... I have always struggled with this (ie Server vs dedicated vs local).. so bear with me. Share this post Link to post Share on other sites
killzone_kid 1329 Posted February 4, 2015 when I create the towers(6) and assigning allowdamage to false, im using if (!IsServer) exitWith {}; so I am assuming only the Server initiates it. When the player uses the action and it kicks off the script, it too is if (!IsServer) exitWith {}; so only the server would be executing the cancel damage...I have always struggled with this (ie Server vs dedicated vs local).. so bear with me. Your script needs to be running on the server for it to be executed on the server. Adding !isServer will not make your client script magically run on the server, it will run on the client until if (!IsServer) exitWith {}; then it will just exit. Share this post Link to post Share on other sites
jshock 513 Posted February 4, 2015 allowDamage is remotely executable, so you can use BIS_fnc_MP (to ensure it's ran on the server), so when you create your towers: fnc_allowDamage = { (_this select 0) allowDamage (_this select 1); }; [[_tower,false],"fnc_allowDamage",false,false,false] call BIS_fnc_MP; //in action code [[_tower,true],"fnc_allowDamage",false,false,false] call BIS_fnc_MP; _tower setDamage 0.75; Share this post Link to post Share on other sites
killzone_kid 1329 Posted February 4, 2015 allowDamage is remotely executable, so you can use BIS_fnc_MP (to ensure it's ran on the server), so when you create your towers: fnc_allowDamage = { (_this select 0) allowDamage (_this select 1); }; [[_tower,false],"fnc_allowDamage",false,false,false] call BIS_fnc_MP; //in action code [[_tower,true],"fnc_allowDamage",false,false,false] call BIS_fnc_MP; _tower setDamage 0.75; Why make function if allowDamage is already supported by remote exec config https://community.bistudio.com/wiki/CfgRemoteExecCommands [[whateverTower, false], "allowDamage", false] call BIS_fnc_MP; is enough. Share this post Link to post Share on other sites
jshock 513 Posted February 4, 2015 Why make function if allowDamage is already supported by remote exec config https://community.bistudio.com/wiki/CfgRemoteExecCommands [[whateverTower, false], "allowDamage", false] call BIS_fnc_MP; is enough. Ugh, I'm just out of it today, that's what I meant to do, but must have gotten sidetracked in my head while writing this out :p. Share this post Link to post Share on other sites
SoloZone 1 Posted February 5, 2015 Gents. thanks this is working. I understand that the action script is a local event, but adding the BIS_MP and only allowing Server to action the call does it. Wow. Learning everyday. Thanks again. Share this post Link to post Share on other sites
Larrow 2819 Posted February 5, 2015 To answer to your original code problem.. Later in the game I have a player Addaction when they find an object, which allows them to remove the HandleDamage. Well it does that too...in another script tied to the addaction._matchtower addEventHandler ["HandleDamage", {_this select 2}]; _matchtower setdamage .75; Here is where its getting fishy and doesn't work. The building is now @ .75, in the below section I hint the damage and its .75 until I shoot a rocket at the building. Once I hit the building it gets reset to 0 and becomes indestructible again????? You are not removing your HandleDamage EH but instead starting another. You need to use the EH ID passed back from the original to remove it. example.. { _tower = createVehicle [ "Land_Cargo_Tower_V1_F", getPosATL start, [], 0, "CAN_COLLIDE"]; _EHID = _tower addEventHandler [ "HandleDamage", { 0 } ]; _tower setVariable [ "EHID", _EHID, true ]; [ _tower, _x ] call BIS_fnc_objectVar; alltowers pushBack _tower; }forEach towerarray; publicVariable "alltowers"; //Switch off _EHID = _matchtower getVariable "EHID"; _matchtower removeEventHandler [ "HanldeDamage", _EHID ]; _matchtower setdamage .75; Share this post Link to post Share on other sites