Loorenzos

[NativeUI] Execute Function if button pressed

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.....

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.