DarkRP:Categories

DarkRP 2.6.1 comes with quite a big change in the default F4 menu: categories. This page explains how to create categories, how to use them and how to change the categories of default items.

Note: Categories do NOT work for custom F4 menus unless the authors of these F4 menus explicitly add support for them. Until then the categories will NOT break those F4 menus.

= Creating categories = There's a file in the DarkRPmod: 'lua/darkrp_customthings/categories.lua'. It might be that you don't have this file in your own DarkRPMod. In that case you can download it here:

https://github.com/FPtje/darkrpmodification/blob/master/lua/darkrp_customthings/categories.lua

Categories look like this: DarkRP.createCategory{ name = "Citizens", -- The name of the category. categorises = "jobs", -- What it categorises. MUST be one of "jobs", "entities", "shipments", "weapons", "vehicles", "ammo". startExpanded = true, -- Whether the category is expanded when you open the F4 menu. color = Color(0, 107, 0, 255), -- The color of the category header. canSee = function(ply) return true end, -- OPTIONAL: whether the player can see this category AND EVERYTHING IN IT. sortOrder = 100, -- OPTIONAL: With this you can decide where your category is. Low numbers to put it on top, high numbers to put it on the bottom. It's 100 by default. }

Feel free to copy the above category, or the one below (which is without the explanation) into your categories.lua. Make sure to put it under the line at the bottom of the file. DarkRP.createCategory{ name = "Citizens", categorises = "jobs", startExpanded = true, color = Color(0, 107, 0, 255), canSee = function(ply) return true end, sortOrder = 100, }

= How to use categories = Custom jobs, vehicles, entities, shipments and the lot now have two fields: category and sortOrder. They are explained below

NOTE: The category of ALL jobs/shipments/entities/etc will be set to "Other" UNLESS you change it!

category The category it belongs to in the F4 menu. NOTE: This will throw an error if the category doesn't exist!

sortOrder Location of the job/entity/... 'within' the category. Lower number means more on top of the list. By default this is set 100.

Here's an example with the gun dealer job. Note how both category and sortOrder are set at the bottom. Also mind the comma that's been added after the hasLicense line to accomodate for the new lines.

It's good practice to add a comma even after the last item. It helps to prevent quite a few "missing comma" errors. TEAM_GUN = DarkRP.createJob("Gun Dealer", {	color = Color(255, 140, 0, 255),	model = "models/player/monk.mdl",	description = A Gun Dealer is the only person who can sell guns to other people.		Make sure you aren't caught selling illegal firearms to the public! You might get arrested!,	weapons = {},	command = "gundealer",	max = 2,	salary = GAMEMODE.Config.normalsalary,	admin = 0,	vote = false,	hasLicense = false,	category = "Citizens",	sortOrder = 100, })

Here's another example with the drug lab entity. Note how adding the category and sortOrder happens in exactly the same way as in the custom job.

DarkRP.createEntity("Gun lab", {	ent = "gunlab",	model = "models/props_c17/TrapPropeller_Engine.mdl",	price = 500,	max = 1,	cmd = "buygunlab",	allowed = TEAM_GUN,	category = "Other", 	sortOrder = 90, })

Categories apply to:
 * jobs
 * entities
 * shipments
 * weapons
 * vehicles
 * ammo

And all are done in the same way.

= Changing categories of default items = Changing the categories of your own custom jobs and other items is easy: just add or change the category field. However, default items might be in a category that you might not agree with. It would be annoying if you had to disable the jobs, copy them over to your own jobs.lua file 'just' to change the categories.

Fear no more! The latest version of settings.lua contains this beauty: -- Override categories -- NOTE: categories are to be set in the "category" field of the custom jobs/shipments/entities/ammo/pistols/vehicles -- Use this only to override the categories of _default_ things. -- This will NOT work for your own custom stuff. -- Make sure the category is created in the darkrp_customthings/categories.lua, otherwise it won't work! GM.Config.CategoryOverride = { jobs = { ["Citizen"]                            = "Citizens", ["Hobo"]                               = "Citizens", ["Gun Dealer"]                         = "Citizens", ["Medic"]                              = "Citizens", ["Civil Protection"]                   = "Civil Protection", ["Gangster"]                           = "Gangsters", ["Mob boss"]                           = "Gangsters", ["Civil Protection Chief"]             = "Civil Protection", ["Mayor"]                              = "Civil Protection" },   entities = { ["Drug lab"]                           = "Other", ["Money printer"]                      = "Other", ["Gun lab"]                            = "Other"

},   shipments = { ["AK47"]                               = "Rifles", ["MP5"]                                = "Rifles", ["M4"]                                 = "Rifles", ["Mac 10"]                             = "Other", ["Pump shotgun"]                       = "Shotguns", ["Sniper rifle"]                       = "Snipers"

},   weapons = { ["Desert eagle"]                       = "Pistols", ["Fiveseven"]                          = "Pistols", ["Glock"]                              = "Pistols", ["P228"]                               = "Pistols" },   vehicles = {}, -- There are no default vehicles ammo = { ["Pistol ammo"]                        = "Other", ["Shotgun ammo"]                       = "Other", ["Rifle ammo"]                         = "Other" }, }

'''Note: when using an older version of darkrpmod you might not have this in your settings.lua. Don't worry, you can just copy it over'''.

'''Note: THIS WILL ONLY WORK FOR DEFAULT ITEMS. ANY ATTEMPTS TO SET THE CATEGORIES OF YOUR OWN CUSTOM ITEMS HERE WILL BE IGNORED!''' IT WON'T WORK, I PROMISE YOU!