JaksamHEX Menu API
Installation
Here you will get the full Installation guide to setup our Menu Default Replacement with Jaksams creators.
Menu Default Replacement
To install our HEX Menu API for Jaksams resources, follow these steps:
Open the file
Open your Jaksam resource folder and navigate to _modules/menu/menu_default. Then open the file named cl_menu.lua.
Copy code
Copy the Client Menu code and replace the existing code in cl_menu.lua.
local moduleType = "menu" -- Module category
local moduleName = "menu_default" -- THIS module name
-- Don't touch, required to appear in in-game settings
Integrations.modules = Integrations.modules or {}
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
table.insert(Integrations.modules[moduleType], moduleName)
if GetResourceState('hex_menu_api') == 'started' then
while ESX == nil do
Citizen.Wait(100)
end
Citizen.Wait(100)
local isJobsCreator = GetCurrentResourceName() == 'jobs_creator'
local _openInteractionMenu = Utils.openInteractionMenu
local _openCraftingTable = openCraftingTable
local function hookMenu()
local ESX_UI_MENU_OPEN = ESX.UI.Menu.Open
local ESX_UI_MENU_CLOSE = ESX.UI.Menu.Close
local ESX_UI_MENU_CLOSE_ALL = ESX.UI.Menu.CloseAll
if isJobsCreator then
local currentTableId = nil
local recipeIndex = nil
openCraftingTable = function(tableId)
currentTableId = tableId
return _openCraftingTable(tableId)
end
-- fix for crafting table in jobs creator since he uses the "type" for checking if its a crafting button...
Utils.openInteractionMenu = function(...)
local args = {...}
local interactionName = args[1]
local submitCb = args[4]
if interactionName == 'crafting_table_recipe' then
submitCb = function(_, _, data)
if data.value ~= 'inputQuantity' then return end
local amount = Utils.askQuantity(getLocalizedText("craft_amount"))
print(Utils.eventsPrefix .. ":craftItem", currentTableId, recipeIndex, amount)
TriggerServerEvent(Utils.eventsPrefix .. ":craftItem", currentTableId, recipeIndex, amount)
Utils.hideInteractionMenu()
end
_openInteractionMenu(interactionName, args[2], args[3], submitCb, table.unpack(args, 5))
return
elseif interactionName == 'crafting_table' then
newSubmitCb = function(_, _, data)
recipeIndex = data.craftingIndex
submitCb(_, _, data)
end
_openInteractionMenu(interactionName, args[2], args[3], newSubmitCb, table.unpack(args, 5))
return
end
return _openInteractionMenu(...)
end
end
ESX.UI.Menu.Open = function(menuType, namespace, name, data, submit, cancel, change, close)
if menuType ~= "default" then
return ESX_UI_MENU_OPEN(menuType, namespace, name, data, submit, cancel, change, close)
end
for k, v in pairs(data.elements) do
v.title = v.label
if isJobsCreator then
if v.type == 'inputQuantity' then
v.type = 'button'
v.value = 'inputQuantity'
end
end
end
return exports['hex_menu_api']:rageOpen(namespace, name, data, submit, cancel, change, close)
end
ESX.UI.Menu.Close = function(menuType, namespace, name, cancel)
if menuType ~= "default" then
return ESX_UI_MENU_CLOSE(menuType, namespace, name, cancel)
end
return exports['hex_menu_api']:closeMenu(namespace, name)
end
ESX.UI.Menu.CloseAll = function()
exports['hex_menu_api']:rageCloseAll()
ESX_UI_MENU_CLOSE_ALL()
end
-- in case the esx_menu_default is deleted or not started, we need to register the default menu type to avoid errors.
ESX.UI.Menu.RegisteredTypes.default = true
end
hookMenu()
RegisterNetEvent('jobs_creator:refreshJobs', function()
if SECONDS_TO_REFRESH_SHARED_OBJECT then
Citizen.Wait(SECONDS_TO_REFRESH_SHARED_OBJECT * 1000)
end
Citizen.Wait(100)
hookMenu()
end)
endRestart Resource
Restart your Jaksam resource to apply the changes.