• Scrip Error, Help!
    6 replies, posted
Hello! I need help with this script, its a weapon and he change my ragdoll after dead, to a Skeleton, but, the problem is... no matter what form die (for a default weapon, killed by a prop, etc.) I always become a skeleton, and my NPC to! I would like to help me correct this error, only to become a skeleton when I die by the gun here is the Script: 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_Alma_Wade_Swep ) 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_Alma_Wade_Swep ) if !victim:IsValid() then return end victim:SetModel("models/skeleton/skeleton_whole.mdl") end) hook.Add( "PlayerDeath", "Skeletonise", function( victim, killer, weapon_Alma_Wade_Swep ) --Set model local victimRagdoll = victim:GetRagdollEntity() victimRagdoll:SetModel( "models/skeleton/skeleton_whole.mdl" ) end ) PD: te code is not mine!, a user in this community give me sorry for my english, bot, i am spanish... thanks in advance [highlight](User was banned for this post ("Wrong forum" - Overv))[/highlight]
it is because your victim:SetModel() doesn't select from your table, but has a string with the (skeleton) model. You're not really doing anything in your hooks other than setting the model to skeleton. [editline]7th July 2011[/editline] Also, add [lua] tags, it makes your code easier to read for us. [editline]7th July 2011[/editline] And post in the questions section, not here.
realy, i dont undesrtand very good the hooks, you can correct the code?, and how can add lua tags?
[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"} local ranMod = table.Random( listNPC ) hook.Add("OnNPCKilled", "Skeletonize", function(victim, killer, weapon) if( !ValidEntity( victim ) || !table.HasValue(listNPC, victim:GetModel()) ) then return; end victim:SetModel( ranMod ) end) hook.Add("PlayerDeath", "Skeletonize", function (victim, killer, weapon) if( !ValidEntiy( victime ) then return; end victim:SetModel( ranMod ) local victimRagdoll = victim:GetRagdollEntity() victimRagdoll:SetModel( ranMod ) end) [/lua] Is that what you are trying to do? [editline]7th July 2011[/editline] That code won't work by the way, are you trying to set a random model from that table though?
[QUOTE=c-unitV2;30973977][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"}local ranMod = table.Random( listNPC )hook.Add("OnNPCKilled", "Skeletonize", function(victim, killer, weapon) if( !ValidEntity( victim ) || !table.HasValue(listNPC, victim:GetModel()) ) then return; end victim:SetModel( ranMod )end)hook.Add("PlayerDeath", "Skeletonize", function (victim, killer, weapon) if( !ValidEntiy( victime ) then return; end victim:SetModel( ranMod ) local victimRagdoll = victim:GetRagdollEntity() victimRagdoll:SetModel( ranMod )end)[/lua]Is that what you are trying to do?[editline]7th July 2011[/editline]That code won't work by the way, are you trying to set a random model from that table though?[/QUOTE] You don't set an Model by the npc's name fyi :downs: Just my 2 cents
[QUOTE=RetTurtl3;30975342]You don't set an Model by the npc's name fyi :downs: Just my 2 cents[/QUOTE] That would be why I posted saying it wont work
What is he trying to do anyway, it's not clear.
Sorry, you need to Log In to post a reply to this thread.