1. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

v 2.5.x How to create categories!

Discussion in 'Tutorials' started by TypicalRookie, Mar 24, 2015.

  1. TypicalRookie

    TypicalRookie Active Member

    DarkRP 2.6.1 comes with a new categories feature. These categories allow you to categorize your jobs/entities/shipments/weapons/vehicles/ammo.

    Before starting make sure you have the latest version of DarkRP and the DarkRP modification addon. You can learn everything you need to know about your categories from the DarkRP wiki page. This guide will just explain the basics of how to create your own categories.

    First navigate to the your categories.lua file (GarrysMod\garrysmod\addons\darkrpmodification\lua\darkrp_customthings\categories.lua). You will see this inside the file:

    Code (Text):

    --[[-----------------------------------------------------------------------
    Categories
    ---------------------------------------------------------------------------
    The categories of the default F4 menu.

    Please read this page for more information:
    http://wiki.darkrp.com/index.php/DarkRP:Categories

    In case that page can't be reached, here's an example with explanation:

    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.
    }


    Add new categories under the next line!
    ---------------------------------------------------------------------------]]
     
    The above block of text explains the format for your categories. The format is very simple and works similar to your jobs. To make your first category, insert the above format under the -------- line. Once you insert it just fill in the blanks. Don't forget your quotation marks (" ") and commands ( , ).

    Your finished category should like something like this.
    Code (Text):

    DarkRP.createCategory{
        name = "Criminals",
        categorises = "jobs",
        startExpanded = true,
        color = Color(52, 122, 95, 255),
    }
     
    Once you have the categories completed you will need to add them to the appropriate jobs/entities/shipments/weapons/vehicles/ammo. I will explain how to add them to a job (you can add your category in the same way to any other category type).

    Open up your jobs.lua file (GarrysMod\garrysmod\addons\darkrpmodification\lua\darkrp_customthings\jobs.lua) and find the job you want to add your category to. I will add a "Criminals" category to a "Thief" job.

    Code (Text):

    TEAM_THIEF = DarkRP.createJob("Thief", {
        color = Color(182, 182, 182, 255),
        model = {"models/player/arctic.mdl"},
        description = [[Thiefs break into buildings and steal things.]],
        weapons = {"lockpick"},
        command = "thief",
        max = 10,
        salary = 30,
        admin = 0,
        vote = false,
        hasLicense = false,
    })
     
    After the line "hasLicense = false," (or which ever line your job ends with) you can add these two new lines:

    Code (Text):
     
    category = "Criminals",
    sortOrder = 100,
     
    The "category = "Criminals,"" tells DarkRP that your Thief job goes inside of your "Criminals" category. The "sortOrder = 100," sets the order in which DarkRP will arrange the job (lower numbers are placed on top, higher numbers on bottom).

    You must insert the "category =" line to properly add the job to your category, sortOrder is optional. If you added your category and sortOrder to your job properly then your job should look like this:
    Code (Text):

    TEAM_THIEF = DarkRP.createJob("Thief", {
        color = Color(182, 182, 182, 255),
        model = {"models/player/arctic.mdl"},
        description = [[Thiefs break into buildings and steal things.]],
        weapons = {"lockpick"},
        command = "thief",
        max = 10,
        salary = 30,
        admin = 0,
        vote = false,
        hasLicense = false,
        category = "Criminals",
        sortOrder = 100,
    })
     

    As I mentioned above you can use this same general pattern on all of your jobs/entities/shipments/weapons/vehicles/ammo.
     
    Last edited: Mar 26, 2015
    (FPtje) Atheos likes this.
  2. [XRAY]Blake

    [XRAY]Blake Active Member

    So say under your shipments.lua, you would have to make a category like so:
    DarkRP.createCategory{
    name = "Gun Dealer",
    categorises = "shipments",
    startExpanded = true,
    color = Color(52, 122, 95, 255),
    }

    Then add the line
    category = "Gun Dealer",

    At the end of the gun shipment?
     
    Last edited by a moderator: Mar 27, 2015
  3. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

    yes, but that will error if the "Gun Dealer" shipment category does not exist.
     
  4. twitchyb1t

    twitchyb1t Member

    so this tells me that with entity categories you can do
    aslong as you have the categories?

    DarkRP.createShipment("Famas F1", {
    model = "models/weapons/w_rif_famas.mdl",
    entity = "fas2_famas",
    price = 17000,
    amount = 10,
    seperate = true,
    pricesep = 1800,
    noship = false,
    catagory = "Black Market", "Government",
    allowed = {TEAM_BMD, }
    })
     
  5. Woof Gabber

    Woof Gabber New Member

    just saying you spelt categorys wrong its "cate" no "cata"
     
  6. Aeioyoo

    Aeioyoo Member

    Nope, Category is the only right one, but both Categories and Catagories are acceptable, depending if you are British or American. But generally, yeah its Categories, (Not categorys)
     
  7. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

  8. Sir Lenopow

    Sir Lenopow New Member

  9. Aeioyoo

    Aeioyoo Member

  10. Sir Lenopow

    Sir Lenopow New Member

    I downloaded the latest DarkRP, and other than m9k and a few building tools, it's all vanilla.
     
  11. Aeioyoo

    Aeioyoo Member

    Sorry but you're going to have to make a thread in Modding Questions & Help because I dont have the faintest idea what is wrong, but im sure someone else will
     
    Last edited by a moderator: Jun 13, 2015

Share This Page