• Making a player wanted in Darkrp 2.6.1 for killing a citizen
    8 replies, posted
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. [CODE] 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 [/CODE]
[code]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)[/code]
[QUOTE=Marbella;50312547][code]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)[/code][/QUOTE] 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: [code] 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) [/code] That should work, haven't tested it myself though.
[QUOTE=Tobiasx;50312573]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: [code] 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) [/code] That should work, haven't tested it myself though.[/QUOTE] 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.
[QUOTE=pogh10;50312598]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.[/QUOTE] Any errors in console?
[QUOTE=Tobiasx;50312602]Any errors in console?[/QUOTE] 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 [URL="https://github.com/FPtje/darkrpmodification"]https://github.com/FPtje/darkrpmodification[/URL]. 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.
[QUOTE=jorji;50322149]If you're making modifications for DarkRP, you might want to get [URL="https://github.com/FPtje/darkrpmodification"]https://github.com/FPtje/darkrpmodification[/URL]. 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.[/QUOTE] No thanks you don't need an addon to edit DarkRP... You really don't.
[QUOTE=pogh10;50328226]No thanks you don't need an addon to edit DarkRP... You really don't.[/QUOTE] 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 :) Great idea!
Sorry, you need to Log In to post a reply to this thread.