Does somebody know how i can make a submenu inside a menu?

I want to add another submenu between the skin spawning and the main menu of eup where it takes me to the skins from.

Normal:
Department/Skins

Example of what I want:
Department/!!Unit type!!/Skins

This is the original:

local function setOutfit(outfit)
local ped = PlayerPedId()

RequestModel(outfit.ped)

while not HasModelLoaded(outfit.ped) do
    Wait(0)
end

if GetEntityModel(ped) ~= GetHashKey(outfit.ped) then
    SetPlayerModel(PlayerId(), outfit.ped)
end

ped = PlayerPedId()

for , comp in ipairs(outfit.components) do
   SetPedComponentVariation(ped, comp[1], comp[2] - 1, comp[3] - 1, 0)
end

for , comp in ipairs(outfit.props) do
    if comp[2] == 0 then
        ClearPedProp(ped, comp[1])
    else
        SetPedPropIndex(ped, comp[1], comp[2] - 1, comp[3] - 1, true)
    end
end

end

local categoryOutfits = {}

for name, outfit in pairs(outfits) do
if not categoryOutfits[outfit.category] then
categoryOutfits[outfit.category] = {}
end

categoryOutfits[outfit.category][name] = outfit

end

local menuPool = NativeUI.CreatePool()
local mainMenu = NativeUI.CreateMenu(‘EUP’, ‘Wähle dein Outfit!’)

for name, list in pairs(categoryOutfits) do
local subMenu = menuPool:AddSubMenu(mainMenu, name)
for id, outfit in pairs(list) do
outfit.item = NativeUI.CreateItem(id, ‘Wähle dieses Outfit.’)
subMenu:AddItem(outfit.item)
end

subMenu.OnItemSelect = function(sender, item, index)
    -- find the outfit
    for _, outfit in pairs(list) do
        if outfit.item == item then
            CreateThread(function()
                setOutfit(outfit)
            end)
        end
    end
end

end

menuPool:Add(mainMenu)

menuPool:RefreshIndex()

RegisterCommand(‘eup’, function()
mainMenu:Visible(not mainMenu:Visible())
end, false)

CreateThread(function()
while true do
Wait(0)

    menuPool:ProcessMenus()
end

end)

As a .txt to edit or look at:
.txt (1.8 KB)

If someone can help me or edit it and send the file back, I would be very thankful.

you can add another menu between the skin spawning and the main menu. You can create another submenu using the NativeUI.CreatePool and NativeUI.CreateMenu functions, and then add it to the menu pool using menuPool:Add.

Here’s an example of how you can add another submenu:
local function setOutfit(outfit)
– code to set outfit
end

local categoryOutfits = {}

for name, outfit in pairs(outfits) do
if not categoryOutfits[outfit.category] then
categoryOutfits[outfit.category] = {}
end

categoryOutfits[outfit.category][name] = outfit

end

local menuPool = NativeUI.CreatePool()
local mainMenu = NativeUI.CreateMenu(‘EUP’, ‘Wähle dein Outfit!’)

– Add another submenu
local chooseCategory = NativeUI.CreateMenu(‘Kategorie auswählen’, ‘Wähle eine Kategorie.’)
for name, list in pairs(categoryOutfits) do
local categoryItem = NativeUI.CreateItem(name, ‘Wähle diese Kategorie.’)
chooseCategory:AddItem(categoryItem)
end

chooseCategory.OnItemSelect = function(sender, item, index)
for name, list in pairs(categoryOutfits) do
if name == item:Text() then
local subMenu = menuPool:AddSubMenu(mainMenu, name)
for id, outfit in pairs(list) do
outfit.item = NativeUI.CreateItem(id, ‘Wähle dieses Outfit.’)
subMenu:AddItem(outfit.item)
end

        subMenu.OnItemSelect = function(sender, item, index)
            for _, outfit in pairs(list) do
                if outfit.item == item then
                    CreateThread(function()
                        setOutfit(outfit)
                    end)
                end
            end
        end
    end
end

end

menuPool:Add(chooseCategory)
menuPool:Add(mainMenu)
menuPool:RefreshIndex()

RegisterCommand(‘eup’, function()
chooseCategory:Visible(not chooseCategory:Visible())
end, false)

CreateThread(function()
while true do
Wait(0)

    menuPool:ProcessMenus()
end

end)

With this code, you will now have a new submenu called “Kategorie auswählen” which will appear between the skin spawning and the main menu. When a category is selected from the “Kategorie auswählen” menu, a submenu with the corresponding outfits will be added to the main menu.

1 Like

it doesent start now