Jump to content

[NativeUI] Execute Function if button pressed


Loorenzos

Recommended Posts

Hey im new with RageMP i was developping on FiveM before and i make an admin menu and so.. i have a question

There is a way with NativeUI to do something like if UIMenuItem is Pressed then execute Function

if yes how can i do because every ways i saw with nativeui was only in Boolean.....

Link to comment
Share on other sites

ui = new Menu("Test", "", new Point(1440, 20));
ui.AddItem(new UIMenuItem("do something", "description text"));
ui.ItemSelect.on( (item, index) => {
if(item.Text === "do something") mp.events.call("doSomeThing", player, options);
});

 

Edited by cmdflow
Link to comment
Share on other sites

6 minutes ago, cmdflow said:

ui = new Menu("Test", "", new Point(1440, 20));
ui.AddItem(new UIMenuItem("do something", "description text"));
ui.ItemSelect.on( (item, index) => {
if(item.Text === "do something") mp.events.call("doSomeThing", player, options);
}

 

yeah i saw this one but as i say its in boolean like if item  == .... then ... but i want something that just detect if i pressed the button to execute my function

Edited by Loorenzos
Link to comment
Share on other sites

I think i don't understand what you want to achieve because if you just want to press a button without having options then you simply do:

ui.ItemSelect.on( (item, index) => {
yourFancyFunction(); // or yourFanyFunction(item.text);
}
Edited by cmdflow
Link to comment
Share on other sites

5 minutes ago, cmdflow said:

I think i don't understand what you want to achieve because if you just want to press a button without having options then you simply do:


ui.ItemSelect.on( (item, index) => {
yourFancyFunction(); // or yourFanyFunction(item.text);
}

I will test that thx for ur help and sry ^^ i just started to learn the ragemp api 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...