Difference between revisions of "DarkRP:CustomJobFields"

From Official DarkRP Wiki
Jump to navigation Jump to search
(Created page with "= Custom job fields = You can create custom jobs in DarkRP. However, there are many things to fiddle with. This page explains every single "field". == Example with all field...")
 
Line 22: Line 22:
 
help = "You are an example. Walk around and be exemplary.",
 
help = "You are an example. Walk around and be exemplary.",
 
customCheck = function(ply) return ply.DarkRPVars.money > 10000 end,
 
customCheck = function(ply) return ply.DarkRPVars.money > 10000 end,
 +
CustomCheckFailMsg = "You don't have enough money!",
 
modelScale = 1.2,
 
modelScale = 1.2,
  
Line 38: Line 39:
  
 
== Field explanations ==
 
== Field explanations ==
 +
'''color'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
The color of the team in tab and other places.
 +
</div>
 +
 +
'''model'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
The model of the team. This can either be a string or a table of strings. Two examples:
 +
A string, players who have this job have ONE model, namely the one given in the string:
 +
{{Code|1=model = "models/player/Group03/Female_01.mdl"}}
 +
 +
A table, the model of the player holding this job is randomly chosen from the list of given models:
 +
{{Code|1=model = {
 +
"models/player/Group03/Female_01.mdl",
 +
"models/player/Group03/Female_02.mdl"
 +
}}}
 +
</div>
 +
 +
'''description'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
The description of a job shows up in the F4 menu when selecting the job. Describe what your job does and what the use of it is.
 +
</div>
 +
 +
'''weapons'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
The list of weapons people with this job spawn with (besides the default weapons)
 +
The following example means that the job spawns with the weapons in the list:
 +
{{Code|1=weapons = {"arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weaponchecker"}}}
 +
</div>
 +
 +
'''command'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
What do you have to enter in chat to get this job?
 +
example: type /example in chat to get the example job
 +
{{Code|1=command = "example"}}
 +
 +
'''Note''': If the job requires voting, a command "/voteexample" is added.
 +
</div>
 +
 +
'''max'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
How many people can have this job at any given time.
 +
</div>
 +
 +
'''salary'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
The salary this job gets.
 +
</div>
 +
 +
'''admin'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
What (admin) access you need to get this job.
 +
{{Code|1=
 +
admin = 0 -- anyone can get this job
 +
admin = 1 -- only admins can get this job
 +
admin = 2 -- only superadmins can get this job
 +
}}
 +
 +
If you want to customize this further (with donators, moderators and whatnot), look at customCheck (scroll down)
 +
</div>
 +
 +
'''vote'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Do players need to create a vote to get this job? true for yes, false for no.
 +
</div>
 +
 +
'''hasLicense'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Does this job get a gun license for free? true for yes, false for no.
 +
It's useful to give the cops gun licenses.
 +
</div>
 +
 +
'''NeedToChangeFrom'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
You can only get this job if you had a specific other job first.
 +
Example: You can only become a chief of police when you're already a CP:
 +
{{Code|1=NeedToChangeFrom = TEAM_POLICE}}
 +
 +
Example 2: You can only become a mayor if you're either a CP or a chief
 +
{{Code|1=NeedToChangeFrom = {TEAM_CHIEF, TEAM_POLICE}}}
 +
</div>
 +
 +
'''help'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
The help text that shows up for this job when the player opens the F1 help menu.
 +
</div>
 +
 +
'''customCheck'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
See http://wiki.darkrp.com/index.php/DarkRP-Config
 +
</div>
 +
 +
'''CustomCheckFailMsg'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Custom message when someone tries and fails to get the job.
 +
See http://wiki.darkrp.com/index.php/DarkRP-Config#Custom_fail_messages
 +
</div>
 +
 +
'''modelScale'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
How big are the players that have this job?
 +
1 for the default size
 +
1.2 for 120% of the default size
 +
0.9 for 90% of the default size.
 +
 +
Don't make it too big or too small, people will get trouble with jumping and crouching.
 +
</div>
 +
 +
== More advanced fields ==
 +
'''CanPlayerSuicide'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
A function that decides whether players with this job can commit suicide.
 +
Arguments: Player ply
 +
</div>
 +
 +
'''PlayerCanPickupWeapon'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
A function that decides whether players with this job can pick up a certain weapon
 +
Arguments: Player ply, Entity weapon
 +
</div>
 +
 +
'''PlayerDeath'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Called when a player dies
 +
Arguments: Player ply, Entity weapon, Entity killer
 +
</div>
 +
 +
'''PlayerLoadout'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Called when a player gets his weapons. Return true to prevent him from getting his default weapons!
 +
Arguments: Player ply
 +
</div>
 +
 +
'''PlayerSelectSpawn'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Called when a spawn is selected for this player.
 +
Arguments: Player ply, Entity spawn
 +
</div>
 +
 +
'''PlayerSetModel'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
A function that decides what the model should be. ALWAYS return a model (string) if you implement this function.
 +
Arguments: Player ply
 +
</div>
 +
 +
'''PlayerSpawn'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Called when a player spawns
 +
Arguments: Player ply
 +
</div>
 +
 +
