LUA:Demote Upon Death

Introduction
Welcome to the tutorial, in this tutorial, I will show you how to demote a player asoon as they die.

Gamemode
Open jobs.lua in lua/darkrp_customthings in your DarkRP modification addon (see here).

Coding it
When you're in jobs.lua, find the job you want the player to be demoted from when they're killed. Then add this:

PlayerDeath = function(ply, weapon, killer) if( ply:Team == TEAM_MAYOR ) then ply:changeTeam( GAMEMODE.DefaultTeam, true ) for k,v in pairs( player.GetAll ) do                               v:PrintMessage( HUD_PRINTCENTER, "The mayor has been killed!" ) end end end

So full team should look something like this:

TEAM_MAYOR = AddExtraTeam("Mayor", {	color = Color(150, 20, 20, 255),	model = "models/player/breen.mdl",	description = The Mayor of the city creates laws to serve the greater good	of the people.	If you are the mayor you may create and accept warrants.	Type /wanted to warrant a player	Type /jailpos to set the Jail Position	Type /lockdown initiate a lockdown of the city.	Everyone must be inside during a lockdown.	The cops patrol the area	/unlockdown to end a lockdown,	weapons = {"weapon_fists"},	command = "mayor",	max = 1,	salary = 100,	admin = 0,	vote = true,	hasLicense = false,	mayor = true,	help = {		"Type /warrant [Nick/SteamID/Status ID] to set a search warrant for a player.",		"Type /wanted [Nick/SteamID/Status ID] to alert everyone to a wanted suspect.",		"Type /unwanted [Nick/SteamID/Status ID] to clear the suspect.",		"Type /lockdown to initiate a lockdown",		"Type /unlockdown to end a lockdown", "Type /placelaws to place a screen containing the laws.", "Type /addlaw and /removelaw to edit the laws." },       PlayerDeath = function(ply, weapon, killer) if( ply:Team == TEAM_MAYOR ) then ply:changeTeam( GAMEMODE.DefaultTeam, true ) for k,v in pairs( player.GetAll ) do                               v:PrintMessage( HUD_PRINTCENTER, "The mayor has been killed!" ) end end end })

When the mayor dies, he will be demoted.

Need anymore additional help? Add me. http://steamcommunity.com/id/Impositive/