Advertisement
Will_Redeemed

Toggle-able Checkbox C# (GTA5 NativeUI)

Aug 8th, 2016
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. 1 - Make a private bool for the checkbox (since it's a toggle it needs to be bool)
  2. public class <menuname> : Script
  3. {
  4.     private bool checkbox = false;
  5.  
  6. 2 - Create the public menu and add a submenu
  7.     public void Menu1(UIMenu menu)
  8.     {
  9.         var sub1 = _menuPool.AddSubMenu(menu, "Menu 1");
  10.        for (int i = 0; i > 1; i++)
  11.         {
  12.        
  13.         }
  14. 3 - Create the checkbox
  15.         var checkbox1 = new UIMenuCheckboxItem("Checkbox 1", checkbox, "Description for Checkbox ~b~Checkbox 1");
  16.        sub1.AddItem(checkbox1);
  17.        checkbox1.Enabled = true;
  18.  
  19.        sub1.OnCheckboxChange += (sender, item, checked_) =>
  20.        {
  21.             if (checked_ == true)   // change "(item == checkbox1)" to "(checked_ == true)"
  22.             // essentials it checks if the checkbox has been checked or not, hence true or false
  23.            {
  24.                 // if it's checked, this happens
  25.                 UI.Notify("~b~Checkbox1 ~w~= ~g~Checked ~w~(This is a notification)");
  26.                 UI.ShowSubtitle("~b~Checkbox1 ~w~= ~g~Checked ~w~(This is a subtitle)");
  27.             }
  28.             else if (checked_ == false)
  29.             {
  30.                 // if it's not checked, this happens
  31.                 UI.Notify("~b~Checkbox1 ~w~= ~r~Not checked ~w~(This is a notification)");
  32.                 UI.ShowSubtitle("~b~Checkbox1 ~w~= ~r~Not checked ~w~(This is a subtitle)");
  33.             }
  34.         };
  35.        
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement