• How do I return a table of all models in a certain job?
    7 replies, posted
So I'm creating an F4 menu esc. NPC, and I've encountered a wall. So basically this NPC replaces the jobs tab in the F4 menu, however if a job (like citizen) has multiple models, I cant seem to get all the models that job has to offer into a new window that pops up after you click 'become', the most I can get is this: https://files.facepunch.com/forum/upload/176026/5333be3a-ed47-458f-be0a-715d298a62f2/image.png Those are all the same models, but pasted for the amount of models in that table. My code is messy (and also quite large) so I wont be posting it unless you absolutely need it. I will however show the fundamentals of whats going on: https://files.facepunch.com/forum/upload/176026/9e35ce95-20fb-4c3b-8ffa-8b184c2af555/image.png (By the way, yes I'm acutely aware that i'm using table.GetFirstValue, and that is my issue, But I cant find a workaround.)
I think you are looking for the table "RPExtraTeams", which essentially has all the information regarding darkrp jobs and category inside it, including models
Yes, However I need it to get the model from the job that is currently selected. The actual UI looks like this: https://files.facepunch.com/forum/upload/176026/66791f93-1c14-4534-8e6f-8226dad10a2a/image.png 'Gun dealer' in this picture is selected, and it properly shows his model, mainly because he only has one model to choose from, so the variable 'model' is not a table, however, if you go to something like citizen, which has many models to choose from, the variable 'model' is then a table, my question is: How do I get the table of models from the selected job, Like, If I selected Citizen, how would I pop up a window with all the model choices?
The models are usually stored as a table when it has more than 1 (or its a table regardless idk), you just loop through that table of models and add a panel or whatev for each model in the table
you can use this Functions/DarkRP/Shared/getJobByCommand you'd use this to access the model value inside the job table and then simply check if it's a table to see if it has multiple model options. how a job table is constructed DarkRP
I understand this, but how would I show them? I can use istable() to actually figure out if it is a table, but how would I show a list of all possible models? kinda like this in the normal darkrp f4 menu: https://files.facepunch.com/forum/upload/176026/bd14129f-be84-4837-aeb7-fefd8b81791d/image.png
there's a table called RPExtraTeams if you index it with the number of one of your teams, it will return a table containing info about that job local jobtable=RPExtraTeams[TEAM_CITIZEN]--you use a number to index this table and it returns the table about the job whos number cooresponds or it returns nil if !jobtable then print"job doesn't exist" return end local models=jobtable.model if type(models)=="string" then print(models) else for i,m in ipairs(models) do print(m) end end the code above prints every model of the default citizen job we can wrap this into a function local function getjobmodels(TEAM) local jobtable=RPExtraTeams[TEAM] if !jobtable then--error handling return {"models/player.mdl"} end local models=jobtable.model if type(models)=="string" then return {models} elseif type(models)=="table" then return models end return {"models/player.mdl"} end
Yes, of course, But how would I set them into individual 'DModelPanels? Obviously you would create a model panel for each model in the job, ##//CODE//## local eDModelPanel = vgui.Create("DModelPanel",eModelSFrame) eDModelPanel:SetSize(100,100) local spacingY = 0 local paddingY = 100 for k,v in ipairs(models) do eDModelPanel:SetPos(0,spacingY) spacingY = spacingY + paddingY end ##//CODE//## But how would I set the model to the Model Panel without them all being the same? If I put eModelPanel:SetModel(models) inside the for loop, it sets the models all to the same thing, this right here is my original problem.
Sorry, you need to Log In to post a reply to this thread.