Demotion On Death Help - DarkRP

Does anyone know how to make it so when the mayor dies, he loses his job? If so I plead that you answer this question!

Put this in lua/autorun/*.lua

[lua]
function DemoteMayorToCitizen(ply)
if ply:Team() == TEAM_MAYOR then ply:ChangeTeam(TEAM_CITIZEN) end
end
hook.Add(“PlayerDeath”, “DemoteMayorToCitizen”, DemoteMayorToCitizen)
[/lua]

I didnt make this…

I tried that, it does not work though if you put it in “lua/autorun/*.lua”.

Don’t you have to put it somewhere in the gamemode itself?

lua/autorun/server/sh_deathdemote.lua




AddCSLuaFile("sh_deathdemote.lua")

function playerdeathdemote( ply )  
if (ply:Team() == (TEAM_MAYOR) then 
ply:SetTeam(TEAM_CITIZEN) ) 
end  
end  
hook.Add("PlayerDeath", "DemoteMayorToCitizen", DemoteMayorToCitizen)