Jump to content

Headshot


yToPzz

Recommended Posts

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 )

 

Link to comment
1 hour ago, NeverGiveup said:

What do you mean by passive and green areas? killer can headshot victim that is inside safe zones?? if so add some check if the victim is inside safe zones then return false it

eg: using https://wiki.multitheftauto.com/wiki/IsInsideRadarArea

if (isElementInsideRadarArea(victim, area) then
    return false
end

 

happens that there are 2 scripts where this Headshot is causing problems the first is the passive mode where you cannot kill or die in it and the green areas where you cannot kill with this headshot shooting in the head even with passive mode active or being in a green area the player dies.

Link to comment

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.
×
×
  • Create New...