CP Warrant/Wanted Commands [Please help]

I’m having issues with giving other police jobs access to /warrant and /wanted. Ive researched and I found one thing but all it does is mess up the gamemode. Can anyone help me with this issue?


function meta:IsCP()
	local Team = self:Team()
	return Team == TEAM_POLICE or Team == TEAM_CHIEF or Team == TEAM_SWAT or Team == TEAM_SWATSNIPER or Team == TEAM_MAYOR
end

**The underlined text is where this goes. The code above breaks the gamemode if i add it to the line
**




/*---------------------------------------------------------
 Warrants/wanted
 ---------------------------------------------------------*/
local function UnWarrant(ply, target)
	if not target.warranted then return end

	hook.Call("PlayerUnWarranted", GAMEMODE, ply, target)

	target.warranted = false
	GAMEMODE:Notify(ply, 2, 4, string.format(LANGUAGE.warrant_expired, target:Nick()))
end

local function SetWarrant(ply, target, reason)
	if target.warranted then return end
	hook.Call("PlayerWarranted", GAMEMODE, ply, target, reason)

	target.warranted = true
	timer.Simple(GAMEMODE.Config.searchtime, function() UnWarrant(ply, target) end)
	for a, b in pairs(player.GetAll()) do
		b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.warrant_approved, target:Nick()) ..
			"
Reason: " .. tostring(reason) ..
			"
Ordered by: " .. (IsValid(ply) and ply:Nick() or "Disconnected player"))
		b:PrintMessage(HUD_PRINTCONSOLE, ply:Nick() .. " ordered a search warrant for " .. target:Nick() .. ", reason: " .. tostring(reason))
	end
	GAMEMODE:Notify(ply, 0, 4, LANGUAGE.warrant_approved2)
end

local function FinishWarrant(choice, mayor, initiator, target, reason)
	if choice == 1 then
		SetWarrant(initiator, target, reason)
	else
		GAMEMODE:Notify(initiator, 1, 4, string.format(LANGUAGE.warrant_denied, mayor:Nick()))
	end
	return ""
end

local function TimerUnwanted(ply, target)
	if IsValid(target) and target:Alive() and target.DarkRPVars.wanted then
		target:SetDarkRPVar("wanted", false)
		for a, b in pairs(player.GetAll()) do
			b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_expired, target:Nick()))
			timer.Destroy(target:Nick() .. " wantedtimer")
		end
	else
		return ""
	end
end

local function SearchWarrant(ply, args)
	local t = ply:Team()
	if not ply:IsCP() then
		GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.must_be_x, "cop/mayor", "/warrant"))
	else
		local tableargs = string.Explode(" ", args)
		local reason = ""

		if #tableargs == 1 then
			GAMEMODE:Notify(ply, 1, 4, LANGUAGE.vote_specify_reason)
			return ""
		end

		if not ply:Alive() then
			GAMEMODE:Notify(ply, 1, 4, "You must be alive in order to issue a warrant")
			return ""
		end

		for i = 2, #tableargs, 1 do
			reason = reason .. " " .. tableargs*
		end
		reason = string.sub(reason, 2)
		if string.len(reason) > 25 then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "/warrant", "<25 chars"))
			return ""
		end
		local p = GAMEMODE:FindPlayer(tableargs[1])

		if p and p:Alive() then
			-- If we're the Mayor, set the search warrant
			if t == TEAM_MAYOR then
				SetWarrant(ply, p, reason)
			else -- If we're CP or Chief
				-- Find the mayor
				local m = nil
				for k, v in pairs(player.GetAll()) do
					if v:Team() == TEAM_MAYOR then
						m = v
						break
					end
				end
				-- If we found the mayor
				if m ~= nil and not m.DarkRPVars.AFK then
					-- Request a search warrent for player "p"
					GAMEMODE.ques:Create(string.format(LANGUAGE.warrant_request.."
Reason: "..reason, ply:Nick(), p:Nick()), p:EntIndex() .. "warrant", m, 40, FinishWarrant, ply, p, reason)
					GAMEMODE:Notify(ply, 0, 4, string.format(LANGUAGE.warrant_request2, m:Nick()))
				else
					-- There is no mayor or the mayor is AFK, CPs can set warrants.
					SetWarrant(ply, p, reason)
				end

			end
		else
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "player: "..tostring(args)))
		end
	end
	return ""
end
AddChatCommand("/warrant", SearchWarrant)
AddChatCommand("/warrent", SearchWarrant) -- Most players can't spell for some reason

local function PlayerWanted(ply, args)
	if not ply:IsCP() then
		GAMEMODE:Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "cop/mayor", "/wanted"))
	else
		local tableargs = string.Explode(" ", args)
		local reason = ""

		if #tableargs == 1 then
			GAMEMODE:Notify(ply, 1, 4, LANGUAGE.vote_specify_reason)
			return ""
		end

		if not ply:Alive() then
			GAMEMODE:Notify(ply, 1, 4, "You must be alive in order to make someone wanted")
			return ""
		end

		for i = 2, #tableargs, 1 do
			reason = reason .. " " .. tableargs*
		end
		reason = string.sub(reason, 2)
		if string.len(reason) > 22 then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "/wanted", "<23 chars"))
			return ""
		end
		local p = GAMEMODE:FindPlayer(tableargs[1])

		if p 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) ..
					"
Ordered by: " .. (IsValid(ply) and ply:Nick() or "Disconnected player"))
				b:PrintMessage(HUD_PRINTCONSOLE, ply:Nick() .. " has made " .. p:Nick() .. " wanted by police for " ..tostring(reason))
			end
			timer.Create(p:UniqueID() .. " wantedtimer", GAMEMODE.Config.wantedtime, 1, function() TimerUnwanted(ply, p) end)
		else
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "player: "..tostring(args)))
		end
	end
	return ""
end
AddChatCommand("/wanted", PlayerWanted)
AddChatCommand("/wantid", PlayerWanted) -- Inspired by the /warrent for people not spelling write. You can rewrite so you can want like this: STEAM_0:0:29257121 stupid kid

local function PlayerUnWanted(ply, args)
	if not ply:IsCP() then
		GAMEMODE:Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "cop/mayor", "/unwanted"))
	else
		local p = GAMEMODE:FindPlayer(args)
		if p and p:Alive() and p.DarkRPVars.wanted then
			hook.Call("PlayerUnWanted", GAMEMODE, ply, p)
			p:SetDarkRPVar("wanted", false)
			for a, b in pairs(player.GetAll()) do
				b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_expired, p:Nick()) ..
					"
Revoked by: " .. ply:Nick())
				b:PrintMessage(HUD_PRINTCONSOLE, string.format(LANGUAGE.wanted_expired, p:Nick()) ..
					"
Revoked by: " .. ply:Nick())
			end
			timer.Destroy(p:UniqueID() .. " wantedtimer")
		else
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "Player: "..tostring(args)))
		end
	end
	return ""
end
AddChatCommand("/unwanted", PlayerUnWanted)
AddChatCommand("/unwantid", PlayerUnWanted) -- Can also do like /wantid but for now it's also for grammar mistakes made by people.