• Vehicle dmg to driver?
    2 replies, posted
I want to make it so that when a car gets shot, dmg goes to player, anyone know how I can do this?
Using [lua]bullet.Callback = function( attacker, tr, dmginfo ) return self:BulletCallback( attacker, tr, dmginfo ); end[/lua] It'll give you information such as the path of the bullet, the entity it hit, etc etc.. You can either use that to damage the driver, all passengers, calculate the trajectory and determine if a player is in the way and only injure them.. etc.
Would [code] if (entity:GetClass() == "prop_vehicle_jeep") then if IsValid(entity:GetDriver()) then entity:GetDriver():TakeDamage(amount * .6, attacker, inflictor) end end [/code] work if I place is it EntityTakeDamage? EDIT: Doesn't work. TakeDamage doesn't work if player is inside a vehicle. I had to manually SetHeath, then check if <= 0 and call DoPlayerDeath and PlayerDeath hooks.
Sorry, you need to Log In to post a reply to this thread.