diff --git a/lua/glide/sh_player.lua b/lua/glide/sh_player.lua index 2e027a7d..75693c2c 100644 --- a/lua/glide/sh_player.lua +++ b/lua/glide/sh_player.lua @@ -96,4 +96,34 @@ if SERVER then ply.GlideCameraAngles = angles ply.GlideCameraAimPos = EntEyePos( ply ) + angles:Forward() * cmd:GetUpMove() end, HOOK_HIGH ) + + local function CheckInVehicleGlide( ply ) + if not IsValid( ply ) or not ply:IsPlayer() then return false end + + local vehicle = GetNWEntity( ply, "GlideVehicle", NULL ) + return IsValid( vehicle ) + end + + if sam then + local freeze_player = function( ply ) + if SERVER then + ply:Lock() + end + ply:SetMoveType( MOVETYPE_NONE ) + ply:SetCollisionGroup( COLLISION_GROUP_WORLD ) + end + + sam.hook_first( "PhysgunPickup", "SAM.CanPhysgunPlayer", function( ply, target ) + if sam.type( target ) == "Player" and ply:HasPermission( "can_physgun_players" ) and ply:CanTarget( target ) and not CheckInVehicleGlide( target ) then + freeze_player( target ) + return true + end + end ) + else + hook.Add( "PhysgunPickup", "Glide.PhysgunPickup", function( _, ent ) + if not CheckInVehicleGlide( ent ) then return end + + return false + end, HOOK_HIGH ) + end end