frodzet Posted May 25, 2015 Share Posted May 25, 2015 (edited) Greetings, So i'm working on this new Mod Menu, and i have this List<VehicleHash> vehicleList where i have stored all the game's vehicle hashes in. Now i need to add a new MenuButton for each of these vehicles, the question is how i should go about doing this. Usually a Menu and a MenuButton can be added this way: GTA.Menu playerMenu = new GTA.Menu("Player", new MenuItem[] { // Wanted Up - Increase Wanted Level by 1 new GTA.MenuButton("Wanted Up", () => { if (player.WantedLevel < 5) player.WantedLevel++; }),}); What i would like to do is something like: foreach (VehicleHash vehicle in vehicleList){ // Create a new menu button // ... where content is equal to vehicle's name // and then an action that would be equivalent for all vehicles.} So basically what i want to do is add a new Button in my menu for each vehicle added to my vehicleList. It does not have to be with a List and a foreach loop (that's just the furthest my logic goes for now), if there is a better approach let me know. Thank you! EDIT: I have no idea where to start! :-) Edited May 25, 2015 by frodzet Link to comment Share on other sites More sharing options...
Reck1501 Posted May 25, 2015 Share Posted May 25, 2015 Hey, I'm also working on a mod menu, although I gotta admit that it gets boring fairly fast when doing it all by yourself, so if you'd like to team up we could do that (p.s, I'm also danish) On topic: I might be able to provide what you need, although I'm not completely sure that I can do it. I'm going to try and give you the code that I come up with Link to comment Share on other sites More sharing options...
frodzet Posted May 25, 2015 Author Share Posted May 25, 2015 Hey, I'm also working on a mod menu, although I gotta admit that it gets boring fairly fast when doing it all by yourself, so if you'd like to team up we could do that (p.s, I'm also danish) On topic: I might be able to provide what you need, although I'm not completely sure that I can do it. I'm going to try and give you the code that I come up with Well sure, we can talk about that: add me on my very old skype account: sifferjb i believe it is. Link to comment Share on other sites More sharing options...
Inco Posted May 25, 2015 Share Posted May 25, 2015 (edited) var buttonsList = new List<MenuButton>(); foreach (VehicleHash vehicle in vehicleList) { buttonsList.Add( new MenuButton( vehicle.ToString(), () => { MyButtonClick(vehicle); } ) ); } var menu = new Menu( "Vehicles", buttonsList.ToArray() ); ... private void MyButtonClick(VehicleHash veh) { // spawn car } Edited May 25, 2015 by Inco frodzet 1 Link to comment Share on other sites More sharing options...
frodzet Posted May 25, 2015 Author Share Posted May 25, 2015 var buttonsList = new List<MenuButton>();foreach (VehicleHash vehicle in vehicleList){ buttonsList.Add( new MenuButton( vehicle.ToString(), () => { MyButtonClick(vehicle); } ) );}var menu = new Menu( "Vehicles", buttonsList.ToArray() );...private void MyButtonClick(VehicleHash veh){// spawn car} THANK YOU! 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