Jan_F_W 10 Posted August 5, 2009 (edited) I have an addEventHandler["killed" ... ] for AI-Units so that killed AIs get a note in the diary. When I -as a player- kill an AI with e.g. a helicoper the EventHandler returns the victim and the killer but in this case the killer is the helicopter Id and not the players one - how can I resolve the player then? I have already succeeded in using commands like "assignedGunner _vehicle createDiaryRecord [...]" but since helicopters like the MI8 MTV-3 and UH-1Y have more than one gunner seat I cannot get the player when he is not the 1st gunner... Called on a units init like this: this addEventHandler["killed", {[_this select 0, _this select 1] execVM "Scripts\playerKilled.sqf"}]; I'm using the following code in the "playerKilled.sqf": _victim = _this select 0; _killer = _this select 1; hint format["Killer: %1, Victim: %2, NameOfKiller: %3", _killer, _victim, name _killer]; When killing an AI unit when Im 2nd gunner of the UH-1Y the hint reports for the "_killer " the name of the uh1y, "_victim" is correctly traced and the name of the "_killer" is mine (playername) but I cannot find a way to get the id/name of the killer and not only the screenname of my player - I cannot address a "createDiaryRecord ..." correctly. Edited August 5, 2009 by Jan_F_W Share this post Link to post Share on other sites
Jan_F_W 10 Posted August 6, 2009 no one knows? How can I resolve the "player ID" so that I can perform actions with the player by just having his player name? Share this post Link to post Share on other sites
dr_eyeball 16 Posted August 6, 2009 Unfortunately, if the killer is the vehicle, then there is no positive way to determine the killer. It could be the pilot (eg: missiles) or any gunner. If you've got a player object, then you can obtain the ID using getPlayerUID or track a list using onPlayerConnected. You can get all gunners using various techniques, like this: getGunners.sqf: // Desc: get a list of all gunners for vehicle // Result: array of objects // Notes: Includes: UH60 gunners, tank commander gunners, boat gunners //----------------------------------------------------------------------------- private ["_vehicle", "_gunners", "_role"]; _vehicle = _this select 0; _gunners = []; { _role = assignedVehicleRole _x; // eg: ["Turret", [turret path]] if (count _role > 0) then { if (_role select 0 == "Turret") then { _gunners = _gunners+[_x]; }; }; } forEach (crew _vehicle); _gunners Share this post Link to post Share on other sites
Jan_F_W 10 Posted August 6, 2009 Thanks! I will give it a try; if I find out something I will post here Share this post Link to post Share on other sites
Rough Knight 9 Posted November 20, 2009 (edited) Hi guys, This is probably the closest subject I have found to my problem. I am finding that with the "killed" eventhandler, if the victim is run over by a vehicle, the EH is returning the killed unit as the killer when the killer is really the driver of the vehicle. I am not sure why...I guess the killed units suddenly accelerates when hit by the vehicle then dies on impact with the ground? What I need to do is check the side of the vehicles driver if a civillian gets run over, but I am not having much success. Here is my script so far. init civarray = [pooman1, pooman2]; {_x addeventhandler ["hit", {nul = [_this select 0, _this select 1] execvm "vehiclesidecheck.sqf"}]} foreach civarray; vehiclesidecheck //check the side of the vehicle that killed a civillian then add count to tally. //hint "drivercheck active"; _civillian = _this select 0; _killer = _this select 1; hint format ["victim : %1\nkiller: %2", _civillian, _killer]; if (side _killer == west) then { civ_casualties = civ_casualties + 1; publicvariable "civ_casualties"; civ_cas_by_west = civ_cas_by_west +1; hint format ["civ casualties : %1\nciv cas west : %2", civ_casualties, civ_cas_by_west]; } else {if (!(_killer iskindOf "man")) then { _driver = driver _vehicle; _driverside = side _driver; hint format ["driver side: %1", _driverside]; if (_driverside == West) then { civ_casualties = civ_casualties + 1; publicvariable "civ_casualties"; civ_cas_by_west = civ_cas_by_west +1; hint format ["civ casualties : %1\nciv cas west : %2", civ_casualties, civ_cas_by_west]; }; }; }; The hints are purley for bug finding and can be ignored. I guess I am not sure what to try next as the killer does not seem to be recognised. Any help or advice would be much appreciated as per usual. Thanks Frosty Edited November 20, 2009 by Rough Knight Sorry..initally had an error in script that returned "any" as the killer Share this post Link to post Share on other sites