-
Notifications
You must be signed in to change notification settings - Fork 10
Adding the Warehouse Management Menu
Benourson#9496 edited this page Mar 2, 2021
·
1 revision
This script was made in such a way that instead of adding marker and a blip on the map to access the warehouse management menu, thus increasing server performance usage, a small menu item must be added in an already existing menu.
For this tutorial, that is applicable to whatever menu, let's say that you have a mafia job (esx_mafiajob) and want them to be able to manage the warehouses on Los Santos.
- Take your main.lua file located in the client folder and open it.
- Navigate down to the function opening the menu you wish to add the Warehouse Management Menu to.
- Let's say you want to add it to the OpenCloakroomMenu(). Do not be impressed by the size of the function, the lines we will have to add will be near the top of the function.
function OpenCloakroomMenu()
local elements = {
{label = _U('citizen_wear'), value = 'citizen_wear'},
{label = _U('mafia_wear'), value = 'mafia_wear'}
}
ESX.UI.Menu.CloseAll()
if Config.EnableNonFreemodePeds then
table.insert(elements, {label = _U('sheriff_wear'), value = 'sheriff_wear'})
table.insert(elements, {label = _U('lieutenant_wear'), value = 'lieutenant_wear'})
table.insert(elements, {label = _U('commandant_wear'), value = 'commandant_wear'})
end
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'cloakroom',
{
title = _U('cloakroom'),
align = 'top-left',
elements = elements,
},
function(data, menu)
menu.close()
--Taken from SuperCoolNinja
if data.current.value == 'citizen_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
local model = nil
if skin.sex == 0 then
model = GetHashKey("mp_m_freemode_01")
else
model = GetHashKey("mp_f_freemode_01")
end
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(1)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
TriggerEvent('skinchanger:loadSkin', skin)
TriggerEvent('esx:restoreLoadout')
end)
end
if data.current.value == 'mafia_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
else
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
end
end)
end
if data.current.value == 'mafia_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
local model = GetHashKey("G_M_M_ArmBoss_01")
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
else
local model = GetHashKey("G_M_M_ArmBoss_01")
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
end
end)
end
if data.current.value == 'lieutenant_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
local model = GetHashKey("G_M_M_ArmBoss_01")
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
else
local model = GetHashKey("G_M_M_ArmBoss_01")
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
end
end)
end
if data.current.value == 'commandant_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
local model = GetHashKey("G_M_M_ArmBoss_01")
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
else
local model = GetHashKey("G_M_M_ArmBoss_01")
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
end
end)
end
CurrentAction = 'menu_cloakroom'
CurrentActionMsg = _U('open_cloackroom')
CurrentActionData = {}
end,
function(data, menu)
menu.close()
CurrentAction = 'menu_cloakroom'
CurrentActionMsg = _U('open_cloackroom')
CurrentActionData = {}
end
)
end
- First, add the following line
{label = "Warehouse Management", value = 'mafia_warehousemenu'}
Inside the following array :
local elements = {
{label = _U('citizen_wear'), value = 'citizen_wear'},
{label = _U('mafia_wear'), value = 'mafia_wear'}
}
Result :
local elements = {
{label = _U('citizen_wear'), value = 'citizen_wear'},
{label = _U('mafia_wear'), value = 'mafia_wear'},
{label = "Warehouse Management", value = 'mafia_warehousemenu'}
}
Then navigate to the next step.
Beneath the following code :
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'cloakroom',
{
title = _U('cloakroom'),
align = 'top-left',
elements = elements,
},
function(data, menu)
menu.close()
You will find multiple IF/END or IF/ELSE/END statements. Simply insert a new IF/END statement.
Before :
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'cloakroom',
{
title = _U('cloakroom'),
align = 'top-left',
elements = elements,
},
function(data, menu)
menu.close()
--Taken from SuperCoolNinja
if data.current.value == 'citizen_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
local model = nil
if skin.sex == 0 then
model = GetHashKey("mp_m_freemode_01")
else
model = GetHashKey("mp_f_freemode_01")
end
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(1)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
TriggerEvent('skinchanger:loadSkin', skin)
TriggerEvent('esx:restoreLoadout')
end)
end
if data.current.value == 'mafia_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
else
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
end
end)
end
After :
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'cloakroom',
{
title = _U('cloakroom'),
align = 'top-left',
elements = elements,
},
function(data, menu)
menu.close()
-- ADD HERE
if data.current.value == 'warehouse_menu' then
exports["esx_illegalWarehouses"]:OpenWarehousesMenu()
end
-- ADD HERE
--Taken from SuperCoolNinja
if data.current.value == 'citizen_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
local model = nil
if skin.sex == 0 then
model = GetHashKey("mp_m_freemode_01")
else
model = GetHashKey("mp_f_freemode_01")
end
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(1)
end
SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
TriggerEvent('skinchanger:loadSkin', skin)
TriggerEvent('esx:restoreLoadout')
end)
end
if data.current.value == 'mafia_wear' then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
else
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
end
end)
end
Simply upload your freshly modified main.lua file to your client folder and restart the script !