Jump to content

stop vehicles killing players


Twisted

Recommended Posts

this may be a nooby question but me and my friend (good scripter) cant seem to cancel the event when some one is injured by a vehicle maybe some of u could help :)

function nodamage(attacker, bodypart) 
vehicle = getPedOccupiedVehicle(source) 
if (vehicle) then 
cancelEvent() 
end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(),nodamage) 
  

Link to comment

gokal, that's the same but without the "()"...... :roll:

He's trying to do when someone get's injured by a vehicle it will not take health from him.

function nodamage(attacker, bodypart) 
local vehicle = getPedOccupiedVehicle(attacker) 
if (vehicle) then 
cancelEvent() 
  end 
end 
addEventHandler("onClientPlayerDamage", getLocalPlayer(),nodamage) 

Try with that.

Link to comment
attacker: A player element representing the attacker or vehicle element (when being run over or falling off a bike).

That's from the onClientPlayerDamage page so can't it just be:

function nodamage(attacker, bodypart) 
if getElementType(attacker) == 'vehicle' then 
cancelEvent() 
end 
addEventHandler("onClientPlayerDamage", getLocalPlayer(),nodamage) 

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