Artisz Posted July 21, 2017 Share Posted July 21, 2017 Hi! I have a problem: addEventHandler("onClientVehicleCollision", root, function (collider,force, bodyPart, x, y, z, nx, ny, nz) if getElementType(collider) == "player" then if not isElementFrozen(source) then if collider ~= source then setElementFrozen(source, true) setTimer(setElementFrozen, 1000, 1, source, false) end end end end ) It's working, I can't push the car, but when I try to hit someone, I can't do it, because it call this function. How can I do that I can hit someone with the car, but a player can't push the car. I tried it with mass handling(it didn't work, the vehicle bugged under the ground). Link to comment
Tails Posted July 21, 2017 Share Posted July 21, 2017 (edited) Here's a snippet from an old resource of mine. I'm using mass handling and it works just fine function setVehiclePushable(veh,pushable) if not pushable then setVehicleHandling(veh,"mass",7000) setVehicleHandling(veh,"turnMass",120000) setVehicleHandling(veh,"brakeDeceleration",100000) else local model = getElementModel(veh) local propTable = getOriginalHandling(model) for k,v in pairs(propTable) do setVehicleHandling(veh,k,v) end end end addEventHandler("onVehicleEnter",root, function() setVehiclePushable(source,true) end ) You'll probably need to add the function to onVehicleExit and maybe some other events like onVehicleRespawn or onVehicleExplode so the vehicles get reset properly. My use case is different so I'm using different events. Hope this helps, good luck! Edited July 21, 2017 by Tails Link to comment
pa3ck Posted July 21, 2017 Share Posted July 21, 2017 I don't think this event causes that issue, I mean why would onClientVehicleCollision interfere with other, onClientPedDamage or w/e events? Also you're checking if source ~= collider, that just doesn't make sense since before that you already checked if collider is a player, so how would a player ever be a vehicle? 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