Log in to reply
 

Template for LemonUI C#



  • This is a simple template, I've put braces { on the same line to conserve space. You will need to download the files from here and follow the instructions carefully. Documentation is sparse and examples are not that useful (unless you want big messages). This is just as a starter. After you can add lists, checkboxes, etc.
    Credit goes out to Jitnaught for important components of the template (proper use of on tick and key bindings).

    https://www.gta5-mods.com/tools/lemonui

    alt text

    N.B. In some of the functions i left object sender, EventArgs e
    these are optional depending on what functions you use. Functions are stripped down to keep things simple.

    using GTA.Native;
    using LemonUI.Menus;
    using System;
    using GTA.Math;
    using System.Windows.Forms;
    //uses lemon and SHVDN version 2, also added windows forms
    
    namespace LemonUI.Menu1
    {
    
        public class Basics : Script
        {
            private static readonly ObjectPool DemoPool = new ObjectPool();
            private static readonly NativeMenu DemoMenu = new NativeMenu("Put your menu name here", " ", " ");
            
            //start of Top Level Items, at top of menu, not part of submenu
            private static readonly NativeItem ClearWeather = new NativeItem("Clear Weather", "");
            private static readonly NativeItem CarGuy = new NativeItem("Change to Car Guy Model", "");
            
            //start of Submenu
            private static readonly NativeMenu DemoSubMenuPed = new NativeMenu("Peds", "Ped Gangs", "");  //The first submenu
            private static readonly NativeItem Ballas = new NativeItem("Ballas and Family", "Description"); //Item 1 of submenu
            private static readonly NativeItem LostMCGang = new NativeItem("Import Export", "Description"); //Item 2 of submenu
            
            public Basics()
            {
                //How you order items below doesn't matter
                DemoPool.Add(DemoMenu); // The pool is container for your menus, add the menu
                DemoPool.Add(DemoSubMenuPed); // add first submenu
    
                //standalone items to add to menu
                DemoMenu.Add(ClearWeather);
                DemoMenu.Add(CarGuy);
    
                //Items for SubMenu Ped
                DemoMenu.AddSubMenu(DemoSubMenuPed); //the submenu
                DemoSubMenuPed.Add(Ballas); // item 1
                DemoSubMenuPed.Add(LostMCGang); // item 2
    
                //Misc Items, these are buttons/standalone (menu items without sub menus)
                CarGuy.Activated += SetModelCarGuy;
                ClearWeather.Activated += SetWeatherClear;
    
                //Peds, these are menus with submenu items
                Ballas.Activated += SpawnBallas;
                LostMCGang.Activated += SpawnLostMC;
                
                //
    
                Tick += Basics_Tick;
                KeyDown += Basics_KeyDown; //line added to replace code in Basics_Tick
            }
    
    
            private void SetWeatherClear(object sender, EventArgs e)
            {World.Weather = Weather.Clear;}
    
            private void SetModelCarGuy(object sender, EventArgs e)
            {Game.Player.ChangeModel(PedHash.Car3Guy2);}
    
            private void SpawnLostMC(object sender, EventArgs e)
            { Ped PedLosHair = World.CreatePed(PedHash.Lost01GFY, Game.Player.Character.GetOffsetInWorldCoords(new Vector3(1, 5, 0))); }       
            
            private void SpawnBallas(object sender, EventArgs e)
            {Ped PedFamily = World.CreatePed(PedHash.Families01GFY, Game.Player.Character.GetOffsetInWorldCoords(new Vector3(1, 3, 0)));}
    
            private void SpawnVagos(object sender, EventArgs e)
            { var VALead = World.CreatePed(PedHash.Vagos01GFY, Game.Player.Character.GetOffsetInWorldCoords(new Vector3(1, 2, 0))); }
    
    
            private void Basics_Tick(object sender, EventArgs e)
            { DemoPool.Process(); }        
            
            private void Basics_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.F6) //put whatever key binding you want here
                { DemoMenu.Visible = true; }
            }
        }
    }


  • @JohnFromGWN
    Going to probably be using LemonUI as an option for all of my mods and this really helped make it more convenient. Thanks!



  • @IAmJFry Good choice. In passing, if you use the list with strings, there is an error in the wiki documentation which the author acknowledged (brief comment exchange). He prefers to use enums but I can vouch that the strings work perfectly with one catch. The first item will not show up in the first slot as it does for integers - the solution is very simple, just leave first slot blank, first item goes in second slot.

    private static readonly NativeListItem<String> MyList = new NativeListItem<String>("My Description", "", "Item 1", "Item 2", "Item n"); // nothing between the description and Item 1 except for the double quotes.


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.