<<FIXED IT!>>
Hello! So I just started to try out some scripting in Arma 3, and it's been fun so far. But I have stumbled upon a little issue that I can't get by.
To test, I'm running two versions of Arma 3 on my PC, where one of them is hosting a local server. When I enable Dead Man's Switch (further abbreviated as 'DMS') on the host player game, it removes both of the actions as it should, but when I enable DMS on the player that is connected to the local server, it only removes the DMS action, and not my "blow up" action. I also added debug hints in the init.sqf file, but the connected local client didn't see those hints, only the host player.
In the end, I will use this on my dedicated server.
I have other classes too, but I reckon those won't be necessary.
Dead Man's Switch Class:
//the suicide bomber
_bomber = _this select 0;
if((_bomber getVariable "is_dead_man") == "false") then {
_bomber setVariable["is_dead_man", "true"];
//Check if player dies
//[player] execVM "scripts\suicide_bomber\explode.sqf";
//[[[player], "scripts\suicide_bomber\explode.sqf"], "BIS_fnc_execVM", false, true] call BIS_fnc_MP;
_bomber addEventHandler ["Killed", {
_pl = _this select 0;
_pl execVM "scripts\suicide_bomber\allahu_akbar.sqf";
}];
//Remove Dead Man's Switch
_id = _bomber getVariable "DeadMansSwitch";
_bomber removeAction (_id);
_id2 = _bomber getVariable "AllahuAkbar";
_bomber removeAction (_id2);
hint "Dead Man's Switch has been enabled!";
sleep 4;
hint "";
}
Explode Class:
//if (!hasInterface || isServer) exitWith {};
//the suicide _bomber
_bomber = _this select 0; //player;
if ((!isServer) && (_bomber != player)) then
{
waitUntil {_bomber == player};
};
explodeFunc = {
_ammoType = "Bo_GBU12_LGB_MI10";
_bombLoc = GetPos _bomber;
_bombLocX = _bombLoc select 0;
_bombLocY = _bombLoc select 1;
_bombLocZ = _bombLoc select 2;
//suicide action
_ammoType createVehicle[_bombLocX, _bombLocY, _bombLocZ];
_bomber setdammage 1;
};
explode = {
_bomber say "allahu"; //playSound "allahu";
sleep 1.7;
call explodeFunc;
};
immediate_explode = {
call explodeFunc;
};
if("SatchelCharge_Remote_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "ATMine_Range_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "APERSMine_Range_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "APERSBoundingMine_Range_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "SLAMDirectionalMine_Wire_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "APERSTripMine_Wire_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "ClaymoreDirectionalMine_Remote_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "DemoCharge_Remote_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "IEDUrbanBig_Remote_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "IEDLandBig_Remote_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "IEDUrbanSmall_Remote_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "IEDLandSmall_Remote_Mag" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "HandGrenade" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "MiniGrenade" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber) || "HandGrenade_Stone" in (items _bomber + assignedItems _bomber + backpackitems _bomber + vestItems _bomber)) then {
if((_bomber getVariable "is_dead_man") == "true") then {
call immediate_explode;
//Remove EventHandler from player
_bomber removeEventHandler["Killed", 0];
_bomber setVariable["is_dead_man", "false"];
_bomber setVariable["DeadMansSwitch", _bomber addAction["<t color='#FF0000'>Dead Man's Switch</t>", "scripts\suicide_bomber\dead_mans_switch_exec.sqf"]];
}
else {
call explode;
}
}
else {
hint "You don't have any explosives on you!";
_bomber addItem "DemoCharge_Remote_Mag";
sleep 4;
hint "";
}