manups4e / ScaleformUI

ScaleformUI is a GTA menu styled API made with custom Scaleforms to be lighter, faster and visually better
Other
139 stars 49 forks source link

[Lua] "attempt to call nil value (local 'item')" error when trying to add items to a column whilst the lobby menu is open #197

Closed Lxk3y closed 7 months ago

Lxk3y commented 7 months ago

This has taken me a bit of time to figure out what I think is going on, but i'm going to try my best to try and explain it with an example resource,

I have been struggling with a repeated error in F8 when it comes to adding items to columns in the lobby menu. Whether it be using "AddSettings" or "AddPlayer", i am repeatedly seeing this error be thrown. I struggled to figure out what was causing it, so I did some digging by adding a heap of debug lines into the ScaleformUI lua file, and I noticed what was happening (I think). In the screenshot below, the top of the stack is the PlayerListColumn:_itemCreation function. I decided to add the following debug line into here:

local menuIndex = self.Pagination:GetMenuIndexFromPageIndex(page, pageIndex)
-- Debug line
print("page: "..page)
print("menuIndex: "..menuIndex)

And this revealed that the page was 0, and the menuIndex was returning a negative number, which is an invalid index, and thus no item was found, which was throwing the following error: image

I decided to create a debug script to try and figure out what i was doing to cause this to happen. It turns out that adding any item to a column whilst the menu is OPEN, is causing this error. When the menu is closed, you can add items to the settings column and the player column with no issues. However when the menu is open, adding items (with the goal of displaying new items in real time), is throwing this error. This same behaviour was also happening in the SettingsColumns _itemCreation function as well.

I have created the attached example script to showcase this bug. Follow these steps to replicate it:

  1. Type /open to display a Lobby menu with the local player added in the players column
  2. Press "Escape" to close the menu
  3. Type /create a few times, followed by /open. You will see multiple local players added to the players column (expected behaviour)
  4. Now press the Create Player button, followed by F8. You will see the error.

Hopefully ive provided some clear information on what i am experiencing. This is using the current latest "Release" build of ScaleformUI Lua.

[example.zip](https://github.com/manups4e/ScaleformUI/files/14068636/example.zip)

manups4e commented 7 months ago

fixed in https://github.com/manups4e/ScaleformUI/commit/9e977b94c546c4302bfc18b989356998402da820