erisP Posted August 11, 2020 Share Posted August 11, 2020 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
Zorgman Posted August 11, 2020 Share Posted August 11, 2020 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
erisP Posted August 12, 2020 Author Share Posted August 12, 2020 I did not understand Link to comment
Zorgman Posted August 12, 2020 Share Posted August 12, 2020 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
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