//Eggbeast kill action - inspired by DayZ scripts by Rocket

if (not (local player)) exitwith {};

EB_player_kill = -1;
EB_myCursorTarget3 = objNull;

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
	_player = player;
	_vehicle = vehicle _player;
	_inVehicle = (_vehicle != _player);
	_hasknife = "EB_knife" in (magazines _player); 
//	if (_hasknife) then {hintsilent "armed with knife"};
	if ( (!isNull cursorTarget) and (!_inVehicle) and (_player distance cursorTarget < 10) and (_hasknife) ) then 
	{
		_isMan = cursorTarget isKindOf "Man";
		_isAlive = alive cursorTarget;
		_text2 = getText (configFile >> "CfgVehicles" >> typeOf cursorTarget >> "displayName");
		//hintsilent format ["vec: %1", _text2];
///////##################################
//Allow player to kill man
///////##################################
		if ( (_hasknife) and (_isMan) and (_isAlive) ) then 
		{
			if (EB_player_kill < 0) then 
			{
				_vehicle = cursorTarget;
				EB_myCursorTarget3 = _vehicle;
				_fstring0 = format["kill %1",_text2];//kill name of type of man
				_ficon = "<img image='\ca\ui\data\ui_action_getingunner_ca.paa' size='1.0' shadow='false' />";
				_fstring = format ["<t color='#f79b31'>" +"%1 %2"+ "</t>",_ficon,_fstring0];
				EB_player_kill = EB_myCursorTarget3 addAction [_fstring, "Actions\EB_resources_scripts\actions\kill.sqf",[_vehicle,_player], 3, true, true,"",""];
			};
		} else 
		{
			EB_myCursorTarget3 removeAction EB_player_kill;
			EB_player_kill = -1;
		};
	} else 
///////##################################
	{
		EB_myCursorTarget3  removeAction EB_player_kill; EB_player_kill = -1;
	};
sleep 1;
};