• Preventing players dead bodies disappearing?
    12 replies, posted
Hey, i'm here to ask that could anyone do a Lua script which prevents dead players corpses disappearing. Normally when player dies, his dead body disappears when the player respawns. I would want that this script would automatically remove the corpse after 2 minutes. If there is a way to do this and someone could do this, i would be really grateful!
Something like this: [lua]local ragdoll = ents.Create( "prop_ragdoll" ); ragdoll:SetPos( self:GetPos() ); ragdoll:SetAngles( self:GetAngles() ); ragdoll:SetModel( self:GetModel() ); ragdoll:SetOwner( self ); ragdoll:Spawn(); timer.Simple( 120, ragdoll.Remove, ragdoll );[/lua] Untested. Put it in a meta function. Like function meta:RagdollPlayer() or something
Thank you! I will try this, hopefully i can get it right.
Damn, it broke the gamemode (DarkRP) I could make a new lua file for it. EDIT: No luck.
[QUOTE=Freze;26353862]Something like this: [lua]local ragdoll = ents.Create( "prop_ragdoll" ); ragdoll:SetPos( self:GetPos() ); ragdoll:SetAngles( self:GetAngles() ); ragdoll:SetModel( self:GetModel() ); ragdoll:SetOwner( self ); ragdoll:Spawn(); timer.Simple( 120, ragdoll.Remove, ragdoll );[/lua] Untested. Put it in a meta function. Like function meta:RagdollPlayer() or something[/QUOTE] If you did that on player death that would create an additional ragdoll. I think you're probably gonna have to hook or override the GM:PlayerDeath function, which has CreateRagdoll() in it. Look through the base gamemode to see how they deal with it. PlayerSpawn probably removes the ragdoll though, so that might be where you have to change something.
Okay, i'm now tricking around with base gamemodes player.lua file but i have no idea how to make this to work. Damn, i'd wish that i had some time learning some lua scripting. [CODE]function GM:PlayerDeath( Victim, Inflictor, Attacker ) // Don't spawn for at least 2 seconds Victim.NextSpawnTime = CurTime() + 2 Victim.DeathTime = CurTime()[/CODE]Should i add CreateRagdoll() in there?
Try that, yeah.
Okay, it didn't work. I heard that MetroRP:s corecode is preventing the client ragdolls staying. I need a solution for this...
use ply:CreateRagdoll(), not just CreateRagdoll. Make sure its function whateveer( ply ), though.
[CODE]function GM:DoPlayerDeath(ply, attacker, dmginfo, ...) if tobool(GetConVarNumber("dropweapondeath")) and ValidEntity(ply:GetActiveWeapon()) then ply:DropWeapon(ply:GetActiveWeapon()) end ply:CreateRagdoll() ply:AddDeaths( 1 ) if ValidEntity(attacker) and attacker:IsPlayer() then if attacker == ply then attacker:AddFrags( -1 ) else attacker:AddFrags( 1 ) end end end[/CODE]There is already 'ply:CreateRagdoll()'. There also must be something that makes the body to disappear. You know any lua commands which do so? I could try to hunt them from lua files.
removing the ragdoll wouldn't be on death, it would be on spawn, so find GM:PlayerSpawn
garrysmod.org has something similar to this called "Serverside Ragdolls" or something like that, basically it replaces the game's ragdolls with serverside, full collision ragdolls.
[QUOTE=Andriko1;27768689]garrysmod.org has something similar to this called "Serverside Ragdolls" or something like that, basically it replaces the game's ragdolls with serverside, full collision ragdolls.[/QUOTE] [url]http://www.garrysmod.org/downloads/?a=view&id=89509[/url] I think.
Sorry, you need to Log In to post a reply to this thread.