Dominicus1165 0 Posted August 9, 2021 This is on a multiplayer server. It must work there. I want to breach a door via Slug Ammo. I placed a wooden plank the size of the door in front of it. After two hits the plank gets destroyed and the door opens. I want to use this script multiple times during my mission. Therefore, I don't want n variables counterPlank0 - counterPlankN I want to save the counter locally. Called in init of plank: [this] execVM "scripts\eh_slugBreach.sqf" File: Working with global variable: Spoiler params ["_object"]; counterPlank = 0; _object addMPEventHandler ["MPHit", { params ["_unit", "_causedBy", "_damage", "_instigator"]; if (currentMagazine _instigator isEqualTo "rhsusf_5Rnd_Slug") then { counterPlank = counterPlank + 1; }; if (counterPlank > 1) then { deleteVehicle _unit; myBuilding animateSource ["Door_1_sound_source", 1]; }; }]; Not working with setVariable: params ["_object"]; _counterplank = 0; _object setVariable ["counterPlank", _counterPlank]; DIFFERENCE _object addMPEventHandler ["MPHit", { params ["_unit", "_causedBy", "_damage", "_instigator"]; if (currentMagazine _instigator isEqualTo "rhsusf_5Rnd_Slug") then { _unit setVariable ["counterPlank", _counterPlank + 1]; DIFFERENCE }; if (_unit getVariable "counterPlank" > 1) then { DIFFERENCE deleteVehicle _unit; myBuilding animateSource ["Door_1_sound_source", 1]; }; }]; Share this post Link to post Share on other sites
pierremgi 4739 Posted August 10, 2021 First of all, welcome on forum. params ["_object"]; _object setVariable ["counterPlank", 0]; _object addMPEventHandler ["MPHit", { params ["_unit", "_causedBy", "_damage", "_instigator"]; if (currentMagazine _instigator isEqualTo "rhsusf_5Rnd_Slug") then { _unit setVariable ["counterPlank", (_unit getVariable ["counterPlank,0]) + 1]; if (_unit getVariable ["counterPlank",0] > 1) then { deleteVehicle _unit; myBuilding animateSource ["Door_1_sound_source", 1,TRUE]; }; }; }]; 1 1 Share this post Link to post Share on other sites
Dominicus1165 0 Posted August 10, 2021 Thank you :D I just should‘ve slept. That was quite obvious. Share this post Link to post Share on other sites