diff --git a/lua/entities/base_glide/init.lua b/lua/entities/base_glide/init.lua index 6540a77c..46224b84 100644 --- a/lua/entities/base_glide/init.lua +++ b/lua/entities/base_glide/init.lua @@ -482,7 +482,7 @@ do if blocked then -- We're cooked... - pos = seat:GetPos() + pos = cvars.Bool( "glide_always_exit_vehicle", true ) and seat:GetPos() or false else -- Put the exit position on the ground traceData.start = pos diff --git a/lua/glide/server/events.lua b/lua/glide/server/events.lua index 1ab749d7..cf63e1ca 100644 --- a/lua/glide/server/events.lua +++ b/lua/glide/server/events.lua @@ -58,6 +58,33 @@ hook.Add( "PlayerEnteredVehicle", "Glide.OnEnterSeat", function( ply, seat ) hook.Run( "Glide_OnEnterVehicle", ply, parent, seatIndex ) end ) +local always_exit_vehicle = CreateConVar( "glide_always_exit_vehicle", "1", { FCVAR_ARCHIVE, FCVAR_REPLICATED }, "If this option is enabled, players always exit GLide vehicles at the most appropriate exit point, even if it is considered 'blocked.'" ) +hook.Add( "CanExitVehicle", "Glide.CheckExitVehicle", function( seat, ply ) + if not ply.IsUsingGlideVehicle then return end + if always_exit_vehicle:GetBool() then return end + + local seatIndex = seat.GlideSeatIndex + if not seatIndex then return end + + local vehicle = seat:GetParent() + if not IsValid( vehicle ) then return end + if not vehicle.IsGlideVehicle then return end + + local exitPos = vehicle:GetSeatExitPos( seatIndex ) + if not exitPos then + Glide.SendNotification( ply, { + text = "#glide.notify.exit_blocked", + icon = "materials/glide/icons/locked.png", + sound = "glide/ui/radar_alert.wav", + immediate = true + } ) + + return false + end + + ply.exitPosGlide = exitPos +end ) + -- Once a player leaves a Glide vehicle, cleanup network variables -- and trigger the `Glide_OnExitVehicle` hook. hook.Add( "PlayerLeaveVehicle", "Glide.OnExitSeat", function( ply, seat ) @@ -80,7 +107,7 @@ hook.Add( "PlayerLeaveVehicle", "Glide.OnExitSeat", function( ply, seat ) ply:SetAllowWeaponsInVehicle( false ) if IsValid( vehicle ) then - ply:SetPos( vehicle:GetSeatExitPos( seatIndex ) ) + ply:SetPos( not always_exit_vehicle:GetBool() and istable( ply.exitPosGlide ) and ply.exitPosGlide or vehicle:GetSeatExitPos( seatIndex ) ) ply:SetVelocity( vehicle:GetPhysicsObject():GetVelocity() ) ply:SetEyeAngles( Angle( 0, vehicle:GetAngles().y, 0 ) ) end diff --git a/resource/localization/en/glide_vehicles.properties b/resource/localization/en/glide_vehicles.properties index 29e406e7..fe035301 100644 --- a/resource/localization/en/glide_vehicles.properties +++ b/resource/localization/en/glide_vehicles.properties @@ -192,6 +192,7 @@ glide.swep.homing_launcher.desc=Hold right mouse to lock on Glide vehicles. # Notifications +glide.notify.exit_blocked=You cannot exit the vehicle because the exit is blocked! glide.notify.lock_denied=You do not have permission to lock/unlock this vehicle. glide.notify.vehicle_locked=This vehicle has been locked, only the vehicle creator and friends can enter it. glide.notify.vehicle_unlocked=This vehicle has been unlocked, anyone can enter it. diff --git a/resource/localization/es-es/glide_vehicles.properties b/resource/localization/es-es/glide_vehicles.properties index edcfd579..68fd5d62 100644 --- a/resource/localization/es-es/glide_vehicles.properties +++ b/resource/localization/es-es/glide_vehicles.properties @@ -193,6 +193,7 @@ glide.swep.homing_launcher.desc=Mantén presionado el botón derecho del ratón # Notificaciones +glide.notify.exit_blocked=No puedes salir del vehículo porque la salida está bloqueada. glide.notify.lock_denied=No tienes permiso para bloquear/desbloquear este vehículo. glide.notify.vehicle_locked=Este vehículo ha sido bloqueado, solo el creador del vehículo y sus amigos pueden entrar. glide.notify.vehicle_unlocked=Este vehículo ha sido desbloqueado, cualquiera puede entrar. diff --git a/resource/localization/fr/glide_vehicles.properties b/resource/localization/fr/glide_vehicles.properties index a0acac92..d67c4956 100644 --- a/resource/localization/fr/glide_vehicles.properties +++ b/resource/localization/fr/glide_vehicles.properties @@ -193,6 +193,7 @@ glide.swep.homing_launcher.desc=Maintenez le clic droit pour verrouiller les vé # Notifications +glide.notify.exit_blocked=Vous ne pouvez pas sortir du véhicule car la sortie est bloquée ! glide.notify.lock_denied=Vous n'avez pas la permission de verrouiller/déverrouiller ce véhicule. glide.notify.vehicle_locked=Ce véhicule a été verrouillé, seuls le créateur et ses amis peuvent y entrer. glide.notify.vehicle_unlocked=Ce véhicule a été déverrouillé, tout le monde peut y entrer.