.OnListChanged being weird
Opened this issue · 1 comments
Deleted user commented
When using OnListChanged it skips a few at a time instead of just going to the next item.
Here is a bit of code where the bug is pressent:
function AddMenuClothes(submenu)
--clothingCategoryNames = {"Masks", "Unused (hair)", "Gloves", "Pants", "Bags & Parachutes", "Shoes", "Necklace and Ties", "Under Shirt", "Body Armor", "Decals & Logos", "Shirt & Jackets" }
clothingCategories = {
--{ComponentID = 0, Label = "Face", Name = "face", Zoom = 0.6, Cam = 0.65},
{ComponentID = 1, Label = "Mask", Name = "mask", Zoom = 0.6, Cam = 0.65},
{ComponentID = 8, Label = "Undershirt", Name = "tshirt", Zoom = 0.75, Cam = 0.15},
{ComponentID = 11, Label = "Shirts & Jackets", Name = "torso", Zoom = 0.75, Cam = 0.15},
{ComponentID = 7, Label = "Necklace and Ties", Name = "chain", Zoom = 0.75, Cam = 0.15},
{ComponentID = 5, Label = "Bags & Parachutes", Name = "bags", Zoom = 0.6, Cam = 0.65},
{ComponentID = 9, Label = "Body Armor", Name = "bproof", Zoom = 0.75, Cam = 0.15},
{ComponentID = 3,Label = "Gloves", Name = "arms", Zoom = 0.75, Cam = 0.15},
{ComponentID = 4, Label = "Pants", Name = "pants", Zoom = 0.8, Cam = -0.5},
{ComponentID = 6, Label = "Shoes", Name = "shoes", Zoom = 0.8, Cam = -0.8}
--{Label = "Decals & Logos", Name = "mask" Zoom = 0.6, Cam = 0.65}
}
local amount = {}
for i=1, #clothingCategories do
local maxDrawables = GetNumberOfPedDrawableVariations(GetPlayerPed(-1), clothingCategories[i].ComponentID);
maxDrawables = maxDrawables - 1
amount = {}
for i = 1, maxDrawables do
amount[i] = "item "..i.."/"..maxDrawables
end
local Select = NativeUI.CreateListItem(clothingCategories[i].Label, amount , 1, "Choose your "..clothingCategories[i].Label )
local BaseColor = NativeUI.CreateColourPanel("Texture", ColoursPanel.Texture)
if submenu.SubMenu ~= nil then
submenu.SubMenu:AddItem(Select)
Select:AddPanel(BaseColor)
else
submenu:AddItem(Select)
end
Select.OnListChanged = function(ParentMenu, SelectedItem, Index)
Citizen.Wait(100)
local ActiveItem = SelectedItem:IndexToItem(Index)
local color = (ActiveItem.Panels and ActiveItem.Panels[1] or 1)
SetPedComponentVariation(GetPlayerPed(-1), clothingCategories[i].ComponentID,Index-1,color-1, 2)
if clothingCategories[i].Name == "face" then
Character[clothingCategories[i].Name] = Index-1
else
Character[clothingCategories[i].Name .. "_1"] = Index-1
Character[clothingCategories[i].Name .. "_2"] = color-1
end
zoomOffset = clothingCategories[i].Zoom
camOffset = clothingCategories[i].Cam
end
end
end
This is from a CharacterCreator menu that i have taken and done some work to it to add new things.
justalemon commented
This is the C# version of NativeUI, not the Lua version.