ssm4862 10 Posted January 13, 2011 example. Player AI is killed. I killed the AI player's name on the screen I want to look. What should I do? help me please. Share this post Link to post Share on other sites
dnk 13 Posted January 13, 2011 (edited) I'm looking for this also, but I didn't see any commands that will tell you who killed who. The game clearly keeps some track of what kills what, although I do not know if it saves a value for each dead unit as to what other unit killed it or visa-versa. I suppose a workaround would be to: while {true} do { units = allunits; scoreP = rating player; sleep 0.00001; if (scoreP < rating player) then { //I will mess this up as I do not understand arrays, but someone should be able to correct it in passing deadman = units - allunits; { deadman2 = name _x; hint format ["Player killed %1",deadman2]; } foreach deadman; }; }; What that attempts to do is check every frame/halfsecond (might need a waituntil, I dunno, because while-dos might not refresh fast enough?) to see if the player's score has increased (by killing stuff, assuming you have no score-granting objectives) by comparing the player's score the previous frame (or whenever: scoreP) to his current score (rating player). If it is higher, then it compares the list of alive units the past frame (units) to the current list of alive units (allunits). The difference (the dead man) is then inputted into a text display. This might not work if you have units added or revived during the mission, and it might throw up some false positives if the player kills someone (or a vehicle/etc) on the same "frame" another person dies, but it's close at least. It might not work at all, I don't want to open A2 just to check. My best attempt, I'm sure it's lolbad :) Edited to add in more stuff. Edited January 13, 2011 by DNK Share this post Link to post Share on other sites
twirly 11 Posted January 13, 2011 (edited) Try this guys.....it's much simplified from what I'm using but will get you started. You need to use an Eventhandler. Create this file in your mission folder (add_ehs.sqf)....it adds the necessary "Killed" Evenhandler to all the units of a group. add_ehs.sqf //Twirly 2011 private ["_group","_unit","_i"]; _group = _this select 0; whoDunnit = { private ["_deatharray","_victim","_killer","_namvictim","_dis"]; _deatharray =_this select 0; _victim = _deatharray select 0; _killer = _deatharray select 1; _dis = round (_killer distance _victim); _killer globalchat format ["%1 killed %2 at %3m", name _killer, name _victim, _dis]; }; for [{_i=0},{_i<=count units _group},{_i=_i+1}] do { _unit = units _group select _i; _unit addeventhandler ["KILLED",{nul=[_this] call whoDunnit}]; sleep 0.01; }; Add this to the leader of each groups init..... nul = [group this] execVM "add_ehs.sqf"; Each and every unit will have to have this script running on it in order to get a message for every death. I run this on all my units and have no problems. Demo mission here. I realise this is not exactly what you need....but I'm sure you can figure out how to run it on the player! Good luck! Edited January 13, 2011 by twirly Clarity Share this post Link to post Share on other sites
Hank_2011 10 Posted February 18, 2011 Great script! Is it still possible to add information about the weapon which killed? Share this post Link to post Share on other sites
Hank_2011 10 Posted February 19, 2011 (edited) and adapted for multiplayer. Edited February 19, 2011 by Hank_2011 Share this post Link to post Share on other sites
Hank_2011 10 Posted February 24, 2011 (edited) In this variant displays information about the main weapon of the arrow: private ["_group","_unit"]; _group = _this select 0; whoDunnit = { private ["_deatharray","_side", "_victim","_killer","_namvictim","_dis"]; _deatharray =_this select 0; _victim = _deatharray select 0; _killer = _deatharray select 1; _killgun = primaryWeapon _killer; _dis = round (_killer distance _victim); _killer globalchat format ["> *%1* < hit the target > *%2* < distance of > *%3* < meters > weapon *%4* <", name _killer, name _victim, _dis, _killgun]; }; for [{_i=0},{_i<=count units _group},{_i=_i+1}] do { _unit = units _group select _i; _unit addeventhandler ["KILLED",{nul=[_this] call whoDunnit}]; sleep 0.01; }; For the script in multiplayer need expert help ! Edited February 24, 2011 by Hank_2011 Share this post Link to post Share on other sites