You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, sorry I am new to this side of RagePlugin.. I'm not quite sure what I have done wrong as I have copied the Example code to just get a menu opening and working but yet its not.
I have it placed under GrandTheftAutoV/Plugins & GrandTheftAutoV/Plugins/LSPDFR but none seem to work... Not sure what to do
namespace Ped_Interaction_Menu
{
using System;
using System.Linq;
using System.Security.Policy;
using System.Windows.Forms;
using Rage;
using Rage.Attributes;
using Rage.Native;
using RAGENativeUI;
using RAGENativeUI.Elements;
using RAGENativeUI.PauseMenu;
internal static class PedInteractionMenu
{
private static MenuPool pool;
private static UIMenu mainMenu;
private static readonly Keys Keybinding = Keys.K;
private static void Main()
{
pool = new MenuPool();
mainMenu = new UIMenu("Ped Interactions", "Version ~o~1.0.0");
{
var cb = new UIMenuCheckboxItem("Checkbox", false, "A Checkbox menu Item");
cb.CheckboxEvent += (item, isChecked) => Game.DisplaySubtitle($"The Checkbox is {(isChecked ? "" : "~r~not~s~")} checked");
var spawnCar = new UIMenuItem("Spawn car", "Spawns a random car after 5 seconds.");
spawnCar.Activated += (menu, item) =>
{
// disable the item so the user cannot activate it again until the car has spawned
spawnCar.Enabled = false;
GameFiber.StartNew(() =>
{
// 5 second countdown
for (int sec = 5; sec > 0; sec--)
{
// show the countdown in the menu description
mainMenu.DescriptionOverride = $"The car will spawn in ~b~{sec}~s~ second(s).";
GameFiber.Sleep(1000); // sleep for 1 second
}
// remove the countdown from the description
mainMenu.DescriptionOverride = null;
// spawn the random car
new Vehicle(m => m.IsCar, Game.LocalPlayer.Character.GetOffsetPositionFront(5.0f)).Dismiss();
// wait a bit and re-enable the item
GameFiber.Sleep(500);
spawnCar.Enabled = true;
});
};
mainMenu.AddItems(cb, spawnCar);
}
// create a child menu
UIMenu childMenu = new UIMenu("RAGENativeUI", "CHILD MENU");
// create a new item in the main menu and bind the child menu to it
{
UIMenuItem bindItem = new UIMenuItem("Go to child menu");
mainMenu.AddItem(bindItem);
mainMenu.BindMenuToItem(childMenu, bindItem);
bindItem.RightBadge = UIMenuItem.BadgeStyle.Star;
mainMenu.OnIndexChange += (menu, index) => mainMenu.MenuItems[index].RightBadge = UIMenuItem.BadgeStyle.None;
}
// create the child menu items
childMenu.AddItems(Enumerable.Range(1, 50).Select(i => new UIMenuItem($"Item #{i}")));
// add all the menus to the pool
pool.Add(mainMenu, childMenu);
// start the fiber which will handle drawing and processing the menus
GameFiber.StartNew(ProcessMenus);
// continue with the plugin...
Game.Console.Print($" Press {Keybinding} to open the menu.");
Game.DisplayHelp($"Press ~{Keybinding.GetInstructionalId()}~ to open the menu.");
}
private static void ProcessMenus()
{
// draw the menu banners (only needed if UIMenu.SetBannerType(Rage.Texture) is used)
// Game.RawFrameRender += (s, e) => pool.DrawBanners(e.Graphics);
while (true)
{
GameFiber.Yield();
pool.ProcessMenus();
if (Game.IsKeyDown(Keybinding) && !UIMenu.IsAnyMenuVisible && !TabView.IsAnyPauseMenuVisible)
{
mainMenu.Visible = true;
}
}
}
// a command that simulates loading the plugin
[ConsoleCommand("LoadPI")]
private static void RunMenuExample() => GameFiber.StartNew(Main);
}
}
The text was updated successfully, but these errors were encountered:
Hi there, sorry I am new to this side of RagePlugin.. I'm not quite sure what I have done wrong as I have copied the Example code to just get a menu opening and working but yet its not.
I have it placed under GrandTheftAutoV/Plugins & GrandTheftAutoV/Plugins/LSPDFR but none seem to work... Not sure what to do
The text was updated successfully, but these errors were encountered: