From e3e3b11739e89f905cc2004412643c36ed197c3e Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sat, 11 Apr 2026 01:24:51 +0200 Subject: [PATCH 1/2] Implement vehicle ejection functionality and update seat switch logic --- lua/glide/server/input.lua | 13 ++----------- lua/glide/server/util.lua | 13 +++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lua/glide/server/input.lua b/lua/glide/server/input.lua index 01414011..bef5e6a8 100644 --- a/lua/glide/server/input.lua +++ b/lua/glide/server/input.lua @@ -179,19 +179,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 vehicle:GetInternalVariable( "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 From 640241d864aa38ea6a36c030eb94d96549c3f63d Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sat, 11 Apr 2026 01:29:01 +0200 Subject: [PATCH 2/2] Cache the getInternalVariable function --- lua/glide/server/input.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/glide/server/input.lua b/lua/glide/server/input.lua index bef5e6a8..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,7 +180,7 @@ 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 ) and not vehicle:GetInternalVariable( "m_bLocked" ) and button ~= KEY_1 then + if ply:KeyDown( IN_WALK ) and not getInternalVariable( vehicle, "m_bLocked" ) and button ~= KEY_1 then if ply ~= vehicle:GetDriver() then return end Glide.EjectPlayer( vehicle, SEAT_SWITCH_BUTTONS[button] )