this headshot script is bugging other protections such as passive and green areas could anyone tell if there is a solution?
Client-side:
function sendHeadshot ( attacker, weapon, bodypart, loss )
if attacker == getLocalPlayer() then
if bodypart == 9 then
triggerServerEvent( "onServerHeadshot", getRootElement(), source, attacker, weapon, loss )
setElementHealth ( source, 0 )
setPedHeadless( source, true )
end
end
end
addEventHandler ( "onClientPedDamage", getRootElement(), sendHeadshot )
addEventHandler ( "onClientPlayerDamage", getRootElement(), sendHeadshot )
Server-side:
function MakePlayerHeadshot( attacker, weapon, bodypart, loss )
if bodypart == 9 then
triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
setPedHeadless ( source, true )
killPed( source, attacker, weapon, bodypart )
setTimer( BackUp, 900, 1, source )
end
end
function MakeHeadshot( source, attacker, weapon, loss )
triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
killPed( source, attacker, weapon, 9 )
setPedHeadless ( source, true )
setTimer( BackUp, 900, 1, source )
end
function BackUp( source )
if getElementType ( source ) == "player" then
setPedHeadless ( source, false )
end
end
function outputHeadshotIcon (killer, weapon, bodypart)
if bodypart == 9 then
cancelEvent()
local r2,g2,b2 = getTeamColor ( getPlayerTeam( killer ) )
local r1,g1,b1 = getTeamColor ( getPlayerTeam( source ) )
exports.killmessages:outputMessage (
{getPlayerName(killer),{"padding",width=3},{"icon",id=weapon},{"padding",width=3},{"icon",id=256},{"padding",width=3},{"color",r=r1,g=g1,b=b1},getPlayerName(source) }, getRootElement(),r2,g2,b2)
end
end
addEvent ( "onServerHeadshot", true )
addEventHandler( "onPlayerDamage", getRootElement(), MakePlayerHeadshot )
addEventHandler( "onPlayerKillMessage", getRootElement(), outputHeadshotIcon )
addEventHandler( "onServerHeadshot", getRootElement(), MakeHeadshot )