I was wondering if it's possible to make a script that automatically cleans up all the ragdolls on the server.
I know it would need a timer and some sort of hook or function for cleaning up the ragdolls, I just dont know how to do it right.
any help is much appreciated
game.CleanUpMap() resets the map.
Or you could
[lua]for k, v in pairs( ents.FindByClass( "prop_ragdoll" ) ) do
v:Remove()
end[/lua]
Then you could encase either of the two in an endless timer:
[lua]timer.Create( "CleanRagdolls", 5, 0, function() end )[/lua]
You could also create a simple timer after creating a ragdoll that removes it.
does ragdoll cleanups remove dead npc bodys?
[QUOTE=AIX-Who;42745940]does ragdoll cleanups remove dead npc bodys?[/QUOTE]
They do not.
[QUOTE=StonedPenguin;42746898]They do not.[/QUOTE]
Does it if Keep Ragdolls for NPCs is set to true?
[QUOTE=AIX-Who;42745940]does ragdoll cleanups remove dead npc bodys?[/QUOTE]
This is a script which I use on my server, I found it somewhere here on the forum.
Put it in a client file.
[LUA]
function RemoveDeadRag( ent )
if (ent == NULL) or (ent == nil) then return end
if (ent:GetClass() == "class C_ClientRagdoll") then
if ent:IsValid() and !(ent == NULL) then
SafeRemoveEntityDelayed(ent,180)
end
end
end
hook.Add( "OnEntityCreated", "RemoveDeadRag", RemoveDeadRag )
[/LUA]
This will remove NPC ragdolls(not other ragdolls).
[QUOTE=vegasx;42746904]Does it if Keep Ragdolls for NPCs is set to true?[/QUOTE]
Yes. Otherwise use Busan1s code.
Thank you all very much for you help, Much appreciated.
*Edit*
It seems to no collide the ragdolls, Is the code meant to completely remove them?
*Edit*
Nevermind, i just had to change the time from 180 down a little bit. Thanks :)
when he says place it in a client file, where specifically if on a server?
Sorry, you need to Log In to post a reply to this thread.