MrSecreto07 Posted June 5, 2017 Share Posted June 5, 2017 Hello Community! I have a question and I would like to know who helps me ... Is there a way to make a script for a player to die when hit by a vehicle? In case if it can be done, I would like you to tell me the functions I need to do it. Link to comment
MIKI785 Posted June 5, 2017 Share Posted June 5, 2017 I guess you could use onClientVehicleCollision but I think that it will trigger on any contact, even if the player runs to the vehicle and touches it. You just have to test it and maybe use the "force" parameter. Link to comment
idarrr Posted June 6, 2017 Share Posted June 6, 2017 You can use onPlayerDamage. addEventHandler( "onPlayerDamage", root, function (attacker, weapon, bodypart, loss) if isElement(attacker) and getElementType(attacker) == "vehicle" then setElementHealth(source, 0) end end ) Link to comment
Hale Posted June 6, 2017 Share Posted June 6, 2017 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. 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now