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