FragZ

[Help please] Detect when X Player kills a target player

11 posts in this topic

Pretty much, I want to be able to detect (in a loop or anything) when a player say John kills player Justin.

Then, return that he got killed but only to the killer as part of an event mission I want to make.

 

So in resume, detect when X player that activates a script kills a designated target player.


Thanks!

 

Share this post


Link to post
Share on other sites
Advertisement
9 hours ago, Taylor Swift (Mezo) said:

Take a look at how _Killer is checked in onKilled?

**Note: Didn't actually look into this just a hint.

Alright ill take a look and report here.

EDIT: Would it be by checking in ExileServer_Object_Player_event_onMpKilled? If so I can't lay a finger on it...
 


 

 

 

private["_victim","_killer","_victimPosition","_addDeathStat","_addKillStat","_normalkill","_killerRespectPoints","_fragAttributes","_player","_grpvictim","_grpkiller","_log","_lastVictims","_victimUID","_vehicleRole","_vehicle","_lastKillAt","_killStack","_distance","_distanceBonus","_flagNextToKiller","_homieBonus","_flagNextToVictim","_raidBonus","_overallRespectChange","_newKillerScore","_killMessage","_newKillerFrags","_newVictimDeaths"];
if (!isServer || hasInterface) exitWith {};
_victim = _this select 0;
_killer = _this select 1;
if( isNull _victim ) exitWith {};
_victim setVariable ["ExileDiedAt", time];
if !(isPlayer _victim) exitWith {};
_victimPosition = getPos _victim;
format["insertPlayerHistory:%1:%2:%3:%4:%5", getPlayerUID _victim, name _victim, _victimPosition select 0, _victimPosition select 1, _victimPosition select 2] call ExileServer_system_database_query_fireAndForget;
format["deletePlayer:%1", _victim getVariable ["ExileDatabaseId", -1]] call ExileServer_system_database_query_fireAndForget;
_victim setVariable ["ExileIsDead", true];
_victim setVariable ["ExileName", name _victim, true]; 
_victim call ExileServer_object_flies_spawn;
_addDeathStat = true;
_addKillStat = true;
_normalkill = true;
_killerRespectPoints = [];
_fragAttributes = [];
if (_victim isEqualTo _killer) then
{
	["systemChatRequest", [format["%1 commited suicide!", (name _victim)]]] call ExileServer_object_player_event_killFeed;
}
else 
{
	if (vehicle _victim isEqualTo _killer) then
	{
		["systemChatRequest", [format["%1 crashed to death!", (name _victim)]]] call ExileServer_object_player_event_killfeed;
	}
	else 
	{
		if (isNull _killer) then
		{
			["systemChatRequest", [format["%1 died for an unknown reason!", (name _victim)]]] call ExileServer_object_player_event_killfeed;
		}
		else 
		{
			_player = objNull;
			if (isPlayer _killer) then 
			{
				if ((typeOf _killer) isEqualTo "Exile_Unit_Player") then
				{
					_player = _killer;	
				}
				else 
				{
					_uid = getPlayerUID _killer;
					{
						if ((getPlayerUID _x) isEqualTo _uid) exitWith 
						{
							_player = _x;
						};
					}
					forEach allPlayers;
				};
			}
			else 
			{
				if (isUAVConnected _killer) then 
				{
					_player = (UAVControl _killer) select 0;
				};
			};
			if !(isNull _player) then
			{
				_killer = _player;
				if (_victim getVariable ["ExileIsBambi", false]) then
				{
					_addKillStat = false;
					_addDeathStat = false;
					_fragAttributes pushBack "Bambi Slayer";
					_killerRespectPoints pushBack ["BAMBI SLAYER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "bambi"))];
				}
				else 
				{
					_grpvictim = _victim getVariable ["ExileGroup",(group _victim)];
					_grpkiller = _killer getVariable ["ExileGroup",(group _killer)];
					if((_grpvictim isEqualTo _grpkiller)&&!(ExileGraveyardGroup isEqualTo _grpkiller))then
					{
						_log = format["%2 was team-killed by %1!", (name _killer), (name _victim)];
						["systemChatRequest", [_log]] call ExileServer_object_player_event_killfeed;
						_fragAttributes pushBack "Teamkill";
						_killerRespectPoints pushBack ["TEAMKILL", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "friendlyFire"))];
						_normalkill = false;
					}
					else
					{
						_lastVictims = _killer getVariable ["ExileLastVictims", ["0", "1", "2"]];
						_victimUID = _victim getVariable ["ExileOwnerUID", getPlayerUID _victim];
						if (_victimUID in _lastVictims) then
						{
							_log = format["%1 keeps killing %2!", (name _killer), (name _victim)];
							["systemChatRequest", [_log]] call ExileServer_object_player_event_killfeed;
							_fragAttributes pushBack "Domination";
							_killerRespectPoints pushBack ["DOMINATION BONUS", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "domination"))];
						}
						else
						{
							_lastVictims deleteAt 0;
							_lastVictims pushBack _victimUID;
							_killer setVariable ["ExileLastVictims", _lastVictims];
							if ((vehicle _killer) isEqualTo _killer) then 
							{
								if ((currentWeapon _killer) isEqualTo "Exile_Melee_Axe") then
								{
									_fragAttributes pushBack "Humiliation";
									_killerRespectPoints pushBack ["HUMILIATION", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "humiliation"))];
								}
								else 
								{
									_killerRespectPoints pushBack ["ENEMY FRAGGED", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "standard"))];
								};
							}
							else 
                              
                              
                              [...]
