(C#) MenuAPI - MAPI v3.0.3 [RedM & FiveM]

Not with MenuAPI, simply because there are not enough images and names for all possible combinations of the heritage options. Rockstar doesn’t use all possible combinations.

Hey guys, I need some help, I am really confused about where i need to put my reference file.
I am working on C# visual studios, I added reference using github. Now when i try to open the menu on keydown, I get the error


And i tried two different variation, I found the file path to the .dll reference for menuAPI , copied it and pasted it into my resource folder names MenuAPI and added a __resource to start the client and go into server config to start it up. Didnt work. So then i tried puting MenuAPI.dll file inside one of the resource folder and added files{“MenuAPI.dll”} and it still didnt work. I have the scripting done, all I need is how to get the reference right.

You have to copy the MenuAPI.dll assembly in the same resource folder of the script which is using it, and be sure that such specific resource has it referenced in its manifest. (fxmanifest.lua)

Example of how your fxmanifest.lua should look like:

fx_version 'bodacious'
games { 'gta5' }

files {
	'MenuAPI.dll'
}

client_scripts {
	'MyClientScript.net.dll'
}

I suggest you to use MenuAPI from nuget

2 Likes

That works, thanks a lot man, guess i was too tired to notice that under __resource.lua i put menuAPI.net.dll

menu.OnItemSelect += (_menu, _item, _index) =>
{
// Code in here would get executed whenever an item is pressed.
Debug.WriteLine($“OnItemSelect: [{_menu}, {_item}, {_index}]”);
};

_menu is the name of the menu you created
_item is the button you placed in the menu
but what is index? I dont get it??
can someone explain to me please?

Index is the item’s index in that specific menu.

Let’s say you have 4 items added to the menu:

MenuItem one = new MenuItem("one");
MenuItem two = new MenuItem("two");
MenuItem three = new MenuItem("three");
MenuItem four= new MenuItem("four");

// make sure to add them in that order.

You select item three:

menu.OnItemSelect += (menu, item, index) =>
{
    // index is now 2
    // item == three
}

Because it has index 2 in the menu.

one has index 0, two has index 1, three has index 2, four has index 3

hey thanks, so you have to spell out one, two and three. I been putting 1, 2 and 3 XD THANK YOU so much!
I appreciate your work man, you made things so EZ

I cant seem to find the problem over here. Everytime when i choose either the LSPD_Male or LSPD_Female button, both skins will turn into female regardless. Could someone point out my error for this please?

This is basic programming knowledge, I suggest you look up some basic C# courses. Because you don’t seem to understand what the code does that you’re writing.

Also take a look at the example menu provided with MenuAPI. And look at how the OnItemSelect event is used there.

Hello, I don’t know if anyone has had this issue before, but I can’t find anything.
Basically, my menu (created with MenuAPI of course), can be reopened indefinitely with the “Menu” key (M), but I don’t want that to happen.
I want the script to control when the menu will be opened, I don’t want the player to be able to reopen that menu whenever they want.

Code:

var menu = new Menu("Character Selection", "Select your character");
menu.InstructionalButtons.Remove(Control.FrontendCancel);
menu.InstructionalButtons.Add(Control.FrontendX, "Variation");
menu.InstructionalButtons.Add(Control.FrontendY, "Accessory");

int i = 1;
foreach (var s in skins)
{
    var item = new MenuItem(s.Name ?? $"Character #{i}");
    item.ItemData = s;
    menu.AddMenuItem(item);
    i++;
}

bool inSelection = true;

// prevents player closing the menu
menu.OnMenuClose += (Menu m) =>
{
    if (inSelection)
        m.Visible = true;
};

// sets the requested model every time the player changes the selection
int selectedPed = 0;
menu.OnIndexChange += async (Menu m, MenuItem oldItem, MenuItem newItem, int oldIndex, int newIndex) =>
{
    if (newItem.ItemData is Skin skin)
    {
        selectedPed = (int)skin.PedHash;
        SetPlayerModel(PlayerId(), (uint)selectedPed);
    }
};

// when the secondary button is pressed, set a random component variation
menu.ButtonPressHandlers.Add(
    new Menu.ButtonPressHandler(
        Control.FrontendX,
        Menu.ControlPressCheckType.JUST_PRESSED,
        new Action<Menu, Control>((m, c) =>
        {
            SetPedRandomComponentVariation(PlayerPedId(), false);
        }), true
    )
);

// when the tertiary button is pressed, set a random prop
menu.ButtonPressHandlers.Add(
    new Menu.ButtonPressHandler(
        Control.FrontendY,
        Menu.ControlPressCheckType.JUST_PRESSED,
        new Action<Menu, Control>((m, c) =>
        {
            SetPedRandomProps(PlayerPedId());
        }), true
    )
);

// when the player chooses a model
menu.OnItemSelect += (Menu m, MenuItem menuItem, int itemIndex) =>
{
    // sets selectModel to false, to allow exiting the method
    inSelection = false;

    if (camera != null)
    {
        RenderScriptCams(false, false, 0, true, false);
        camera.Delete();
        camera = null;
    }

    m.Visible = false;
    m.CloseMenu();
    MenuController.CloseAllMenus();
};

MenuController.AddMenu(menu);
MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
menu.Visible = true;

// block the method here until selectModel stops being true
while (inSelection)
    await Delay(0);

Instructional buttons don’t seem to be working for me, all I see is a blank box.
I am using submenu.InstructionalButtons.Add(Control.Context, "Check"); (copied straight from the example menu)
I don’t see any errors in console. The blank box is still there even if I comment out adding the instructional button

Hello, does anyone know how to change the banner image of a menu?
Example: How to put an image on its menu?

Is drawing the banner as a sprite over the menu banner the only option?

EDIT

You need to set the HeaderTexture property on the Menu.
Example:

Menu.HeaderTexture = new KeyValuePair<string, string>("txdName", "imageName");

Drawing it as a sprite over the menu will glitch, because the order in which the two items will be drawn is not guaranteed and not controllable, so in some ticks it will draw over the menu, and during other ticks it will draw below it

Hello,

I made a stream (\assets\stream) folder + added ‘assets’ within config server file

I’v got few questions :

  • How do I get txdName and imageName from a PNJ file ? What are the steps ?
  • I heard about ytd, is that the texture file ? How do I create my own ?

I really want to change my Header MenuImage but I’m kinda Lost :slight_smile:

ref :
menu.HeaderTexture = new KeyValuePair<string, string>(“txdName”, “imageName”);

You’ll need to put it inside a custom YTD file.
You can use this guide: How to add a custom banner to Vmenu... | The Solution it works the same for any menu created by MenuAPI, not just vMenu. In your case, for a custom menu, you don’t even need to replace the existing one (interaction_bg), you can just make a new texture in that YTD file, give it a custom name, and put it in the streaming folder of your resource. Then change the txdName to the name of the .YTD file, and the imageName to the name of the image inside the .YTD file.

1 Like

Hi there,

First of all, awesome api to use and thanks for sharing!

I’m working on a menu with this api (FiveM GTA) and i’m wondering if there is any way to disable the hotkey.

I can change MenuController.MenuToggleKey to a different Control and this works great. But i’m looking for a way to disable the hotkey all together.
I did find MenuController.DisableMenuButtons, but setting this to true disables all controls.

Or is the only way to edit the API from the sourcecode and use a custom version of it?

Thanks a lot :slight_smile:

You can set it to -1 like this:

MenuController.MenuToggleKey = (Control) -1;
1 Like

Thanks! that did the trick :slight_smile:

Hello, I am trying to make it so after a do a command the menu opens, the documentation says nothing about it, does anyone know how to do it, thanks.

hi. how to disable the key for menuapi? vstancer and vmenu used menuapi but i cant managed to disable the key in another LUA script. i tried DisableControlAction but doesnt work. only work if the menu are nativeui or esx based menu.

This would be amazing to have in JavaScript! :upside_down_face: