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:
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];
};
}];