Alright, so I need alittle help. As some know, the body physics in Gmod are messed up, especially in TTT, and when a body goes berserk, it CAN crash your server. Well this is happening to me. I have the force limiter(see code below) but it doesn't quite do the job, the server still has a tendency to crash, especially when many bodies hit a certain force. I was hoping you guys could help me(As well as other servers having this issue.)
Any help is appreciated.
[CODE]local freezespeed = 2700
local removespeed = 7000
hook.Add("Think","AMB_CrashCatcher",function()
for k, ent in pairs(ents.FindByClass("prop_ragdoll")) do
if IsValid(ent) then
if ent.player_ragdoll then
local velo = ent:GetVelocity( ):Length()
local ply = false
if IsValid(ent:GetOwner()) then
ply = ent:GetOwner()
end
if velo >= removespeed then
if ply != false then
game.ConsoleCommand("ulx slay \"" .. ply:GetName() .. "\" \n")
PrintMessage(HUD_PRINTTALK, "[Autoslay] " .. ply:GetName() .. " was slayed for trying to exploit the ragdoll removal glitch.")
end
ent:Remove()
ServerLog("[!CRASHCATCHER!] Caught ragdoll entity moving too fast ("..velo.."), removing offending ragdoll entity from world.\n")
local messageToShow = "[CRASH PREVENTION] A ragdoll was removed to prevent server crashing. It was "
if CORPSE.GetFound(ent, true) then
PrintMessage(HUD_PRINTTALK, messageToShow .. "an unID'd body.")
else
PrintMessage(HUD_PRINTTALK, messageToShow .. ent:GetNWString("nick") .. "'s body.")
end
elseif velo >= freezespeed then
AMB_KillVelocity(ent)
ServerLog("[!CRASHCATCHER!] Caught ragdoll entity moving too fast ("..velo.."), disabling motion. \n")
end
end
end
end
end)
function AMB_SetSubPhysMotionEnabled(ent, enable)
if not IsValid(ent) then return end
ent:SetVelocity(vector_origin)
if !(enable) then
ent:SetColor(Color(255,0,255,255))
else
ent:SetColor(Color(255,255,255,255))
end
if !(enable) then
if IsValid(ent:GetOwner()) then
ent:GetOwner():GetWeapon("weapon_zm_carry"):Reset(false)
end
--ent:SetPos(ent:GetPos()+Vector(0,0,50))
end
for i=0, ent:GetPhysicsObjectCount()-1 do
local subphys = ent:GetPhysicsObjectNum(i)
if IsValid(subphys) then
subphys:EnableMotion(enable)
if !(enable) then
subphys:SetVelocity(vector_origin)
subphys:SetMass(subphys:GetMass()*20)
end
if enable then
subphys:SetMass(subphys:GetMass()/20)
subphys:Wake()
end
end
end
ent:SetVelocity(vector_origin)
end
function AMB_KillVelocity(ent)
AMB_SetSubPhysMotionEnabled(ent, false)
timer.Simple(3, function() AMB_SetSubPhysMotionEnabled(ent, true) end)
end[/CODE]
First of all I'd like to apologize for everyone else on this site. It takes some work to get the helpful people out of the woodwork.
Un/Fortunately we have had a similar issue on our server and we know how to fix it... but it creates problems all on its own. Not server crashing problems but people exploiting our fix to hide bodies. You can find all the code we used to fix the glitch and a discussion on fixing the secondary problems
[URL="http://facepunch.com/showthread.php?t=1353069"]here by clicking on these blue words.[/URL]
Hi. That's DarthTealc's and my script. I understand it's not totally efficient, but you can modify the remove/freeze speed if it still has a tendency of crashing.
[QUOTE=Galactic;43662601]First of all I'd like to apologize for everyone else on this site. It takes some work to get the helpful people out of the woodwork.
Un/Fortunately we have had a similar issue on our server and we know how to fix it... but it creates problems all on its own. Not server crashing problems but people exploiting our fix to hide bodies. You can find all the code we used to fix the glitch and a discussion on fixing the secondary problems
[URL="http://facepunch.com/showthread.php?t=1353069"]here by clicking on these blue words.[/URL][/QUOTE]
Is that one alittle more useful than the current one I use?
[editline]25th January 2014[/editline]
[QUOTE=code_gs;43663019]Hi. That's DarthTealc's and my script. I understand it's not totally efficient, but you can modify the remove/freeze speed if it still has a tendency of crashing.[/QUOTE]
I've changed 100 different numbers and nothing seems to help when multiple bodies are hit by, say, c4, or something that causes force.
[editline]25th January 2014[/editline]
The deleting portion of the script I use never works. I have never seen it delete a body, but console.log detects the bodies hitting about a 17000 force, which causes the crash, though I have it set to 7000 for remove.
Sorry, you need to Log In to post a reply to this thread.