Jump to content
Sign in to follow this  
ssm4862

AI Kill Player Name question.

Recommended Posts

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

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 by DNK

Share this post


Link to post
Share on other sites

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 by twirly
Clarity

Share this post


Link to post
Share on other sites

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 by Hank_2011

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×