simas 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 comment Share on other sites More sharing options...
offsetx Posted January 9, 2021 Share Posted January 9, 2021 (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, 2021 by offsetx 1 Link to comment Share on other sites More sharing options...
simas Posted February 27, 2021 Author Share Posted February 27, 2021 On 1/9/2021 at 2:31 AM, offsetx said: 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; }); }) Hello sir, i hope i will complete it my self but when i use native.ItemSelect.on(item => { mp.game.graphics.notify("itemass "+item.price); i get undefined or native.ListChange.on((item, index) => { amount = index + 1; mp.game.graphics.notify("zzz "+item.price); }); i get nothing at all can you correct me ? Link to comment Share on other sites More sharing options...
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