Making a player wanted in Darkrp 2.6.1 for killing a citizen

Hey guys the title says it all. I am trying to make a player wanted for killing a npc_citizen in darkrp. This is what I have so far, but I can’t get it work because class isn’t quite defined right. Thanks in advanced.



local function NPCKilled( victim, killer, weapon )
		if IsValid(victim) && IsValid(killer) then
			if !killer:IsPlayer() then return end
			if !victim:IsNPC() then return end
			if class["npc_citizen"] then
				killer:wanted("U.S.A", "Murdered A Citizen!", 120)
			end



hook.Add("OnNPCKilled","WantedKiller",function(victim,killer,weapon)
if IsValid(victim) && IsValid(killer) then
if !killer:IsPlayer() then return end
if !victim:IsNPC() then return end
if class["npc_citizen"] then
killer:wanted("U.S.A", "Murdered A Citizen!", 120)
end
end)

This is a step in the right direction, but it is still wrong.

You never defined what class is, you are missing a few ends, and there is no need to check if the NPC is an NPC if you’re using the “OnNPCKilled” hook, since it only applies to NPCs

Here is how it should be:



hook.Add("OnNPCKilled","WantedKiller",function(victim,killer,weapon)
      if IsValid(victim) && IsValid(killer) then
           if !killer:IsPlayer() then return end
           if victim:GetClass() == "npc_citizen" then
               killer:wanted("U.S.A", "Murdered A Citizen!", 120)
           end
      end
end)


That should work, haven’t tested it myself though.

Ah ok thanks however, I just tried running it serversided through modules. I named a folder sh_wanted.lua and restarted my server. However it still won’t run.

Any errors in console?

No I tried running it lua/autorun still nothing. Am I putting in the wrong spot or what? o.0

If you’re making modifications for DarkRP, you might want to get https://github.com/FPtje/darkrpmodification. Install it to addons, then navigate through it to lua/darkrp_modules and make a new folder named whatever you want. There will be a text file explaining how to make new modules.

No thanks you don’t need an addon to edit DarkRP… You really don’t.

sure dont use the addon that was created specifically to edit darkrp. that way when you need to update due to a super horrid exploit (like the money dupe exploit that resurfaces every few years) everything you changed will be gone :slight_smile: Great idea!