ActionMenu
ActionMenu is a html/js based quick select style menu, it consists of a group of buttons that can each be set to perform a different task, many other communities have this, like DOJ and SOE, but none of them are public.
I noticed other members of the community trying to create a menu like this, however I felt like they lacked some form of automation. New buttons and sub-menus can easily be added, without the need of modifying the JavaScript, or adding more code. All of the code files included in this resource have been commented thoroughly to make it easy for you to understand.
IF YOUR BUTTONS DO NOT WORK, MAKE SURE YOU HAVE NOT RENAMED THE RESOURCE, OR CHANGE THE RESOURCE NAME ON LINE 117 OF ui.js
This is an example resource, which you must add to in order for it to become usable in your server/gamemode. It is recommended that you only use this if you have experience with Lua and HTML.
Press āZā (ID: 20) by default to open the menu.
How to add a new button
To add a new button, use the following template, and place the button inside the mainmenu div, or a sub-menu div in the ui.html file:
<button class="menuoption" data-action="buttonaction">Button Name</button>
The Button Name is what the text that will display on the button, and the data-action is what the NUI Callback receives when you click the button. You must make sure that all buttons you add have the menuoption class, otherwise they will not work. So say I wanted to add a hands up button, I would put:
<button class="menuoption" data-action="handsup">Put Hands Up</button>
How to add a new sub-menu
To add a new sub-menu, use the following template, and place the div inside of the actionmenu div in of the ui.html file:
<div id="submenuname" data-parent="mainmenu" style="display: none;">
<!-- buttons -->
</div>
If you look inside of the ui.html file, you will see how Iāve set up the sub-menus. In order for a sub-menu to be opened, you must set up a button with a data-sub attribute, that is equal to the ID of the sub-menu div.
Download
Click here to download [1.0.1]
Click here to download [1.0.0]
Installation
- Download the latest version above
- Extract the wk_actionmenu folder from the .zip file into your resources folder
- Add āstart wk_actionmenuā into your server.cfg
Changelog
Version 1.0.1
- Fixed buttons overflowing off the screen
- Localised the font file
- Gave the buttons a graphical update
- Pressing ESC when the menu is open now closes it
- Added a " >>" indicator to help identify submenus
- Back and Exit buttons now get automatically generated for every submenu
Version 1.0.0
- Initial release
License
I give full permission for anyone to modify and re-upload this resource, the only thing that I ask is that I be credited in the upload.
Credits
Me - writing the script and making it do cool shit.
@lowheartrate - I used some of his work as a base
@Briglair - Helping with a few issues on @lowheartrateās post
@TheStonedTurtle - Helping me with the JavaScript side