Mod Menu
-
How to remove / update items in mod menu
-
Please be more specific.
-
@Jitnaught I use NativeUI to create a mod menu. Is the subject of "Weed". Player can collect the "Weed " on the plantation. When collecting weed, weed is added to your inventory. It turns out
And I can't figure out how to make sure the item isn't added, it's updated. My code at the moment, here's a:
public class Class1 : Script
{//Menu MenuPool modMenuPool; UIMenu mainMenu; //UIMenuItem Weed = new UIMenuItem("Травка " + Take_weed); //Weed = new UIMenuItem("Травка " + Take_weed); public static bool INV_Weed = false; public static int Take_weed = 0; public static int Weed_Max_InBug = 50; public Class1() { Setup_Menu() this.Interval = 5; this.Tick += new EventHandler(this.onTick); KeyDown += onKeyDown; } void Setup_Menu() { modMenuPool = new MenuPool(); mainMenu = new UIMenu("Инвентарь", "Выберите предмет:"); modMenuPool.Add(mainMenu); } private void onKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.I && !modMenuPool.IsAnyMenuOpen()) { mainMenu.Visible = !mainMenu.Visible; } // if (World.GetDistance(Game.Player.Character.Position, Weed_1) < 3f && Take_weed <= Weed_Max_InBug) { toolTip("Нажмите Е, чтобы начать сбор травки"); if (e.KeyCode == Keys.E) { Take_weed += 1; Game.Player.Character.Task.PlayAnimation("mp_common", "givetake1_b", 8f, -1, (AnimationFlags)16); Script.Wait(3000); INV_Weed = true; UI.Notify("+1 Травка"); } else if (Take_weed >= Weed_Max_InBug) { UI.Notify("Вы забиты травкой"); } } } void onTick(object sender, EventArgs e) { // if (modMenuPool != null) modMenuPool.ProcessMenus(); // if (INV_Weed == true && Take_weed >0) { UIMenuItem Weed = new UIMenuItem("Травка " + Take_weed); mainMenu.AddItem(Weed); INV_Weed = false; } return; } void toolTip(string text) { Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING"); Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text); Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1); } }
-
@CaTBaT Because you are creating an object as a MenuItem, and adding that Item to menu onTick basis.
void onTick(object sender, EventArgs e)
{
//
if (modMenuPool != null) modMenuPool.ProcessMenus();
//
if (INV_Weed == true && Take_weed >0)
{
UIMenuItem Weed = new UIMenuItem("Травка " + Take_weed);
mainMenu.AddItem(Weed);
INV_Weed = false; }
return;
}