Adding job filters to darkrp f4 menu

Hey guys I am unsure where to start to add a job filtering system to my f4 menu.
I know I should be using http://wiki.garrysmod.com/page/Category:DCategoryList
But I don’t know how to get it started in a sense of detecting the job, or filtering what job goes under the category.
ALL HELP is appreciated thanks!



local categories = DarkRP.getCategories().entities

for k,v in pairs(categories) do
    local category = vgui.Create("Panel") // Make your DCategoryList in this
    for ka,item in pairs(v.members) do
        // Add the item here
    end
end


Ah ok I sort of see now but wouldn’t I have to add every single job there? Or atleast the ones I want in a category. Can you show me an example with citizen or something, also I am using 2.4.3.

Sorry I mis-read. DarkRP 2.6 doesn’t support categories for jobs and 2.4.3 doesn’t support categories at all. You could probably add a category=“yourcategory” in the job table and use that, eg



local categories = {}
categories['other'] = { name = "Other" }
categories['cps'] = { name = "CPs"} 
categories['terrorists'] = { name = "Terrorists" }

for k,v in pairs(categories) do
    v.element = vgui.Create("DCategoryList")
    // Set position and stuff. You should probably add it to a DScrollPanel or something here
end

for k,v in pairs(TheJobTable) do
    if(!v.category or !categories[v.category]) then
        v.category = 'other'
    end
    
    local item = vgu.Create("YourItem")
    // Set the item stuff here, use v. (eg v.name or v.model)
  
    categories[v.category].element:AddItem(item)
end


awesome thanks so much so if i put category=“cp” it will go under the CPs section and this goes into vgui.lua correct?

(‘cps’ not ‘cp’ in my example)

You still need to change it to support your F4 menu, see my comments