• How to make cars collide with players
    5 replies, posted
Hey, I have a DarkRP server and It's pretty successful, I've gotten to the stage where everyone is begging for TDMCars, however I'll have a problem with CarDM a lot seeing as there'll be 50-70 players on the server. I was wondering if there was a way to make cars collide with players but not other props and if so how? Thanks.
-snip- misread [editline]22nd August 2013[/editline] Try this, I've never worked with this hook and this is untested so use at your own risk :P [code] hook.Add("ShouldCollide", "Collisions", function(ent, ent2) if ent:IsPlayer() and ent2:IsVehicle() or ent2:IsPlayer():InVehicle() then return true elseif !ent:IsPlayer() and ent:GetClass() == "prop_physics" and ent2:IsVehicle() or ent2:IsPlayer():InVehicle() then return false else return true end end) [/code]
It would be better to make it so that players do not take damage from the collisions instead of doing a billion custom collision checks. Something like this: [code]hook.Add("PlayerShouldTakeDamage", "PreventCarDM", function(ply, ent) if ent:GetClass() == "my_car_class" or ent:IsVehicle() then return false end return true end)[/code] Oh and for CustomCollision hooks to even work you have to enable them on the entity first with Entity:EnableCustomCollisions(true/false)
Thanks for the replies but... heh where do I add that?
bump
lua/autorun/server/something.lua
Sorry, you need to Log In to post a reply to this thread.