Lucky44 13 Posted March 12, 2017 I have used Shuko's script to monitor when players kill civilians and then identify the killer. But it seems that it doesn't work in Arma 3 anymore. Does anyone have a solution to this or an alternative way to do this? Here's the code I had been using: ////////////////////////////////////////////////////////////////// // Count Civ Deaths, // Consider which faction killed them, // Identify killer in hint to everyone. // Created by: Shuko ////////////////////////////////////////////////////////////////// ////////////////////////CIVILIAN DEATH LIMIT///////////////////////////////////////////////////////////// SHK_DeadCivilianLimit = 99; // Set as specific number OR (paramsarray select 2) <--set in Description.ext SHK_DeadCivilianCount = 0; SHK_DeadCivilianArray = [SHK_DeadCivilianCount, objNull]; SHK_EndMission = false; [] spawn { waituntil {SHK_EndMission}; cuttext ["Mission Failure!\nUnfortunately, your team killed too many civilians.","PLAIN",2]; sleep 10; endmission "END2"; }; SHK_fnc_deadCivilians = { _count = _this select 0; _killer = _this select 1; hintSilent format ["Civilians dead: %1 \nLast civ killer: %2", _count, name _killer]; if (_count >= SHK_DeadCivilianLimit) then { SHK_EndMission = true; publicvariable "SHK_EndMission"; }; }; SHK_eh_killed = { private "_side"; _killer = _this select 1; _side = side _killer; //Set the players' side in next line if (_side == WEST) then { SHK_DeadCivilianCount = SHK_DeadCivilianCount + 1; SHK_DeadCivilianArray = [SHK_DeadCivilianCount, _killer]; publicvariable "SHK_DeadCivilianArray"; if isdedicated then { if (_this >= SHK_DeadCivilianLimit) then { SHK_EndMission = true; publicvariable "SHK_EndMission"; }; } else { [SHK_DeadCivilianCount, _killer] call SHK_fnc_deadCivilians; }; }; }; if isserver then { { if (side _x == Civilian && _x iskindof "Man") then { _x addEventHandler ["killed", SHK_eh_killed]; }; } foreach allunits; } else { "SHK_DeadCivilianArray" addpublicvariableeventhandler { _array = _this select 1; _count = _array select 0; _killer = _array select 1; [_count, _killer] call SHK_fnc_deadCivilians }; }; [] spawn { waituntil {!isnil "BIS_alice_mainscope"}; waituntil {!isnil "bis_fnc_variablespaceadd"}; [BIS_alice_mainscope,"ALICE_civilianinit",[{_this addEventHandler ["killed", SHK_eh_killed]}]] call bis_fnc_variablespaceadd; }; 1 Share this post Link to post Share on other sites
serena 151 Posted March 12, 2017 The simpler - the better, I think: // init.sqf CivilianKillers = []; if (isServer) then { { if (side _x == CIVILIAN) then { _x addEventHandler ["Killed", { params ["_vct", "_klr"]; private _dta = CivilianKillers; private _rec = {if (_x select 0 isEqualTo _klr) exitWith {_x}} forEach _dta; if (isNil {_rec}) then {_rec = [_klr, 1]; _dta pushBack _rec} else {_rec set [1, (_rec select 1) + 1]} }] } } foreach allUnits; }; player addAction ["List Civilian Killers", { { _x params ["_unt", "_cnt"]; systemChat format ["%1 killed %2 civilian(s)", _unt, _cnt] } forEach CivilianKillers }]; player addAction ["Count Killed Civilians", { private _cnt = 0; {_cnt = _cnt + (_x select 1)} forEach CivilianKillers; systemChat format ["Civilians killed: %1", _cnt] }]; Sample mission: link Share this post Link to post Share on other sites
killzone_kid 1333 Posted March 12, 2017 8 hours ago, serena said: The simpler - the better, I think: I'll drink to that //init.sqf addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer"]; if (_killed isKindOf "CAManBase" && {side group _killed isEqualTo civilian}) then { systemChat format ["Player %1 killed a civilian", name _killer]; }; }]; 1 Share this post Link to post Share on other sites
serena 151 Posted March 12, 2017 Updated to killzone_kid variant: CivilianKillers = []; if (isServer) then { addMissionEventHandler ["EntityKilled", { params ["_vct", "_klr"]; if (_vct isKindOf "CAManBase" and {side group _vct isEqualTo CIVILIAN}) then { private _dta = CivilianKillers; private _rec = {if (_x select 0 isEqualTo _klr) exitWith {_x}} forEach _dta; if (isNil {_rec}) then {_rec = [_klr, 1]; _dta pushBack _rec} else {_rec set [1, (_rec select 1) + 1]} } }]; }; Sample mission Share this post Link to post Share on other sites
Lucky44 13 Posted March 12, 2017 I really appreciate the input! My goals for this script would be It has to work on dedi server in MP. Has to work for spawned as well as placed AI civs. Note whenever a player (or it could be by faction: West) kills a civilian human. Keep running count of total. Publish message (hint is fine) to everyone showing who the player was, and use the player's profile name. Originally, the mission would end if the # of civs killed hit a set amount. Maybe not do that and show the count and the killers' names at the end of mission too, but that's a detail. I'll try the code y'all sent. UPDATE: KK's code works in SP to ID the unit name of the civ killer but not MP. Does anyone see anything wrong with the Shuko code, for the current Arma 3 environment? -I'm not married to that code, but it does address #s 1-6 above. Share this post Link to post Share on other sites
Lucky44 13 Posted March 15, 2017 Does anyone have suggestions for either A) why the Shuko code doesn't work anymore, or B) how to accomplish the 1-5 I listed for this? Share this post Link to post Share on other sites
killzone_kid 1333 Posted March 15, 2017 On 3/12/2017 at 5:43 PM, lucky44 said: KK's code works in SP to ID the unit name of the civ killer but not MP. It should work in MP too, unless you somehow restricted it only for the server. Share this post Link to post Share on other sites
Lucky44 13 Posted March 15, 2017 @killzone_kid: you said to put it in the init.sqf, yes? (That's what I did.) Also, should it work on spawned AI units? I appreciate your help! Share this post Link to post Share on other sites
killzone_kid 1333 Posted March 17, 2017 Sorry, you want my answer? If so, I have nothing more to add, the snippet I gave you works in MP i have just checked. Well in fact I've just checked it on stable since I downloaded it for something. It goes in init.sqf and boom it works for everyone. Share this post Link to post Share on other sites
Lucky44 13 Posted March 18, 2017 24 minutes ago, killzone_kid said: Sorry, you want my answer? If so, I have nothing more to add, the snippet I gave you works in MP i have just checked. Well in fact I've just checked it on stable since I downloaded it for something. It goes in init.sqf and boom it works for everyone. Thanks. And should it work for spawned units? Share this post Link to post Share on other sites
froggyluv 2136 Posted March 18, 2017 I also use a script to make civilians talk and react and to make sure the spawned ones also react I just plant the call in the Config or in your case for a mission the Description.ext. All CaManbase class can call the script for each human created and in the script you can filter it to Civilian. Share this post Link to post Share on other sites
Lucky44 13 Posted March 19, 2017 Thanks, Froggyluv. Are you suggesting putting the same code (from KK) just in the description.ext? Does that work for adding a mission EH? Share this post Link to post Share on other sites
salihf7 0 Posted March 19, 2017 Hello help please ? Share this post Link to post Share on other sites
Tankbuster 1747 Posted March 19, 2017 @lucky44 Are you using CUP? 1 Share this post Link to post Share on other sites
accuracythruvolume 547 Posted March 20, 2017 More importantly, are you using ACE medical? In my tests, it makes the killer and killed of the onKilled event handler the same 1 Share this post Link to post Share on other sites
Tankbuster 1747 Posted March 20, 2017 Yes, ACE medical adds eventhandlers that can interfere with this, also, a lot of CUP civilians are misconfigured so they arent really civilians. 1 Share this post Link to post Share on other sites
Lucky44 13 Posted March 20, 2017 Yes, we generally run CUP, and we use ACE3 Medical (Basic, atm). That would explain why I couldn't get the killer and killed straight! I tried switching the two vars, switching the output, etc. but it never worked. Does anyone know a way to make KK's simple code work with ACE3 Medical? (or have an alternative approach)? Share this post Link to post Share on other sites
accuracythruvolume 547 Posted March 21, 2017 My alternative system was for any civilian that dies within X meters of a player (I used 200) it adds to a counter and pops a hint to all players. At a certain number of civvie deaths (I used 10) the mission is failed. So players don't want any civvies dying around them or they get blamed. 1 Share this post Link to post Share on other sites
Tankbuster 1747 Posted March 21, 2017 My alternative system was to count the number of alive civilians periodically. The problem was that so many of them are killed by being run down by AI drivers that that whole aspect of my mission had to be shelved. Share this post Link to post Share on other sites
Tankbuster 1747 Posted March 21, 2017 Basically, if you want to use eventhandlers, don't use ACE. If you want to use CAManBase >> Civilian, don't use CUP. 1 Share this post Link to post Share on other sites
Lucky44 13 Posted March 21, 2017 Well, sadness! I can live without some of the CUP civvies, but my group relies on ACE3 for our MP missions. Thanks for all the input. If anyone hears of a workaround, particularly for using ACE, please post back here! Share this post Link to post Share on other sites