DarkRP: Damaging a police a CP automatically makes you wanted

Hi, I’d like to implement it so that if somebody damaged one of my CP job classes that they are instantly wanted by the police so that we can get more use out of the wanted system, which currently doesn’t see much utilization. It seems like it might be a fairly simple thing to implement, so I’m wondering if anyone would have any ideas on how to go about it? thanks!

Aw, that would take the fun out of assassinating cp.

do a file search for the string /warrant in the darkrp gamemode and look at the function called on the player that makes the player wanted. Take that function name and call it on the attacker in a PlayerTakeDamage hook if the receiver is on the cp team. I’d post some sample code but the wiki is dead for me at the moment.

sounds fairly simple, like I said, but I’m afraid that there’s a little bit more to that than copy pasting for me, and I really don’t know how to fill in those blanks to do it myself

Try this:
[LUA]
hook.Add(“ScalePlayerDamage”,“CopWanted”, function(ply, hitgroup, dmginfo)
if ply:IsCP() then
local reason = “Attacking a government official.”
local p = dmginfo:GetAttacker()
if ply and ply != p and p:IsPlayer() and p:Alive() and not p:isArrested() and not p.DarkRPVars.wanted then
hook.Call(“PlayerWanted”, GAMEMODE, ply, p, reason)

              p:SetDarkRPVar("wanted", true)
              p:SetDarkRPVar("wantedReason", tostring(reason))
              for a, b in pairs(player.GetAll()) do
                    b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_by_police, p:Nick()) .. "

Reason: " … tostring(reason)
end
timer.Create(p:UniqueID() … " wantedtimer", GAMEMODE.Config.wantedtime, 1, function() TimerUnwanted(ply, p) end)
end
end
end)
[/LUA]

Put that in the server code somewhere and see if it works.

well I honestly have no idea where to put that, but I pasted it around the server files and it doesn’t seem to have worked

[LUA]
hook.Add(“PlayerHurt”,“CopWanted”, function( ply, p, remain, dmg )
if ply:IsCP() then
local reason = “Attacking a government official.”
if ply and ply != p and p:IsPlayer() and p:Alive() and not p:isArrested() and not p.DarkRPVars.wanted then
hook.Call(“PlayerWanted”, GAMEMODE, ply, p, reason)

              p:SetDarkRPVar("wanted", true)
              p:SetDarkRPVar("wantedReason", tostring(reason))
              for a, b in pairs(player.GetAll()) do
                    b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_by_police, p:Nick()) .. "

Reason: " … tostring(reason)
end
timer.Create(p:UniqueID() … " wantedtimer", GAMEMODE.Config.wantedtime, 1, function() TimerUnwanted(ply, p) end)
end
end
end)
[/LUA]

Try that one.
Put it at the bottom of main.lua

Well that IS a simple request, but it also steps into automatically violating NLR. It would be better to auto-wanted the killer only if a different CP is witness to the killing.

Avoid editing core files. Create a module and put it there.