Airboat Gun

So apparently firing the airboat gun while a client is connecting causes the server to crash. I was recommended the PlayerSpawnedVehicle hook in order to prevent turret-mounted vehicles from firing, but with little personal knowledge of Lua, I don’t know how I can implement such a hook. Can someone here please help me sort this issue?

You’ll also want to be able to disable the turret on Jeeps. I’m sure someone has an infinitely better way of doing this, but here’s the approach I take:

--[[ The airboat and jeep turret are known to crash the server when being fired during PlayerInitialSpawn. This disables them. ]]

-- If any of these vehicles are spawned, we need to disable their turrets.
    prop_vehicle_jeep       = true,
    prop_vehicle_jeep_old   = true,
    prop_vehicle_airboat    = true
hook.Add( "PlayerSpawnedVehicle", "DisableVehicleTurrets", function( ply, vehicle )

    if ( BLOCK_TURRET[vehicle:GetClass()] ) then
        vehicle:Fire( "EnableGun", "false" ) -- Disables the vehicle from being able to fire the turret

end )

You can just create some arbitarily-named file like “DisableVehicleTurrets.lua” and place it in your server’s garrysmod/lua/autorun/ directory (or if you want it as an addon, addons/DisableVehicleTurrets/lua/autorun/DisableVehicleTurrets.lua)

I hope that helps! It was becoming a rather annoying problem on my server as well.

Thanks for your reply, however this solution did not appear to help in my case. Now the server simply crashes whenever the airboat gun is fired at all.