Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //How we freeze things
- local function DoFreeze(stuff, action)
- //Safeguard
- if !stuff || !stuff:IsValid() || !stuff:GetPhysicsObject():IsValid() || stuff:IsPlayer() || stuff:IsWorld() then return end
- //Normal physics
- if action == "Sleep" then stuff:GetPhysicsObject():Sleep() end
- if action == "Wake" then stuff:GetPhysicsObject():Wake() end
- //Ragdoll physics
- if stuff:GetClass() == "prop_ragdoll" || stuff:GetClass() == "prop_vehicle_jeep" then
- for boneindex=1, stuff:GetPhysicsObjectCount() do
- local boneobject = stuff:GetPhysicsObjectNum(boneindex)
- if boneobject then
- if action == "Sleep" then boneobject:Sleep() end
- if action == "Wake" then boneobject:Wake() end
- end
- end
- end
- end
- //How we freeze everything
- local function FreezeEverything_D2K(ply, text)
- //Freeze everything if player says so
- if string.sub(text,1,3) == "!fr" || string.sub(text,1,7) == "!freeze" then
- //Find all entities on the map
- for _, stuff in pairs(ents.GetAll()) do
- //Safeguard
- if stuff && stuff:IsValid() && stuff:GetPhysicsObject():IsValid() && !stuff:IsPlayer() && !stuff:IsWorld() then
- //If not an admin, freeze own ents
- if !ply:IsAdmin() && !ply:IsSuperAdmin() && stuff:GetOwner(ply) then
- //Freeze
- DoFreeze(stuff, "Sleep")
- //Notify player
- ply:ConCommand("play ambient/levels/citadel/portal_beam_shoot3.wav\n")
- end
- //If an admin, freeze everything
- if ply:IsAdmin() || ply:IsSuperAdmin() then
- //Freeze
- DoFreeze(stuff, "Sleep")
- //Notify players
- for i = 1, table.getn(player.GetAll()) do
- player.GetAll()[i]:ConCommand("play ambient/levels/citadel/portal_beam_shoot3.wav\n")
- end
- end
- end
- end
- //Don't print it in chat
- //return "Requesting freezing..."
- return ""
- end
- end
- //Add hook
- hook.Add("PlayerSay", "FreezeEverything_D2K", FreezeEverything_D2K)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement