DarkRP, Notify CPs when CPs die

Hi!
I need help notifying all Civil Protection Units, and only the Civil Protection Units, when another Civil Protection Unit dies.

To notify the entire server that the mayor has died, I use this code:


PlayerDeath = function(ply, weapon, killer)
		ply:teamBan()
		ply:changeTeam(GAMEMODE.DefaultTeam, true)
		if killer:IsPlayer() then
			DarkRP.notifyAll(0, 4, "The mayor has been murdered.")
		else
			DarkRP.notifyAll(0, 4, "The mayor has died.")
		end
	end,

I would like to do something similar when a Civil Protection Unit dies. However I would like to only notify the Civil Protection Units about the death of another Civil Protection Units death.

How do I modify the code above to accomplish this?

I would also not like to ban the CP dying for his job or change his team, but I already know that I just remove those lines

Moved to Developer Discussion, please keep anything related to coding/scripting here.

Oh okey, sorry about that!

This should work (if you’re using 2.5+);
[lua]
PlayerDeath = function(ply, weapon, killer)
if killer:IsPlayer() then
for k, v in pairs(player.GetAll()) do
if v:isCP() then
DarkRP.notify(v, 0, 4, ply:Nick() … " has been killed.")
end
end
else
for k, v in pairs(player.GetAll()) do
if v:isCP() then
DarkRP.notify(v, 0, 4, ply:Nick() … " has died.")
end
end
end
end,
[/lua]

It worked, thanks!