• Help change ragdoll by killing NPC / Player
    4 replies, posted
Hello I need your help, but the truth is that I speak Spanish and my English is a bit bad I want to know if you can give me a tutorial to create a small Entities as a bomb or a bullet to kill an NPC or Player and change the EP2 HL2 ragdoll skeleton. if you do not understand something, please let me know thanks in advance
For changing to skeleton model: [lua]local listNPC = { "npc_breen", "npc_alyx", "npc_barney", "npc_eli", "npc_gman", "npc_kleiner", "npc_metropolice", "npc_mossman", "npc_citizen", "npc_monk","npc_combine_s" } hook.Add( "OnNPCKilled", "Skeletonize", function ( victim, killer, weapon ) if !victim:IsValid() or !table.HasValue( listNPC, victim:GetClass() ) then return end victim:SetModel("models/skeleton/skeleton_whole.mdl") end) hook.Add( "PlayerDeath", "Skeletonise", function ( victim, killer, weapon ) if !victim:IsValid() then return end victim:SetModel("models/skeleton/skeleton_whole.mdl") end)[/lua] I can also change this so it affects only human NPCs because now it affects ALL killed NPCs. Oh wait, it only affects NPCs. Hook PlayerDeath exists, so no problem but needs two hooks. In theory the Player part should work. Tried to test it in multiplayer but Bots aren't players so I think that that was the problem.
That won't work. You need to change the actual victim's ragdoll, not their model. [lua] hook.Add( "PlayerDeath", "Skeletonise", function( victim ) --Set model local victimRagdoll = victim:GetRagdollEntity() victimRagdoll:SetModel( "models/skeleton/skeleton_whole.mdl" ) end ) [/lua]
[QUOTE=ConTron123;30739362]That won't work. You need to change the actual victim's ragdoll, not their model. [lua] hook.Add( "PlayerDeath", "Skeletonise", function( victim ) --Set model local victimRagdoll = victim:GetRagdollEntity() victimRagdoll:SetModel( "models/skeleton/skeleton_whole.mdl" ) end ) [/lua][/QUOTE] Works on NPCs without that though.
thank you very much everybody, now proves the 2 metho
Sorry, you need to Log In to post a reply to this thread.