Overriding Animations

Hi all,

I’ve been fiddeling around for 4 hours now, and still no result.

I am trying to use another animation for the normal airboat chair that has an animations where the hands are on the steer. The Driver seat is the aitboat seat and the parent is the vehicle. I created a second GetVehicle function to get the custom vehicle entity if the chair has an parent with the class of the vehicle entity.

However, every function I’ve overwritten, every hook I created. Nothing worked.

How can I do this? I just was an airboat seat with a steering animation.

I tried that, made a hook for it, no result.

function GM:HandlePlayerDriving( ply )

    if ( !ply:InVehicle() ) then return false end

    local pVehicle = ply:fGetVehicle()

    if ( !pVehicle.HandleAnimation && pVehicle.GetVehicleClass ) then
        local c = pVehicle:GetVehicleClass()
        local t = list.Get( "Vehicles" )[ c ]
        if ( t && t.Members && t.Members.HandleAnimation ) then
            pVehicle.HandleAnimation = t.Members.HandleAnimation
            pVehicle.HandleAnimation = true -- Prevent this if block from trying to assign HandleAnimation again.

    local class = pVehicle:GetClass()

    if ( isfunction( pVehicle.HandleAnimation ) ) then
        local seq = pVehicle:HandleAnimation( ply )
        if ( seq != nil ) then
            ply.CalcSeqOverride = seq

    if ( ply.CalcSeqOverride == -1 ) then -- pVehicle.HandleAnimation did not give us an animation
        if ( class == "prop_vehicle_jeep" ) then
            ply.CalcSeqOverride = ply:LookupSequence( "drive_jeep" )
        elseif ( class == "prop_vehicle_airboat" ) then
            ply.CalcSeqOverride = ply:LookupSequence( "drive_airboat" )
        elseif ( class == "prop_vehicle_prisoner_pod" && pVehicle:GetModel() == "models/vehicles/prisoner_pod_inner.mdl" ) then
            -- HACK!!
            ply.CalcSeqOverride = ply:LookupSequence( "drive_pd" )
            ply.CalcSeqOverride = ply:LookupSequence( "sit_rollercoaster" )
    hook.Run("HandlePlayerDriving", ply)

    local use_anims = ( ply.CalcSeqOverride == ply:LookupSequence( "sit_rollercoaster" ) || ply.CalcSeqOverride == ply:LookupSequence( "sit" ) )
    if ( use_anims && ply:GetAllowWeaponsInVehicle() && IsValid( ply:GetActiveWeapon() ) ) then
        local holdtype = ply:GetActiveWeapon():GetHoldType()
        if ( holdtype == "smg" ) then holdtype = "smg1" end

        local seqid = ply:LookupSequence( "sit_" .. holdtype )
        if ( seqid != -1 ) then
            ply.CalcSeqOverride = seqid

    return true

hook.Add("HandlePlayerDriving", "Vehicle Animations", function(ply)
    if ( !ply:InVehicle() ) then return false end
    if ( !ply:GetVehicle() ) then return false end

    if ply:fGetVehicle():GetClass() == "special_vehicle" then
        ply.CalcSeqOverride = ply:LookupSequence( "drive_jeep" )

    return true

HandlePlayerDriving is not a valid hook. Your custom hook does not return true in GM:HandlePlayerDriving.

You should never override GM:* methods from addons.

Its not an addon, its a gamemode.

Even when if returns true, nothing happens.

For any smartass who would stumble upon this thread and copy paste the code.

I gave you everything you need to know to do it, if it “doesn’t work” for you, then you are doing it wrong.

I am fiddling for two days now getting this to work, nothing, I repeat nothing works. I am pretty sure that I am not wrong with my codes as I override everything, and it still refuses to do what I told.

How am I even supposed to know if I am right or wrong, or what the problem with this animation story, if I cannot even find a clear documentation or at least get supplied with a working example?

I am a really experienced coder, I now how Garry’s Mod, the source engine and lua works, so there is no point saying that I am doing it wrong or at least threatening me like this. I’m pretty sure that experienced developers are kind to help each other, am I wrong?

hook.Add("CalcMainActivity", "Vehicle Animations", function( ply, vel )
	//if ( ply.MyCustomVehicle ) then
	ply.CalcIdeal = ACT_MP_STAND_IDLE
	ply.CalcSeqOverride = -1
		ply.CalcSeqOverride = ply:LookupSequence( "drive_jeep" )
		return ply.CalcIdeal, ply.CalcSeqOverride
end )

It took me about 60 seconds to whip this out from the code I gave you.

If it stated that it needed to be serverside AND clientside on the Wiki Page I could understand why it didn’t wanted to work.


But it does.