Darkrp mayor to citizen when killed script

I remember some script of this sort being out there, Or was it a DarkRP command?

If its not out there or its a DarkRP command, Im requesting a LUA script that simply turns the mayor back to a citizen when he dies.

I’m pretty sure that DarkRP has that as an admin command, although i don’t remember it.

Yeah i was quite sure it did aswell, But i couldn’t find it.

I had this on my old server once, i tried to find it and give it to you.

  • But unfortunately i can’t find it :confused:

[lua]function GM:PlayerDeath()
if ply:Team() == TEAM_MAYOR then
ply:SetTeam() == TEAM_CITIZEN
Notify(ply, 1, 4, “The Mayor has been murder.”)


Something like that

Exactly what i was looking for, But where do i put it?

I’m sure you have to put it in Main.lua

That wont work.

Here, use this:

[lua]function DemoteMayor(ply,wep,killer)
if ply:Team() != TEAM_MAYOR then return end
if !killer:IsPlayer() then return end
ply:ChangeTeam(TEAM_CITIZEN, true)
NotifyAll(1,4,“The overseer has been assassinated.”)

Looks good, but I would check for suicide too, dunno if they want suicide to demote too…

My server doesn’t allow regular players to suicide - but I could code that in

I’m not trying to undermine your script, 'twas merely a suggestion.

Where the hell should you put it then, :stuck_out_tongue:

I’m pretty sure it goes in, cl_init.lua

Yep, because death is clientside.

Yep, because you can change players team clientside

Stop being a cunt. It goes in the main.lua file.


Sigh All the code in this thread has been a failure so far, Luke was the closest.

By the way, there was a thread about this before, but it seems to have disappeared.
function DemoteMayor(victim,killer)
if ( victim:Team(TEAM_MAYOR) && victim != killer ) then
victim:ChangeTeam(TEAM_CITIZEN, true)
victim:ChatPrint(“Have fun being a citizen.”)
for k, v in pairs (player.GetAll()) do
if v != victim then
v:PrintMessage(HUD_PRINTCENTER, “The mayor is dead!”)

Also a check if the player is not the killer (means they don’t get demoted if they suicide)

Goes in init.lua


if (v:Team() == TEAM_MAYOR) then
for k, v in ipairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,“The mayor has been killed!”);