Edited by FragZ

Share this post


Link to post
Share on other sites

you could check by UID
(very rough example not tested)

_victimID = (guytobe killed UID );
_killerID = (guy who kills UID );
_killerUID = (_killer getplayerUID);
_victimUID = (_victim getplayerUID);
_WASKILLED = false;

if ((  _killerUID == _killerID )  && (  _victimUID == _victimID )) then {

//message here / code here
_WASKILLED = true;

};

you would put this under

_fragAttributes = [];

in theroy this will work, there may be better ways to do it but this is simple and easy to implement

 

it will still say to all he was killed but you could just add a boolean and have the main alert code check for it and if its true not send of the global message

Edited by FallingSheep
edit code

Share this post


Link to post
Share on other sites
26 minutes ago, FallingSheep said:

you could check by UID
(very rough example not tested)


_victimID = (guytobe killed UID );
_killerID = (guy who kills UID );
_killerUID = (_killer getplayerUID);
_victimUID = (_victim getplayerUID);
_WASKILLED = false;

if ((  _killerUID == _killerID )  && (  _victimUID == _victimID )) then {

//message here / code here
_WASKILLED = true;

};

you would put this under


_fragAttributes = [];

in theroy this will work, there may be better ways to do it but this is simple and easy to implement

 

it will still say to all he was killed but you could just add a boolean and have the main alert code check for it and if its true not send of the global message

So edit my MPKilled file to include a custom variable or something and then use an external script in the client side to verify who it was or something?

This is a part of an XM8 app I want to make

Share this post


Link to post
Share on other sites
7 minutes ago, FragZ said:

So edit my MPKilled file to include a custom variable or something and then use an external script in the client side to verify who it was or something?

This is a part of an XM8 app I want to make

ah now i get what you want :)

since i like the idea of alerting just one player ill see if i can come up with a script for you.

if you could tell me what you want the app to do/ display ill try get a test version together today for you :P

Share this post


Link to post
Share on other sites
9 minutes ago, FallingSheep said:

ah now i get what you want :)

since i like the idea of alerting just one player ill see if i can come up with a script for you.

if you could tell me what you want the app to do/ display ill try get a test version together today for you :P

Okay that sounds good thanks.

 

And nah im fine I have the rest of the script already, just need to detect in the loop of the active thing when you kill the target player :P

Share this post


Link to post
Share on other sites
2 hours ago, FragZ said:

Okay that sounds good thanks.

 

And nah im fine I have the rest of the script already, just need to detect in the loop of the active thing when you kill the target player :P

no probs ill write a script to detec if a certain UID was killed by another UID and only message the killer

it will most likey be an edited

ExileServer_Object_Player_event_onMpKilled?

Share this post


Link to post
Share on other sites

this shouldnt be that difficult. at work on my phone so cant really look at all the code easily.

add to each player a mpkilled event handler that will run a simple script that checks if _victim uid == target _victim.  if true, now do whatever you want to do with the killer info.   

what seems to be your current problem?

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#MPKilled

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.