How to make player in vehicle shoot

So I got a player who’s sitting in a seat (prop_vehicle_prisoner_pod) and I want him to be able to see his view model, shoot, reload and toggle ironsights. So far I got the view model visible using ply:DrawViewModel(true) after entering the seat.

I was able to make the player shoot using this in a shared script:

local function KeyPress(ply, key)
    if ply:InVehicle() and IsValid(ply:GetActiveWeapon()) then
        local wep = ply:GetActiveWeapon()
        if key == IN_ATTACK then
        elseif key == IN_ATTACK2 then
        elseif key == IN_RELOAD then
        return true
hook.Add( "KeyPress", "Vehicle.KeyPress", KeyPress)

But the secondary attack does nothing and when the clip runs empty, it plays the reload animation without actually reloading.
Pressing reload manually does the same thing. Also the primary attack and reload don’t seem to take their delays into account.

Can somebody tell me if it can be done like this or there’s some other way?

Not entirely sure if there is an easy good way to do this.

I’m wondering how you managed to get the weapon to draw while the player is in the seat because ply:DrawViewModel( true ) does not work.

I’m guessing it shouldn’t actually work, but it does:

You can even see the edge of the airboat seat I’m sitting in.

Yeah that’s strange. It doesn’t work at all for me, are you using a weapon pack? If so, which one?

No packs, the weapon base is copied from TTT with the TTT-specific stuff removed.

I forgot to mention that you need to use primary attack once for it to show, as your weapon is holstered when you enter a vehicle.

ply:GetActiveWeapon():SendWeaponAnim(ACT_VM_IDLE) works too.

[editline]22nd November 2012[/editline]

It seems what I’m trying to do isn’t possible until Garry hooks CBasePlayer::UsingStandardWeaponsInVehicle( void )

This seems like a very interesting topic, could be very cool for weapon support in vehicles.

There are also many good uses for it? For example, Drive-Bys. =D

The gamemode I’m making mostly resembles All Points Bulletin, but in first person so it’s kind of like CS gamemodes(VIP, bomb plant, etc) with cars. Drive-bys are going to be important.

So what am I supposed to do? Post a request for the hook in the Developments subforum?

Take a look at this (dl)

Used to work pretty well and the players could shoot while riding it. Was easy to make an airboat seat out of it when it did work back in 12 but parenting seems different in 13.

I tried parenting before moving to airboat seats. The less entities, the better. Unfortunately parenting players to a car didn’t work, as the player didn’t move with the car reliably, usually never unless you hit a wall or something. Constantly updating the position was laggy.
Looking at the Valve docs about parenting, it said that moving with parents only works on physics entities. Initializing VPhysics on the player did fix the parenting issue, but that seemed to break a bunch of other stuff.