Jump to content

Recommended Posts

Hello guys, I would like some help with this script below. My idea is to make two arenas (PvP), one of them is to kill any player with just one shot. The other arena is just killing with headshots! I was indicted to put elementData, but I don't know how to do that. Can someone help me?

Sorry for bad English.

Script Arena Oneshot
function playerDamage_text ( attacker, weapon, bodypart, loss )
	if ( bodypart == 3 and attacker and attacker ~= source ) then 
	    killPed ( source, attacker, weapon, bodypart ) 
	end
end
addEventHandler ( "onPlayerDamage", root, playerDamage_text )
--------------------------_----------------------------------
Script Headshot
function playerDamage_text ( attacker, weapon, bodypart, loss )
	if ( bodypart == 9 and attacker and attacker ~= source ) then 
	    killPed ( source, attacker, weapon, bodypart ) 
	end
end
addEventHandler ( "onPlayerDamage", root, playerDamage_text )

 

Edited by GunnerMapper
Link to comment

First of all, instead working at serverside, I recommend you to work at serverside with practically the same function.

onClientPedDamage()
setElementHealth()

Respecting you main question, might the best option is to deal with dimensions to prevent a high amount of players in the same dimension. This also might brings you a better performance (Might not visible)

About the code, I didn't test it. IT IS CLIENTSIDE

-- FOR HEAD SHOT ARENA
function cancelPedDamage (attacker,weapon,bodypart)
	cancelEvent() -- cancel any damage done to peds
	if source == local player then
		if ( bodypart == 9 and attacker and attacker ~= source ) then 
			setElementHealth(source,0)
		end
	end
end
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage )

-- FOR ONE SHOT ARENA
function cancelPedDamage (attacker,weapon,bodypart)
	cancelEvent() -- cancel any damage done to peds
	if source == local player then
		setElementHealth(source,0)
	end
end
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage )

Also, try to deal with player state with elementData. This is to prevent an already dead ped of being shot again. 

Edited by Overkillz
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...