davidoss 552 Posted December 11, 2015 Hi. Could someone please say me why this is not working anymore after last update? description.ext class CfgFunctions { class INS { class ck { class ckMP { preInit = 0; postInit = 0; preStart = 0; recompile = 0; ext = ".sqf"; headerType = -1; }; class ckcivEH { preInit = 0; postInit = 0; preStart = 0; recompile = 0; ext = ".sqf"; headerType = -1; }; }; }; }; class Extended_Init_EventHandlers { class Civilian_F { class Man { init = "(_this select 0) call INS_fnc_ckcivEH"; }; }; }; INS_fnc_ckcivEH // INS_fnc_ckcivEH if (!hasInterface || isServer) then { //hint format ["KEH added to %1", typeof _this]; _this addEventHandler ["killed", { private ["_cvictim", "_ckiller"]; _cvictim = _this select 0; _ckiller = _this select 1; if(vehicle _ckiller isEqualTo vehicle _cvictim ) exitWith{}; if (isPlayer _ckiller) then { //hint format ["You havd just killed %1", typeof _cvictim]; [] remoteExec [ "INS_fnc_ckMP", _ckiller ]; }; }]; }; INS_fnc_ckMP //civilian casualties punishment INS_fnc_ckMP if (!hasInterface) exitWith {}; private ["_txt", "_output", "_declare"]; [profileName + " has killed civilian!", "systemChat"] call BIS_fnc_MP; sleep 2; [[hq_logic_papa,"papabear_dammit"],"sideRadio",WEST,false,false] call BIS_fnc_MP; sleep 2; if !(vehicle player == player) exitWith {}; if (alive player AND !(player getVariable ["ACE_isUnconscious", false])) then { player setCaptive true; disableUserInput true; sleep 2; titleCut ["", "BLACK FADED", 999]; sleep 3; playSound "WoundedGuyA_03"; titleText ["YOU HAVE KILLED A CIVILIAN!!","PLAIN"]; titleFadeOut 5; sleep 5; playSound "WoundedGuyA_04"; titleText ["HOW COULD YOU?!","PLAIN"]; titleFadeOut 5; sleep 5; playSound "WoundedGuyA_05"; _txt = "You are experiencing extreme stress caused by killing unarmed civilian!!"; _output = [ [_txt,"<t size='1.2' font='PuristaBold'>%1</t>",15] ]; _declare = [_output,0,0.5,"<t color='#FFFFFFFF' align='center'>%1</t>"] spawn BIS_fnc_typeText; waitUntil {scriptDone _declare}; "dynamicBlur" ppEffectEnable true; "dynamicBlur" ppEffectAdjust [6]; "dynamicBlur" ppEffectCommit 0; "dynamicBlur" ppEffectAdjust [0.0]; "dynamicBlur" ppEffectCommit 5; titleCut ["", "BLACK IN", 5]; sleep 4; playSound "WoundedGuyA_06"; player switchMove "Acts_UnconsciousStandUp_part2"; waituntil { sleep 0.5; animationState player != "Acts_UnconsciousStandUp_part2"}; titleCut ["", "BLACK FADED", 999]; playSound3D ["A3\Sounds_F\arsenal\weapons\Pistols\4-Five\4-Five_01.wss", player, false, position player, 8, 1, 0]; sleep 1; player setdamage 0.9; player setCaptive false; disableUserInput false; "dynamicBlur" ppEffectEnable true; "dynamicBlur" ppEffectAdjust [6]; "dynamicBlur" ppEffectCommit 0; "dynamicBlur" ppEffectAdjust [0.0]; "dynamicBlur" ppEffectCommit 5; titleCut ["", "BLACK IN", 5]; player setdamage 1; }; I have added hints to INS_fnc_ckcivEH for debug if the event handler are even being added to civilians. It is. But for some reason after player kill civ unit or more he get only a message : You havd just killed "classname" The function INS_fnc_ckMP seams to be no more executed on player. Why? Share this post Link to post Share on other sites
davidoss 552 Posted December 12, 2015 Ok. I have figured out that the condition is not working in INS_fnc_ckcivEH if (isPlayer _ckiller) then {}; If i put the debug hint inside then {}; hint isn't show up. how this is possible? Are the isPlayer check not working in event handler environment? Share this post Link to post Share on other sites
davidoss 552 Posted December 18, 2015 Hi. Could someone help me on this please? Basically i want to execute a function INS_fnc_ckMP on the player which has killed civilian. Share this post Link to post Share on other sites
killzone_kid 1333 Posted December 18, 2015 you dont need remoteExec for that, you can add MPKilled EH and limit it to killer PC _this addMPEventHandler ["MPKilled", { params ["_cvictim", "_ckiller"]; if (player isEqualTo _cKiller) then { if (vehicle _ckiller isEqualTo vehicle _cvictim) exitWith {}; // code here will run on killer's PC }; }]; Share this post Link to post Share on other sites
davidoss 552 Posted December 20, 2015 Unfortunately still not working. EH is added to the units but the code inside is not executed for some reason. Share this post Link to post Share on other sites
donelsarjo 60 Posted December 20, 2015 well the problem might be that you are running sleep in unschedualed environment. try to spawn it. Share this post Link to post Share on other sites
davidoss 552 Posted December 20, 2015 I do not see sleep in INS_fnc_ckcivEH If i put a editor guy and in his init i put killzone_kid code all works well. If EH was added by script or by extended event handler the function is executed but: 1. Event handler is being not added 2. Event handler is immediately removed 3. Event handler is not working ( the code inside are not executed) Please help Share this post Link to post Share on other sites
davidoss 552 Posted December 20, 2015 Is there are any possibility to debug event handlers to define whats wrong? Civilians are spawning from BangaBob's civilian occupation system There are file addScript_Unit.sqf where is executed by any civilian unit spawned. In that file i add: /* Add Script to individual units spawned by COS. _unit = unit. Refer to Unit as _unit. */ [_this select 0] call INS_fnc_ckcivEH; description.ext class CfgFunctions { class INS { class ck { class ckMP { preInit = 0; postInit = 0; preStart = 0; recompile = 0; ext = ".sqf"; headerType = -1; }; class ckcivEH { preInit = 0; postInit = 0; preStart = 0; recompile = 0; ext = ".sqf"; headerType = -1; }; }; }; }; INS_fnc_ckcivEH private "_unit"; _unit = _this select 0; //hint format ["KEH added to %1", typeof _unit]; //hint to knew if the code is even executed _unit addMPEventHandler ["MPKilled", { params ["_cvictim", "_ckiller"]; if (player isEqualTo _cKiller) then { if (vehicle _ckiller isEqualTo vehicle _cvictim) exitWith {}; [] spawn INS_fnc_ckMP; }; }]; INS_fnc_ckMP //civilian casualties punishment INS_fnc_ckMP if (!hasInterface) exitWith {}; private ["_txt", "_output", "_declare"]; [profileName + " has killed civilian!", "systemChat"] call BIS_fnc_MP; sleep 2; [[hq_logic_papa,"papabear_dammit"],"sideRadio",WEST,false,false] call BIS_fnc_MP; sleep 2; if !(vehicle player == player) exitWith {}; if (alive player AND !(player getVariable ["ACE_isUnconscious", false])) then { player setCaptive true; disableUserInput true; sleep 2; titleCut ["", "BLACK FADED", 999]; sleep 3; playSound "WoundedGuyA_03"; titleText ["YOU HAVE KILLED A CIVILIAN!!","PLAIN"]; titleFadeOut 5; sleep 5; playSound "WoundedGuyA_04"; titleText ["HOW COULD YOU?!","PLAIN"]; titleFadeOut 5; sleep 5; playSound "WoundedGuyA_05"; _txt = "You are experiencing extreme stress caused by killing unarmed civilian!!"; _output = [ [_txt,"<t size='1.2' font='PuristaBold'>%1</t>",15] ]; _declare = [_output,0,0.5,"<t color='#FFFFFFFF' align='center'>%1</t>"] spawn BIS_fnc_typeText; waitUntil {scriptDone _declare}; "dynamicBlur" ppEffectEnable true; "dynamicBlur" ppEffectAdjust [6]; "dynamicBlur" ppEffectCommit 0; "dynamicBlur" ppEffectAdjust [0.0]; "dynamicBlur" ppEffectCommit 5; titleCut ["", "BLACK IN", 5]; sleep 4; playSound "WoundedGuyA_06"; player switchMove "Acts_UnconsciousStandUp_part2"; waituntil { sleep 0.5; animationState player != "Acts_UnconsciousStandUp_part2"}; titleCut ["", "BLACK FADED", 999]; playSound3D ["A3\Sounds_F\arsenal\weapons\Pistols\4-Five\4-Five_01.wss", player, false, position player, 8, 1, 0]; sleep 1; player setdamage 0.9; player setCaptive false; disableUserInput false; "dynamicBlur" ppEffectEnable true; "dynamicBlur" ppEffectAdjust [6]; "dynamicBlur" ppEffectCommit 0; "dynamicBlur" ppEffectAdjust [0.0]; "dynamicBlur" ppEffectCommit 5; titleCut ["", "BLACK IN", 5]; player setdamage 1; }; Why the event handler not fire? Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted December 24, 2015 I've never used the "MPKilled" EH yet, only the "Killed" EH. But as far as I understand it, "MPKilled" is like "Killed", only that the code will be executed on each connected machine when the unit it's added to is killed. That in mind, INS_fnc_ckMP will only be executed if the player is the killer of the unit the "MPKilled" EH is added to. The problem is, if the player is the one which the EH is added to, this thing will only fire if the player is killed by himself. But that again is opted out by this line: if (vehicle _ckiller isEqualTo vehicle _cvictim) exitWith {}; So, the "MPKilled" EH must be added to the victim, not the killer, just like it's done with the "Killed" EH. Share this post Link to post Share on other sites
davidoss 552 Posted December 24, 2015 Maybe i make it easy. The goal is to spawn some code on client PC which has killed civilian unit. Civilians are owned by server EH is added to civilian unit at unit spawn I knew no way to achieve this until remoteExec is not working. Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted December 25, 2015 Try the "HandleScore" EH, it only works in MP, but it fires whenever the player's score changes, usually after a kill. Having said that, I don't know which other situations might occur for this EH to fire, so you better check if the "object" parameter of this command isKindOf "Man". Share this post Link to post Share on other sites