if SERVER then
util.AddNetworkString("PropFreezeSync")
local function FreezeProp(ent)
local phys = ent:GetPhysicsObject()
if IsValid(phys) then
phys:EnableMotion(false)
phys:Sleep()
ent:SetCustomCollisionCheck(true) -
end
end
hook.Add("OnEntityCreated", "PropSetup", function(ent)
if ent:IsValid() and ent:GetClass() == "prop_physics" then
timer.Simple(0, function()
if ent:GetPersistent() then return end
ent:SetNW2Bool("ManagedProp", true)
ent:SetPhysicsAttacker(Entity(0))
end)
end
end)
hook.Add("GravGunPickupAllowed", "CollisionToggle", function(ply, ent)
if ent:GetNW2Bool("ManagedProp") then
ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
ent:EnableCustomCollisions(false)
return true
end
end)
hook.Add("GravGunOnDropped", "FreezeLogic", function(ply, ent)
if ent:GetNW2Bool("ManagedProp") then
ent:SetCollisionGroup(COLLISION_GROUP_NONE)
FreezeProp(ent)
net.Start("PropFreezeSync")
net.WriteEntity(ent)
net.Broadcast()
end
end)
hook.Add("EntityRemoved", "CleanupProps", function(ent)
if ent:GetNW2Bool("ManagedProp") then
ent:SetCollisionGroup(COLLISION_GROUP_NONE)
ent:RemoveAllDecals()
end
end)
end
if CLIENT then
net.Receive("PropFreezeSync", function()
local ent = net.ReadEntity()
if IsValid(ent) then
ent:SetRenderFX(kRenderFxNone) -- Сброс эффектов
end
end)
end