I have the following code as a tazer function:
waitUntil {!isNull player && player == player};
waitUntil {!(isNull (findDisplay 46))};
sleep 2;
mav_tazer_fnc = {
private["_unit","_damage","_source","_projectile","_old"];
_unit = param[0,objNull,[objNull]];
_damage = param[2,0,[0]];
_source = param[3,objNull,[objNull]];
_projectile = param[4,"",[""]];
_old = (getDammage player);
if(
!isNull _source && {!isNull _unit} && {_source != _unit} &&
{(toLower(currentWeapon _source) find "hgun_p07" != -1)}
) then {
if(alive player && (player distance _source) < 50) then {
[] spawn {
tased = true;
player allowDamage false;
player setUnconscious true;
uiSleep 10;
player setUnconscious false;
player playMoveNow "AmovPercMstpSnonWnonDnon";
player allowDamage true;
tased = false;
};
_damage = _old;
};
};
0;
};
player removeAllEventHandlers "handleDamage";
player addEventHandler["handleDamage",{_this call mav_tazer_fnc;}];
};