Jump to content

Question


Recommended Posts

Here's a good example of how to check vehicle's speed, which is useful unless you want players to die from a vehicle hitting them at 1 km/h. :P 

addEventHandler( "onPlayerDamage", root, 
	function (attacker, weapon, bodypart, loss)
	  	if isElement(attacker) and getElementType(attacker) == "vehicle" then
      		local speedx, speedy, speedz = getElementVelocity (attacker)
			local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
			local kmh = actualspeed * 180
      		if kmh > 50 then
				setElementHealth(source, 0)
			end
		end
	end
)

 

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...