SA-Symon

HeadShot Bugged

Recommended Posts

function MakePlayerHeadshot( attacker, weapon, bodypart, loss )
	if getElementType ( attacker ) == "ped" then
		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
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 )

it's has bug : if player have Armour it's just damge and when damge removed not making head shot it's just damge

i need it if player have Armour it's auto removed when player make headshot and when kill player haven't armour make his hp 0 auto

Share this post


Link to post

I don't really understand what is your problem. Can you use google translator, please?

BTW, this could help:

 

Edited by Peti

Share this post


Link to post
function MakePlayerHeadshot( attacker, weapon, bodypart, loss )
	if getElementType ( attacker ) == "ped" then
		if bodypart == 9 then
     		if getPedArmor(source) > 0 then
        		triggerEvent( "onPlayerHeadshotArmor", source)
        	else
                triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
                setPedHeadless ( source, true )
                killPed( source, attacker, weapon, bodypart )
                setTimer( BackUp, 900, 1, source )
       		end
		end
	end
end

function onPlayerHeadshotArmor()
	setPedArmor(source, 0)
end
addEvent("onPlayerHeadshotArmor", true)
addEventHandler("onPlayerHeadshotArmor", root, onPlayerHeadshotArmor)

 

Try this (Not tested)

Share this post


Link to post

If the above code doesn't work, try this:


function MakePlayerHeadshot( attacker, weapon, bodypart, loss )
	if getElementType ( attacker ) == "player" and bodypart == 9 then
		if getPedArmor(source) > 0 then
			setPedArmor( source, 0 )
			if loss and loss > 0 then setElementHealth( source, getElementHealth(source) + loss ) end -- dunno if 'loss' also works for the armor
		else
			triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
			setPedHeadless ( source, true )
			killPed( source, attacker, weapon, bodypart )
			setTimer( BackUp, 900, 1, source )
		end
	end
end
addEventHandler( "onPlayerDamage", getRootElement(), MakePlayerHeadshot )

function BackUp( source )	
	if getElementType ( source ) == "player" then
		setPedHeadless ( source, false )
	end
end

 

Share this post


Link to post
On 08/02/2019 at 01:20, DNL291 said:

If the above code doesn't work, try this:


function MakePlayerHeadshot( attacker, weapon, bodypart, loss )
	if getElementType ( attacker ) == "player" and bodypart == 9 then
		if getPedArmor(source) > 0 then
			setPedArmor( source, 0 )
			if loss and loss > 0 then setElementHealth( source, getElementHealth(source) + loss ) end -- dunno if 'loss' also works for the armor
		else
			triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss )
			setPedHeadless ( source, true )
			killPed( source, attacker, weapon, bodypart )
			setTimer( BackUp, 900, 1, source )
		end
	end
end
addEventHandler( "onPlayerDamage", getRootElement(), MakePlayerHeadshot )

function BackUp( source )	
	if getElementType ( source ) == "player" then
		setPedHeadless ( source, false )
	end
end

 

not working

Share this post


Link to post

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.