critMenu - A scaleform-based menu framework

Have you ever looked at the orbital cannon scaleform and thought: “Damn, I wished I could use that menu on my server”? No? Me neither, but I did it anyway.

critMenu - A menu framework based on the “ORBITAL_CANNON_CAM” Scaleform.

Perks:

  • Extremely lightweight (0.04ms when using the menu!)
  • Completely event-based. The only loop used is for scaleform rendering.
  • Makes use of RegisterKeyMapping(), meaning every user can set their own keybinds!
  • Every easy to use.

Screenshots:

How it works:

Every button has an event assigned to it. Whenever you select a button, that client-side event will be triggered, with the menuID and buttonID as params. With that, you can do whatever you want. Easy.

Grab it!

Github: GitHub - CritteRo/critMenu: Fivem Menu Framework using the Orbital Cannon scaleform.

12 Likes

Ooh nice work on this one ! Thanks for the share!

Not sure where I can use it. But I love it! <3

This is intresting, definetly a fun thing to mess around with!

minor thing, but it might be a better idea to only create the draw thread on menu “open”, then of course kill it once the menu has been closed, that way you arent having a loop for no real reason and such

Thanks all! <3 Scaleform sort of looks like a computer menu…I guess it can be used for that. Also for creating quick menus on your ‘dev’ scripts.

Will have to check. It’s an easy fix, but I also have to make sure that users can’t generate multiple menus on top of each other.

2 Likes

Major Update:
Not gonna lie to y’all, this menu is growing on me.

  • Added SubMenu functionality. You can now create sub-menus, and sub-sub-menus, and sub-sub-sub-menus!

    • Usage: TriggerEvent('critMenu.CreateSubMenu', _menuID, _parentID', _menuTitle, _menuSubtitle, _selectText, _upText, _downText, _quitText)
    • Note: Closing submenus will automatically open the parent. Currently there is not way to fully close a menu from the lower levels.
  • You can now modify the “description” or “tooltip” of an empty menu, meaning that you can create things like this:


    That description supports “\n” and “~color~ formatting”. Does not support instructional buttons or blips.

    • Usage: TriggerEvent('critMenu.ModifyEmptyMenuDescription', _menuID, _newDescription)
  • Added 2 “check” events. 'critMenu.Check.MenuWasClosed' and 'critMenu.Check.MenuWasOpened' will trigger whenever a menu/submenu is opened/closed.

  • Modified Instructional buttons. Now “Select” button will only appear if there is an item that can be used. “Up” and “Down” buttons will appear only if there are 2 or more items.


Notes:
Next on the list is “list” items functionality.

Update 25 Jun 2021

  • Added critMenu.Check.ButtonWasUsed trigger. You can add client-side event handlers that will trigger every time a button is used / selected.
  • Added critMenu.AddMenuButton event.
    • This works the same as the warmenu’s AddMenuButton. Instead of linking it to an event, you link this button to a “Target menuID”. Selecting this button will hide the current menu and open the target menu.
  • Added critMenu.ModifyMenu event. You can modify an existing menuID. Can’t change the menu from a submenu to a primary menu.

Update 03 Jul 2021
Added a TOS menu type. It uses the TOS portion of “ONLINE_POLICIES” scaleform. It’s neat. Looks neat. And I like it :).

  • Added critMenu.CreateTosMenu event.
  • Added critMenu.Check.TosAccepted trigger.
  • Added critMenu.Check.TosDenied trigger.

1 Like

Can you make a example for CreateTosMenu? For me is not working the event ‘critMenu.CreateTosMenu’

Sooo, the Tos menu is a bit weird. That’s because it has pre-defined buttons.

So, you create a menu like this:

--lua
TriggerEvent('critMenu.CreateTosMenu', _menuID, _tosTitle, _tosBody, _acceptButtonText, _declineButtonText)

In order to receive the input, you will have to listen to 2 event handlers, like this:

--lua
AddEventHandler('critMenu.Check.TosDenied', function(menuID)
--Player pressed the Decline button on the tos menu. Menu is closed by default.
end)

AddEventHandler('critMenu.Check.TosAccepted', function(menuID)
--Player pressed the Accept button on the tos menu. Menu is NOT closed by default.
end)

To open, the menu, you use the same event as the normal menus:

--lua
TriggerEvent('critMenu.ShowMenu', menuID)

Why does it work like this? Well… I made it in a rush, and didn’t have the time or energy to make it more “friendly”.

Oh perfect now works fine! the only detail when i press enter nothing happens, i should bind it myself or is a bug? mostly because backspace works fine

the Enter keybind only triggers the 'critMenu.Check.TosAccepted' event. Nothing else. It will not close the menu, or send a sound, or anything. You will have to do that in that event handler.

1 Like