dustyroo

first

Feb 27th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.17 KB | None | 0 0
  1. if SERVER then
  2.     local ranks = { -- Ranks aloud to do things.
  3.     "owner",
  4.     "dev",
  5.     "c_manager",
  6.     "superadmin",
  7.     "admin_liar",
  8.     "admin_deceiver",
  9.     "admin_trickster",
  10.     "admin",
  11.     "mod_liar",
  12.     "mod_deceiver",
  13.     "mod_trickster",
  14.     "mod",
  15.     "trial_mod_liar",
  16.     "trial_mod_deceiver",
  17.     "trial_mod_trickster",
  18.     "trial_mod",
  19.     }
  20.     local freezedelay = 0
  21.     local spawndelay = 0
  22.    
  23.     local function Pprotect()
  24.         --[[for k, v in pairs(ents.GetAll()) do -- freeze all props
  25.             if v:IsValid() then
  26.                 if (v:GetClass() == "prop_physics") then
  27.                     local phys = v:GetPhysicsObject()
  28.                     phys:EnableMotion(false)
  29.                     phys:Sleep()
  30.                 end
  31.             end
  32.         end]]
  33.    
  34.         for k,v in pairs( player.GetAll() ) do -- removes ragdolls
  35.             v:SendLua([[game.RemoveRagdolls()]])
  36.         end
  37.        
  38.         for k, v in ipairs(player.GetAll()) do -- removes decals
  39.             if v:IsValid() then
  40.                 v:ConCommand("r_cleardecals")
  41.             end
  42.         end
  43.     end
  44.     timer.Create("Pprotects", 15, 0, Pprotect)
  45.    
  46.     util.AddNetworkString( "NoR" )
  47.     util.AddNetworkString( "NoNC" )
  48.     util.AddNetworkString( "NoNCT" )
  49.     util.AddNetworkString( "PlayerTrap" )
  50.  
  51.     hook.Add("OnPhysgunReload", "NoNR", function(_, ply) -- cant use r
  52.         if CurTime() < freezedelay then return false end
  53.         net.Start( "NoR" )
  54.         net.Send(ply)
  55.         net.Broadcast()
  56.         freezedelay = CurTime() + 1
  57.         if table.HasValue(ranks, ply:GetNWString("usergroup")) then
  58.             return
  59.         end
  60.         freezedelay = CurTime() + 1
  61.         net.Start( "NoR" )
  62.         net.Send(ply)
  63.         net.Broadcast()
  64.         return false
  65.     end)
  66.  
  67.     hook.Add("OnPhysgunFreeze", "NoTrssp", function(_, _, ent, ply) -- cant prop trap
  68.         if !( ent:GetClass() == "prop_physics" ) then return end
  69.         local lw_center = ent:LocalToWorld(ent:OBBCenter())
  70.         for k ,v in pairs(ents.FindInSphere(lw_center, ( ent:BoundingRadius() + 1 ) )) do
  71.             if v:IsPlayer() and IsValid(v) and ply:GetMoveType() ~= MOVETYPE_NOCLIP then
  72.                 ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
  73.                 ent:SetCustomCollisionCheck(true)
  74.                 net.Start( "PlayerTrap" )
  75.                 net.Send(owner)
  76.                 net.Broadcast()
  77.                 return
  78.             end
  79.         end
  80.         timer.Simple(0.0, function()
  81.             ent:SetCollisionGroup(5)
  82.             ent:SetCustomCollisionCheck(true)
  83.         end)
  84.     end)
  85.      
  86.     hook.Add("PhysgunPickup", "NoPPC", function(ply, ent) -- no prop push or cimb
  87.         if ent:GetModel() == "models/props_lab/keypad.mdl" then
  88.             ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
  89.             ent:SetCustomCollisionCheck(true)
  90.         end
  91.         if !( ent:GetClass() == "prop_physics" ) then return end
  92.         ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
  93.         ent:SetCustomCollisionCheck(true)
  94.         RunConsoleCommand("physgun_maxSpeed", "700")
  95.     end)
  96.  
  97.     hook.Add("PhysgunDrop", "PFreez", function(ply, ent) -- no prop push or cimb
  98.         if !( ent:GetClass() == "prop_physics" ) then return end
  99.  
  100.         local phys = ent:GetPhysicsObject()
  101.         ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
  102.         phys:EnableMotion(false)
  103.         phys:Sleep()
  104.         ent:SetCustomCollisionCheck(true)
  105.     end)
  106.    
  107.     hook.Add("EntityTakeDamage", "AntiDmgss", function(ply,dmg) -- no car/player dammage
  108.         if ( ply:IsValid() and dmg:IsDamageType(16) or dmg:IsDamageType(1) or dmg:IsDamageType(8) ) then
  109.             dmg:ScaleDamage( 0 )
  110.             dmg:SetDamage( 0 )
  111.         end
  112.     end)
  113.  
  114.     hook.Add("ShouldCollide", "NoPCs", function(ent1, ent2) -- no prop crash
  115.       if ( ent1:GetClass() == "prop_physics" ) and ( ent2:GetClass() == "prop_physics" ) then return false end
  116.     end)
  117.    
  118.     hook.Add("CanProperty", "NoCRN", function(ply, property, ent) -- cant use no collide on cars
  119.         if !( property == "collision" and ent:GetClass() == "prop_physics" ) then return end
  120.        
  121.         if table.HasValue(ranks, ply:GetNWString("usergroup")) then
  122.             return
  123.         end
  124.        
  125.         local lw_center = ent:LocalToWorld(ent:OBBCenter())
  126.         for k ,v in pairs(ents.FindInSphere(lw_center, ( ent:BoundingRadius() + 1 ) )) do
  127.             if v:IsPlayer() and IsValid(v) and ply:GetMoveType() ~= MOVETYPE_NOCLIP then
  128.                 ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
  129.                 ent:SetCustomCollisionCheck(true)
  130.                 net.Start( "NoNC" )
  131.                 net.Send(ply)
  132.                 net.Broadcast()
  133.                 return false
  134.             end
  135.         end
  136.         return
  137.     end)
  138.    
  139.     hook.Add("CanTool", "IDontThinkYouCanStopThis", function(ply, tr, tool, ent) -- cant use no collide on cars
  140.         if !( tool == "nocollide" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_physics" ) then return end
  141.         if table.HasValue(ranks, ply:GetNWString("usergroup")) then
  142.             return
  143.         end
  144.         net.Start( "NoNCT" )
  145.         net.Send(ply)
  146.         net.Broadcast()
  147.         return false
  148.     end)
  149.  
  150.     hook.Add("PlayerSpawnedProp", "PPcrash", function(ply, _, ent) -- no prop crash
  151.         if !( ent:GetClass() == "prop_physics" ) then return end
  152.         if CurTime() < spawndelay then return false end
  153.        
  154.         local phys = ent:GetPhysicsObject()
  155.         ent:SetHealth(99999*99)
  156.         phys:EnableMotion(false)
  157.         phys:Sleep()
  158.         ent:SetCustomCollisionCheck(true)
  159.  
  160.         owner = ply
  161.         local lw_center = ent:LocalToWorld(ent:OBBCenter())
  162.         for k ,v in pairs(ents.FindInSphere(lw_center, ( ent:BoundingRadius() + 5 ) )) do
  163.             if v:IsPlayer() and IsValid(v) and ply:GetMoveType() ~= MOVETYPE_NOCLIP then
  164.                 local o = v:GetOwner()
  165.                 ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
  166.                 ent:SetCustomCollisionCheck(true)
  167.                 net.Start( "PlayerTrap" )
  168.                 net.Send(owner)
  169.                 net.Broadcast()
  170.                 return
  171.             end
  172.         end
  173.         ent:SetCollisionGroup(5)
  174.         freezedelay = CurTime() + 1
  175.     end)
  176.    
  177.     hook.Add( "PlayerNoClip", "FeelFreeToTurnItOff", function( ply, desiredState )
  178.         if ( desiredState == false ) then -- the player wants to turn noclip off
  179.             return true -- always allow
  180.         elseif table.HasValue(ranks, ply:GetNWString("usergroup")) then
  181.             return true
  182.         end
  183.     end)
  184. end
  185.    
  186. if CLIENT then
  187.     net.Receive( "PlayerTrap", function()
  188.      notification.AddLegacy( "You can not freeze a prop inside a player!", 1, 4)
  189.     end )
  190.     net.Receive( "NoR", function()
  191.      notification.AddLegacy( "Please wait before Unfreezing again!", 1, 2)
  192.     end )
  193.     net.Receive( "NoNC", function()
  194.      notification.AddLegacy( "You can not no-collide a prop inside a player!", 1, 4)
  195.     end )
  196.      net.Receive( "NoNCT", function()
  197.      notification.AddLegacy( "Use no-collide in c menu!", 1, 4)
  198.     end )
  199. end
  200.    
  201. --[[
  202.   TO DO LIST:
  203.   https://wiki.garrysmod.com/page/GM/PlayerUnfrozeObject
  204.   make tools auto freeze owners props shit
  205.   ]]
Advertisement
Add Comment
Please, Sign In to add comment