Difference between revisions of "LUA:Pay Day Baton"

From Official DarkRP Wiki
Jump to navigation Jump to search
(Coding it)
Line 2: Line 2:
 
category = Lua |
 
category = Lua |
 
name = Pay Day Baton |
 
name = Pay Day Baton |
author = [[User:KillerLUA|KillerLUA]] |
+
author = [[User:Pawsative|Pawsative]] |
date = March 13, 2010 |
+
date = April 17th 2013 |
description = How to create a pay day baton. }}
+
description = Demote upon death }}
  
 
{{TOC right}}
 
{{TOC right}}
Line 17: Line 17:
  
 
Open Shared.lua in garrysmod/garrysmod/gamemodes/darkrp/gamemode
 
Open Shared.lua in garrysmod/garrysmod/gamemodes/darkrp/gamemode
 
===Gamemode===
 
 
Create a new file called shared.lua inside YourGamemode/entites/weapons/pay_day_baton
 
  
 
==Coding it==
 
==Coding it==
Line 28: Line 24:
  
 
----
 
----
 
+
<div style="border-style:dashed; border-color:#3385FF; border-width:1px; background-color:#F7F7F7;">
 +
<font size="2">
 +
<syntaxhighlight>
 
PlayerDeath = function(ply, weapon, killer)  
 
PlayerDeath = function(ply, weapon, killer)  
 
if( ply:Team() == TEAM_MAYOR ) then
 
if( ply:Team() == TEAM_MAYOR ) then
Line 37: Line 35:
 
end
 
end
  
 
+
</syntaxhighlight>
 +
</font>
 +
</div>
 
----
 
----
  
Line 43: Line 43:
  
 
----
 
----
<br>TEAM_MAYOR = AddExtraTeam("Mayor", {</br>
+
<div style="border-style:dashed; border-color:#3385FF; border-width:1px; background-color:#F7F7F7;">
<br> color = Color(150, 20, 20, 255),</br>
+
<font size="2">
<br> model = "models/player/breen.mdl",</br>
+
<syntaxhighlight>
 +
 
 +
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
 
description = [[The Mayor of the city creates laws to serve the greater good
 
of the people.
 
of the people.
Line 81: Line 85:
 
end
 
end
 
})
 
})
 
+
</syntaxhighlight>
 +
</font>
 +
</div>
 
----
 
----
  
 
When the mayor dies, he will be demoted.
 
When the mayor dies, he will be demoted.

Revision as of 06:54, 17 August 2013

Lua: Pay Day Baton
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.