Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- local ranks = { -- Ranks aloud to do things.
- "owner",
- "dev",
- "c_manager",
- "superadmin",
- "admin_liar",
- "admin_deceiver",
- "admin_trickster",
- "admin",
- "mod_liar",
- "mod_deceiver",
- "mod_trickster",
- "mod",
- "trial_mod_liar",
- "trial_mod_deceiver",
- "trial_mod_trickster",
- "trial_mod",
- }
- local freezedelay = 0
- local spawndelay = 0
- local function Pprotect()
- --[[for k, v in pairs(ents.GetAll()) do -- freeze all props
- if v:IsValid() then
- if (v:GetClass() == "prop_physics") then
- local phys = v:GetPhysicsObject()
- phys:EnableMotion(false)
- phys:Sleep()
- end
- end
- end]]
- for k,v in pairs( player.GetAll() ) do -- removes ragdolls
- v:SendLua([[game.RemoveRagdolls()]])
- end
- for k, v in ipairs(player.GetAll()) do -- removes decals
- if v:IsValid() then
- v:ConCommand("r_cleardecals")
- end
- end
- end
- timer.Create("Pprotects", 15, 0, Pprotect)
- util.AddNetworkString( "NoR" )
- util.AddNetworkString( "NoNC" )
- util.AddNetworkString( "NoNCT" )
- util.AddNetworkString( "PlayerTrap" )
- hook.Add("OnPhysgunReload", "NoNR", function(_, ply) -- cant use r
- if CurTime() < freezedelay then return false end
- net.Start( "NoR" )
- net.Send(ply)
- net.Broadcast()
- freezedelay = CurTime() + 1
- if table.HasValue(ranks, ply:GetNWString("usergroup")) then
- return
- end
- freezedelay = CurTime() + 1
- net.Start( "NoR" )
- net.Send(ply)
- net.Broadcast()
- return false
- end)
- hook.Add("OnPhysgunFreeze", "NoTrssp", function(_, _, ent, ply) -- cant prop trap
- if !( ent:GetClass() == "prop_physics" ) then return end
- local lw_center = ent:LocalToWorld(ent:OBBCenter())
- for k ,v in pairs(ents.FindInSphere(lw_center, ( ent:BoundingRadius() + 1 ) )) do
- if v:IsPlayer() and IsValid(v) and ply:GetMoveType() ~= MOVETYPE_NOCLIP then
- ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
- ent:SetCustomCollisionCheck(true)
- net.Start( "PlayerTrap" )
- net.Send(owner)
- net.Broadcast()
- return
- end
- end
- timer.Simple(0.0, function()
- ent:SetCollisionGroup(5)
- ent:SetCustomCollisionCheck(true)
- end)
- end)
- hook.Add("PhysgunPickup", "NoPPC", function(ply, ent) -- no prop push or cimb
- if ent:GetModel() == "models/props_lab/keypad.mdl" then
- ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
- ent:SetCustomCollisionCheck(true)
- end
- if !( ent:GetClass() == "prop_physics" ) then return end
- ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
- ent:SetCustomCollisionCheck(true)
- RunConsoleCommand("physgun_maxSpeed", "700")
- end)
- hook.Add("PhysgunDrop", "PFreez", function(ply, ent) -- no prop push or cimb
- if !( ent:GetClass() == "prop_physics" ) then return end
- local phys = ent:GetPhysicsObject()
- ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
- phys:EnableMotion(false)
- phys:Sleep()
- ent:SetCustomCollisionCheck(true)
- end)
- hook.Add("EntityTakeDamage", "AntiDmgss", function(ply,dmg) -- no car/player dammage
- if ( ply:IsValid() and dmg:IsDamageType(16) or dmg:IsDamageType(1) or dmg:IsDamageType(8) ) then
- dmg:ScaleDamage( 0 )
- dmg:SetDamage( 0 )
- end
- end)
- hook.Add("ShouldCollide", "NoPCs", function(ent1, ent2) -- no prop crash
- if ( ent1:GetClass() == "prop_physics" ) and ( ent2:GetClass() == "prop_physics" ) then return false end
- end)
- hook.Add("CanProperty", "NoCRN", function(ply, property, ent) -- cant use no collide on cars
- if !( property == "collision" and ent:GetClass() == "prop_physics" ) then return end
- if table.HasValue(ranks, ply:GetNWString("usergroup")) then
- return
- end
- local lw_center = ent:LocalToWorld(ent:OBBCenter())
- for k ,v in pairs(ents.FindInSphere(lw_center, ( ent:BoundingRadius() + 1 ) )) do
- if v:IsPlayer() and IsValid(v) and ply:GetMoveType() ~= MOVETYPE_NOCLIP then
- ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
- ent:SetCustomCollisionCheck(true)
- net.Start( "NoNC" )
- net.Send(ply)
- net.Broadcast()
- return false
- end
- end
- return
- end)
- hook.Add("CanTool", "IDontThinkYouCanStopThis", function(ply, tr, tool, ent) -- cant use no collide on cars
- if !( tool == "nocollide" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_physics" ) then return end
- if table.HasValue(ranks, ply:GetNWString("usergroup")) then
- return
- end
- net.Start( "NoNCT" )
- net.Send(ply)
- net.Broadcast()
- return false
- end)
- hook.Add("PlayerSpawnedProp", "PPcrash", function(ply, _, ent) -- no prop crash
- if !( ent:GetClass() == "prop_physics" ) then return end
- if CurTime() < spawndelay then return false end
- local phys = ent:GetPhysicsObject()
- ent:SetHealth(99999*99)
- phys:EnableMotion(false)
- phys:Sleep()
- ent:SetCustomCollisionCheck(true)
- owner = ply
- local lw_center = ent:LocalToWorld(ent:OBBCenter())
- for k ,v in pairs(ents.FindInSphere(lw_center, ( ent:BoundingRadius() + 5 ) )) do
- if v:IsPlayer() and IsValid(v) and ply:GetMoveType() ~= MOVETYPE_NOCLIP then
- local o = v:GetOwner()
- ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
- ent:SetCustomCollisionCheck(true)
- net.Start( "PlayerTrap" )
- net.Send(owner)
- net.Broadcast()
- return
- end
- end
- ent:SetCollisionGroup(5)
- freezedelay = CurTime() + 1
- end)
- hook.Add( "PlayerNoClip", "FeelFreeToTurnItOff", function( ply, desiredState )
- if ( desiredState == false ) then -- the player wants to turn noclip off
- return true -- always allow
- elseif table.HasValue(ranks, ply:GetNWString("usergroup")) then
- return true
- end
- end)
- end
- if CLIENT then
- net.Receive( "PlayerTrap", function()
- notification.AddLegacy( "You can not freeze a prop inside a player!", 1, 4)
- end )
- net.Receive( "NoR", function()
- notification.AddLegacy( "Please wait before Unfreezing again!", 1, 2)
- end )
- net.Receive( "NoNC", function()
- notification.AddLegacy( "You can not no-collide a prop inside a player!", 1, 4)
- end )
- net.Receive( "NoNCT", function()
- notification.AddLegacy( "Use no-collide in c menu!", 1, 4)
- end )
- end
- --[[
- TO DO LIST:
- https://wiki.garrysmod.com/page/GM/PlayerUnfrozeObject
- make tools auto freeze owners props shit
- ]]
Advertisement
Add Comment
Please, Sign In to add comment