Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions lua/glide/server/input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Glide.activeInputData = activeData

local EntityMeta = FindMetaTable( "Entity" )
local getTable = EntityMeta.GetTable
local getInternalVariable = EntityMeta.GetInternalVariable

do
local SetNumber = Glide.SetNumber
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions lua/glide/server/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading