LUA:Demote Upon Death

From Official DarkRP Wiki
Revision as of 06:58, 17 August 2013 by Pawsative (talk | contribs) (Created page with "{{Article| category = Lua | name = Demote Upon Death | author = Pawsative | date = April 17th 2013 | description = Demote upon death }} {{TOC right}} ==I...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Lua: Demote Upon Death
Page white text.png Description:Demote upon death
User.png Original Author:Pawsative
Calendar.png Created:April 17th 2013


Introduction

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

Setting up the files

Gamemode

Open Shared.lua in garrysmod/garrysmod/gamemodes/darkrp/gamemode

Coding it

When your in Shared.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( TEAM_CITIZEN, true )
		for k,v in pairs( player.GetAll() ) do
			v:PrintMessage( HUD_PRINTCENTER, "The mayor has been killed!" )
		end
	end


So it should look 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 <name>  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( TEAM_CITIZEN, 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/