Take Damage while seated

Is there any addon or script that makes it so when players are sitting they can still receive damage? If so please post a link or code, thanks :slight_smile:

Check out the sticky for requesting work to be done: Coderhire.com

Anyways, if you are trying to make this functionality, I’d be happy to discuss some ways to solve the question. But you’ve got to put some effort into trying to make it for the purpose of the Developer Forum.

You could try coding a bullet callback function that detects if it hit a vehicle/chair and then detects the rotation of the chair, the attachment point and solve for hitbox collision.

I really really really wish i could do that :frowning: But i have just started learning lua and its really beating me… I just can’t seem to understand how certain things work. Thats why i posted it under help… Sorry i can’t :confused: even though i would really like to.

Vehicles do not fire EntityTakeDamage. When hit by a vehicle/taking damage from hitting something while inside a vehicle it doesn’t fire it either. Vehicles are basically one huge invincibility box (except for collisions with seats, and the jeep’s collisions/getting shot).
C-side weapons (the default HL2 weapons) will need some major hackery to detect bullets (because they use C-side functions, not Lua).
Trust me, I’ve tried all this before. If it’s possible it’s hugely difficult and not really worth the effort.
It would probably be easier to beg garry to do it.

Well then how does VC-Mod do it? And thank you for the insight, maybe we should start some thing to give to garry about this issue because this is a big issue especially in RP gamemodes. But i’ll talk to freemann about it because he probably has a pretty good idea of it too.

Here’s a start to at least detect if a bullet hits a car. You can use the Bullet Callback to do that, and apply damage to the entire vehicle, or to occupants, or solve for hitboxes in the path of the bullet.
[lua] local bullet = {
Num = 1;
Src = self.Owner:GetShootPos();
Dir = self.Owner:GetAimVector();
Spread = Vector( 0, 0, 0 );
Tracer = 1;
Force = 1;
Damage = 150;
AmmoType = “Pistol”;
Callback = function( attacker, tr, dmginfo ) return BulletCallback( attacker, tr, dmginfo ) end // This is the callback function

[lua]function BulletCallback( attacker, tr, dmginfo )
print( attacker )
PrintTable( tr )
–PrintDamageInfo( dmginfo ) // Custom DAMAGE REPORT: to IsBulletDamage text output function
print( "MatType: ", tr.MatType )
print( "MATERIALS: ", MATERIALS[ tr.MatType ] )
print( "Texture: ", tr.HitTexture )

LuaPinapple or somebody made a mod that does this and it also let you shoot while sitting. Try searching garrysmod.org

why does no one tell me these things

But it still doesn’t solve for the standard HL2 C++ weapons, and doesn’t solve for other SWEPs.
Though, what if… Make an addon to overwrite weapon_base, maybe? Then remake the standard HL2 weapons as SWEPs. This would allow the few bugs present there to be fixed, and for new features that could be used on all SWEPs to be used…

[editline]27th April 2013[/editline]

A friend of mine did the “shoot while sitting” thing just recently too.

[editline]27th April 2013[/editline]

What is VC-Mod?

Vc-mod or Vehicle control mod, is an addon that overhauls every vehicle in the game. Very very very realistic. Dirt from tires, windshield wipers, lights, multiple seats, headlights rear lights, gas, car locking, car damage, everything. And the damage is also windows breaking, and such. Also doors should actually open and all that. But some features will only work with cars specifically made for this mod. He said he is also working on being able to shoot out of cars. But that will be in a later release. For the release date however, i talked to freemmann today and he said that alot of it is done, but due to him being in college and his project being due tomorrow, he has been working on that. My guess is 1-3 months until it gets released. Hope i helped.

There is a video that shows off a really neat damage system to cars:

LOL Thank you for the video from him. I spent forever trying to describe it, and istead you can just watch the video :stuck_out_tongue:

I thought it got abandoned long ago.

No, I talk to freemmann on almost a daily basis and yeah its goin pretty well

Can’t wait for that damage system to be released. I’m personally working on a new passenger seating system for my vehicle mod which removes the necessity to have people “sit” in chairs ( Less entities the better ). This also means that they can be hit without modifying anything else aside from coding penetration if they’re inside a vehicle :slight_smile:

I just need to figure out a few more things, namely locking down the rear-end to the chair so it can’t move. It also enables shooting from a seated position too, but the animations are non-existent ( Maybe I can convince Max to code those in… ).

I remember now. I believe it was Kogitsune that made this mod.

For some reason this does not work with TDM cars? can any help me out? Im also getting this error: [ERROR] lua/autorun/server/damagecar.lua:3: attempt to index global ‘self’ (a nil value)

  1. unknown - lua/autorun/server/damagecar.lua:3