Skip to content
Closed
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
30 changes: 30 additions & 0 deletions lua/glide/sh_player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading