simas 0 Posted December 2, 2020 Share Posted December 2, 2020 Hello i understand slider, checkbox but don't understand how to set data on list items i new to rage scripting and i wish to understand better how things work ui.AddItem(new UIMenuListItem( "menu item text", "menu item description goes here", new ItemsCollection(["erty", "abc"]), // i understand how to add items but how set data for them because ui.ItemSelect.on(item => { if (item instanceof UIMenuListItem) { console.log(item.SelectedItem.DisplayText, item.SelectedItem.Data); mp.game.graphics.notify(`"${item.Text}". ${item.SelectedItem.Data}`); ***************** // i get data as nill or null *********************** } else if (item instanceof UIMenuSliderItem) { console.log(item.Text, item.Index, item.IndexToItem(item.Index)); mp.game.graphics.notify(`text "${item.Text}". index ${item.Index} indextoitem ${item.IndexToItem(item.Index)}`); } else { console.log(item.Text); mp.game.graphics.notify(`"${item.Text}".`); } }); Link to post Share on other sites
offsetx 1 Posted January 9 Share Posted January 9 (edited) mp.events.add("loop",() => { let amount = 1; let data= [{name: "w", price: 200}, {name: "w", price: 200}]; let array = [0, 1, 2, 3, 4, 5, 6, 7, 8]; const native = new Menu("HELLO WORLD", " ", resolution); let list = new UIMenuListItem("list", "something..", new ItemsCollection(array)); native.AddItem(list); data.forEach(item => { let _item = new UIMenuItem("name: " + item.name, "price: " + item.price); native.AddItem(_item); }) native.ListChange.on((item, index) => { amount = index + 1; }); }) Edited January 9 by offsetx 1 Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now