I placed the NPC to drop crowbar upon death but still they drop the original HL2 weapons + the crowbar i have set. What i am missing?
if not SERVER then return end
local WeaponList = {
"weapon_crowbar"
}
hook.Add("OnNPCKilled", "DropWeaponOnNPCKilled", function(npc, killer, weapon)
local weapon = ents.Create(table.Random(WeaponList)) --randomly choose a weapon entity from WeaponList
weapon:SetPos(npc:LocalToWorld(npc:OBBCenter())) -- Set the position to the center of the NPC
weapon:Spawn()
end)
Because by default if a player or npc is killed they will drop their weapons.
You could use Player/StripWeapon to remove the NPC weapons so only the crowbar would be dropped.
Sorry, you need to Log In to post a reply to this thread.