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

Keep checkmark state? #199

Closed GLiTcH2 closed 7 months ago

GLiTcH2 commented 7 months ago

I am new to lua coding so forgive my ignorance, I have been fiddling with the example menu provided. I just need a very small simple menu so I managed to strip out everything except two menu items, with a lot of trial and error I got the menu to finally work with no errors lol. Anyways the checkbox item does not maintain it's checked state, It's un-checked by default but when I manually check it and close the menu then open the menu back up it goes right back to it's un-checked state. What do I need to do to have it keep it's checked state?

manups4e commented 7 months ago

use an external member.

local parameter = false

local checkboxItem = UIMenuCheckboxItem.New("checkboxItem", parameter, 1, "description")

checkboxItem.OnCheckboxChanged = function(menu, item, checked)
    parameter = checked
end

this way the checkboxitem will depend on the external declared parameter state and not a fixed true or false

GLiTcH2 commented 7 months ago

Thank you so much!! That worked perfectly.