'''PlayerSpawnProp'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Called when a player attempts to spawn a prop
 +
Arguments: Player ply, string model
 +
</div>
 +
 +
'''ShowSpare1'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Called when a player presses the F1 key
 +
Arguments: Player ply
 +
</div>
 +
 +
'''ShowSpare2'''
 +
<div style="margin-left: 16px; margin-bottom: 8px;">
 +
Called when a player presses the F2 key
 +
Arguments: Player ply
 +
</div>

Revision as of 14:52, 2 April 2013

Custom job fields

You can create custom jobs in DarkRP. However, there are many things to fiddle with. This page explains every single "field".

Example with all fields

Here's an example with all available fields filled in:

TEAM_Example = AddExtraTeam("Example team", {
	color = Color(255, 255, 255, 255),
	model = {
		"models/player/Group03/Female_01.mdl",
		"models/player/Group03/Female_02.mdl"
		},
	description = [[This text will serve as the description of
		this team.]],
	weapons = {"weapon_p2282"},
	command = "example",
	max = 3,
	salary = 45,
	admin = 0,
	vote = false,
	hasLicense = false,
	NeedToChangeFrom = TEAM_CITIZEN,
	help = "You are an example. Walk around and be exemplary.",
	customCheck = function(ply) return ply.DarkRPVars.money > 10000 end,
	CustomCheckFailMsg = "You don't have enough money!",
	modelScale = 1.2,

	CanPlayerSuicide = function(ply) return false end,
	PlayerCanPickupWeapon = function(ply, weapon) return true end,
	PlayerDeath = function(ply, weapon, killer) end,
	PlayerLoadout = function(ply) return true end,
	PlayerSelectSpawn = function(ply, spawn) end,
	PlayerSetModel = function(ply) return "models/player/Group03/Female_02.mdl" end,
	PlayerSpawn = function(ply) end,
	PlayerSpawnProp = function(ply, model) end,
	ShowSpare1 = function(ply) end,
	ShowSpare2 = function(ply) end
})

Field explanations

color

The color of the team in tab and other places.

model

The model of the team. This can either be a string or a table of strings. Two examples: A string, players who have this job have ONE model, namely the one given in the string:

model = "models/player/Group03/Female_01.mdl"

A table, the model of the player holding this job is randomly chosen from the list of given models:

model = {
		"models/player/Group03/Female_01.mdl",
		"models/player/Group03/Female_02.mdl"
}

description

The description of a job shows up in the F4 menu when selecting the job. Describe what your job does and what the use of it is.

weapons

The list of weapons people with this job spawn with (besides the default weapons) The following example means that the job spawns with the weapons in the list:

weapons = {"arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weaponchecker"
}

command

What do you have to enter in chat to get this job? example: type /example in chat to get the example job

command = "example"

Note: If the job requires voting, a command "/voteexample" is added.

max

How many people can have this job at any given time.

salary

The salary this job gets.

admin

What (admin) access you need to get this job.

admin = 0 -- anyone can get this job
admin = 1 -- only admins can get this job
admin = 2 -- only superadmins can get this job

If you want to customize this further (with donators, moderators and whatnot), look at customCheck (scroll down)

vote

Do players need to create a vote to get this job? true for yes, false for no.

hasLicense

Does this job get a gun license for free? true for yes, false for no. It's useful to give the cops gun licenses.

NeedToChangeFrom

You can only get this job if you had a specific other job first. Example: You can only become a chief of police when you're already a CP:

NeedToChangeFrom = TEAM_POLICE

Example 2: You can only become a mayor if you're either a CP or a chief

NeedToChangeFrom = {TEAM_CHIEF, TEAM_POLICE
}

help

The help text that shows up for this job when the player opens the F1 help menu.

customCheck

See http://wiki.darkrp.com/index.php/DarkRP-Config

CustomCheckFailMsg

Custom message when someone tries and fails to get the job. See http://wiki.darkrp.com/index.php/DarkRP-Config#Custom_fail_messages

modelScale

How big are the players that have this job? 1 for the default size 1.2 for 120% of the default size 0.9 for 90% of the default size.

Don't make it too big or too small, people will get trouble with jumping and crouching.

More advanced fields

CanPlayerSuicide

A function that decides whether players with this job can commit suicide. Arguments: Player ply

PlayerCanPickupWeapon

A function that decides whether players with this job can pick up a certain weapon Arguments: Player ply, Entity weapon

PlayerDeath

Called when a player dies Arguments: Player ply, Entity weapon, Entity killer

PlayerLoadout

Called when a player gets his weapons. Return true to prevent him from getting his default weapons! Arguments: Player ply

PlayerSelectSpawn

Called when a spawn is selected for this player. Arguments: Player ply, Entity spawn

PlayerSetModel

A function that decides what the model should be. ALWAYS return a model (string) if you implement this function. Arguments: Player ply

PlayerSpawn

Called when a player spawns Arguments: Player ply

PlayerSpawnProp

Called when a player attempts to spawn a prop Arguments: Player ply, string model

ShowSpare1

Called when a player presses the F1 key Arguments: Player ply

ShowSpare2

Called when a player presses the F2 key Arguments: Player ply