Hey people, recently i’ve stumbled upon a problem with the AddCallback function.
I am currently working on a custom damage system for vehicles in my upcoming gamemode and have got it working… mostly. I don’t want it having damage caused by players running around the roof of a car which it currently does.
But the problem comes from the collisiondata.HitEntity returning nil which prevents me from checking the damage inflictor when collision is called.
Here’s my callback
And… my actual function
CGRP.VehicleCollide = function(ent,coldata,physobj) for k,v in pairs(player.GetAll()) do v:PrintMessage(HUD_PRINTTALK,tostring(coldata.HitEntity)) end if ent:GetVelocity():Length()/100<=10 and ent:WorldToLocal(coldata["HitPos"]).z>15 then local physobj = ent:GetPhysicsObject() local Mass = physobj:GetMass() if ent["Damage"]~=nil then ent["Damage"] = math.Clamp(ent["Damage"] - coldata["OurOldVelocity"]:Length()/100*(Mass/1500),0,100) if ent["Damage"]<=0 and ent["Tog"] then ent["Tog"]=false ent["Broken"]=true ent:Fire("turnoff") end end if ent["Damage"]<=80 then ent["Smoking"]=true else ent["Smoking"]=false end if ent["Damage"]>0 then ent["Broken"]=false else ent["Broken"]=true end end end
The PrintMessage piece is just to test the HitEntity which is still returning nil and I noticed it was on the github a while back for being fixed, which it seems not.