diff --git a/lua/glide/server/input.lua b/lua/glide/server/input.lua index 01414011..0d76b374 100644 --- a/lua/glide/server/input.lua +++ b/lua/glide/server/input.lua @@ -8,6 +8,7 @@ Glide.activeInputData = activeData local EntityMeta = FindMetaTable( "Entity" ) local getTable = EntityMeta.GetTable +local getInternalVariable = EntityMeta.GetInternalVariable do local SetNumber = Glide.SetNumber @@ -179,19 +180,10 @@ local function HandleInput( ply, button, active, pressed ) -- Is this a "switch seat" button? if pressed and SEAT_SWITCH_BUTTONS[button] then -- Let the driver lock the vehicle - if ply:KeyDown( IN_WALK ) then + if ply:KeyDown( IN_WALK ) and not getInternalVariable( vehicle, "m_bLocked" ) and button ~= KEY_1 then if ply ~= vehicle:GetDriver() then return end - if Glide.CanLockVehicle( ply, vehicle ) then - vehicle:SetLocked( not vehicle:GetIsLocked() ) - else - Glide.SendNotification( ply, { - text = "#glide.notify.lock_denied", - icon = "materials/icon16/cancel.png", - sound = "glide/ui/radar_alert.wav", - immediate = true - } ) - end + Glide.EjectPlayer( vehicle, SEAT_SWITCH_BUTTONS[button] ) else Glide.SwitchSeat( ply, SEAT_SWITCH_BUTTONS[button] ) end diff --git a/lua/glide/server/util.lua b/lua/glide/server/util.lua index 9f34f494..1eb5afa9 100644 --- a/lua/glide/server/util.lua +++ b/lua/glide/server/util.lua @@ -265,6 +265,19 @@ function Glide.SwitchSeat( ply, seatIndex ) hook.Run( "Glide_PostSwitchSeat", ply, seatIndex ) end +-- Eject the player from the vehicle +function Glide.EjectPlayer( vehicle, seatIndex ) + local seat = vehicle.seats[seatIndex] + if not IsValid( seat ) then return end + + local driver = seat:GetDriver() + if not IsValid( driver ) then return end + + driver:ExitVehicle() + driver:SetAllowWeaponsInVehicle( false ) +end + + --- Finds and returns all human players near a certain position. function Glide.GetNearbyPlayers( pos, radius ) radius = radius * radius