Title basically says all. This is for a project I am working on. Thanks.
yes but the best way is to create a export on vMenu itself then call it from your lua menu to get the menu state to know if its open or not
That’s what I figured would be best. Is this the right place to put it?:
i thing you should add it to vMenuClient and in the public MainMenu() function , and also i dont know how fivem things work on c# but with a little search i saw you have to add
Exports.Add(“isVmenuOpen”, new Action(ExportMethod));
then add ExportMethod function somewhere in the samefile like
public bool ExportMethod()
{
if (MenuController.IsAnyMenuOpen())
{
return true;
}
else
{
return false;
}
}
also you WILL get an error if you just copy paste as i just showed you the way and place , but i cant give more info as i didnt work with fivem c# so you have to get more help or do a little search for how to do it right
Would something like this work? Really appreciate the help btw.
i dont see why it wont give it a try , but ! its not a best solution you know … also triggering the server event on every tick is also NOT good for this thing you want , just create a local value and save the menu status there , and check if the value changed somehow ( menu opened or closed ) THEN you trigger the event
Problem is I’m not sure where the menu is opened and closed through within vMenu’s code. I was gonna have a variable in my lua code like “vMenuOpen” and set it to true or false depending on the event getting triggered. I know it would be better suited if it was just triggered when it happens, but I don’t know where that is in the vMenu code. It’s quite vast
Can you please also let me know if you figure this out? I use a piece of code that uses the up and down arrows and when im in vmenu it triggers it also.
i just told you where to look ! and what is the code to see if the menu is opened or not
read again my answers.
an example to do in vMenu codes,
bool menuStatus = false;
if (MenuController.IsAnyMenuOpen()) // menu is open now
{
if (menuStatus == false) // menu is open but we didnt send the "open" status with trigger
{
//trigger code here
menuStatus = true;
}
}
else
{
if (menuStatus == true) // menu is closed but we didnt send the "close" status with trigger
{
//trigger code here
menuStatus = false;
}
}
Yes, but where are you putting the if statements inside? I need a location lol. vMenu has many different classes.
add it on MainMenu.cs
in the OnTick()
function
Another question, when I try to add it to export, it’s asking for a void method?
Nevermind figured that out. However when I built the project, I couldn’t load into my fivem server and got “Couldn’t load vMenu”
Here is the code I changed:
if (MenuController.IsAnyMenuOpen())
{
if (!menuOpen)
{
menuOpen = true;
TriggerEvent("vMenu:MenuOpened");
}
}
else
{
if (menuOpen)
{
menuOpen = false;
TriggerEvent("vMenu:MenuClosed");
}
}
I put the above inside of the OnTick function as you can see below in full code:
https://hastebin.com/afekehebuy.cs
Anyone know what I did wrong? Thank you.
compile the vMenu again and see if you can load it without any edit then edit it if the compiled version is OK , + make sure your edited version build successfully.
Figured it all out! I built it correctly, but had not known I had to create a __resource.lua for it. Thanks for all the help!