Jump to content

[Help] vehicle damage


erisP

Recommended Posts

function onVehicleDamage(attacker, wep, loss, x, y, z, tire)
        if (exports.team:isPlayerInTeam(source, "TSK") and exports.team:isPlayerInTeam(attacker, "TSK")) then
            cancelEvent(true)
        elseif (exports.team:isPlayerInTeam(source, "WSP") and exports.team:isPlayerInTeam(attacker, "WSP")) then
            cancelEvent(true)
	end
end
addEventHandler("onClientVehicleDamage", root, onVehicleDamage)

this code doesn't work. what should I do?

Link to comment

The source of onClientVehicleDamage event is the vehicle that got damaged.

So your code is checking if the vehicle is in a team - you probably want to run your checks on the vehicle driver instead. You can use

player getVehicleOccupant ( vehicle theVehicle, [ int seat=0 ] )  

 

Link to comment
function onVehicleDamage(attacker, wep, loss, x, y, z, tire)
  if getElementType(attacker) == "player" then
        if (exports.team:isPlayerInTeam(getVehicleOccupant(source), "TSK") and exports.team:isPlayerInTeam(attacker, "TSK")) then
            cancelEvent(true)
        elseif (exports.team:isPlayerInTeam(getVehicleOccupant(source), "WSP") and exports.team:isPlayerInTeam(attacker, "WSP")) then
            cancelEvent(true)
		end
  end
end
addEventHandler("onClientVehicleDamage", root, onVehicleDamage)

This should do it.

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