Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. //How we freeze things
  2. local function DoFreeze(stuff, action)
  3.  
  4. //Safeguard
  5. if !stuff || !stuff:IsValid() || !stuff:GetPhysicsObject():IsValid() || stuff:IsPlayer() || stuff:IsWorld() then return end
  6.  
  7. //Normal physics
  8. if action == "Sleep" then stuff:GetPhysicsObject():Sleep() end
  9. if action == "Wake" then stuff:GetPhysicsObject():Wake() end
  10.  
  11. //Ragdoll physics
  12. if stuff:GetClass() == "prop_ragdoll" || stuff:GetClass() == "prop_vehicle_jeep" then
  13. for boneindex=1, stuff:GetPhysicsObjectCount() do
  14. local boneobject = stuff:GetPhysicsObjectNum(boneindex)
  15. if boneobject then
  16. if action == "Sleep" then boneobject:Sleep() end
  17. if action == "Wake" then boneobject:Wake() end
  18. end
  19. end
  20. end
  21.  
  22. end
  23.  
  24.  
  25.  
  26. //How we freeze everything
  27. local function FreezeEverything_D2K(ply, text)
  28.  
  29. //Freeze everything if player says so
  30. if string.sub(text,1,3) == "!fr" || string.sub(text,1,7) == "!freeze" then
  31.  
  32. //Find all entities on the map
  33. for _, stuff in pairs(ents.GetAll()) do
  34.  
  35. //Safeguard
  36. if stuff && stuff:IsValid() && stuff:GetPhysicsObject():IsValid() && !stuff:IsPlayer() && !stuff:IsWorld() then
  37.  
  38. //If not an admin, freeze own ents
  39. if !ply:IsAdmin() && !ply:IsSuperAdmin() && stuff:GetOwner(ply) then
  40.  
  41. //Freeze
  42. DoFreeze(stuff, "Sleep")
  43.  
  44. //Notify player
  45. ply:ConCommand("play ambient/levels/citadel/portal_beam_shoot3.wav\n")
  46.  
  47. end
  48.  
  49. //If an admin, freeze everything
  50. if ply:IsAdmin() || ply:IsSuperAdmin() then
  51.  
  52. //Freeze
  53. DoFreeze(stuff, "Sleep")
  54.  
  55. //Notify players
  56. for i = 1, table.getn(player.GetAll()) do
  57. player.GetAll()[i]:ConCommand("play ambient/levels/citadel/portal_beam_shoot3.wav\n")
  58. end
  59.  
  60. end
  61.  
  62. end
  63. end
  64.  
  65. //Don't print it in chat
  66. //return "Requesting freezing..."
  67. return ""
  68.  
  69. end
  70.  
  71. end
  72.  
  73.  
  74. //Add hook
  75. hook.Add("PlayerSay", "FreezeEverything_D2K", FreezeEverything_D2K)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement