mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Use new boss menu + Add chest
This commit is contained in:
+135
-64
@@ -96,12 +96,12 @@ function OpenMecanoActionsMenu()
|
||||
local elements = {
|
||||
{label = 'Sortir Véhicule', value = 'vehicle_list'},
|
||||
{label = 'Tenue de travail', value = 'cloakroom'},
|
||||
{label = 'Tenue civile', value = 'cloakroom2'}
|
||||
{label = 'Tenue civile', value = 'cloakroom2'},
|
||||
{label = 'Déposer Stock', value = 'put_stock'},
|
||||
{label = 'Prendre Stock', value = 'get_stock'}
|
||||
}
|
||||
if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.grade_name == 'boss' then
|
||||
table.insert(elements, {label = 'Retirer argent société', value = 'withdraw_society_money'})
|
||||
table.insert(elements, {label = 'Déposer argent ', value = 'deposit_money'})
|
||||
table.insert(elements, {label = 'Blanchir argent', value = 'wash_money'})
|
||||
table.insert(elements, {label = 'Action Patron', value = 'boss_actions'})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
@@ -187,68 +187,20 @@ function OpenMecanoActionsMenu()
|
||||
end)
|
||||
end
|
||||
|
||||
if data.current.value == 'withdraw_society_money' then
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'withdraw_society_money_amount',
|
||||
{
|
||||
title = 'Montant du retrait'
|
||||
},
|
||||
function(data, menu)
|
||||
local amount = tonumber(data.value)
|
||||
if amount == nil then
|
||||
ESX.ShowNotification('Montant invalide')
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:withdrawMoney', 'mecano', amount)
|
||||
end
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
if data.current.value == 'put_stock' then
|
||||
OpenPutStocksMenu()
|
||||
end
|
||||
|
||||
if data.current.value == 'get_stock' then
|
||||
OpenGetStocksMenu()
|
||||
end
|
||||
|
||||
if data.current.value == 'boss_actions' then
|
||||
TriggerEvent('esx_society:openBossMenu', 'mecano', function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
end
|
||||
|
||||
if data.current.value == 'deposit_money' then
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'deposit_money_amount',
|
||||
{
|
||||
title = 'Montant du dépôt'
|
||||
},
|
||||
function(data, menu)
|
||||
local amount = tonumber(data.value)
|
||||
if amount == nil then
|
||||
ESX.ShowNotification('Montant invalide')
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:depositMoney', 'mecano', amount)
|
||||
end
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
if data.current.value == 'wash_money' then
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'wash_money_amount',
|
||||
{
|
||||
title = 'Montant à blanchir'
|
||||
},
|
||||
function(data, menu)
|
||||
local amount = tonumber(data.value)
|
||||
if amount == nil then
|
||||
ESX.ShowNotification('Montant invalide')
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:washMoney', 'mecano', amount)
|
||||
end
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
end
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
@@ -643,6 +595,125 @@ function OpenMobileMecanoActionsMenu()
|
||||
)
|
||||
end
|
||||
|
||||
function OpenGetStocksMenu()
|
||||
|
||||
ESX.TriggerServerCallback('esx_mecanojob:getStockItems', function(items)
|
||||
|
||||
print(json.encode(items))
|
||||
|
||||
local elements = {}
|
||||
|
||||
for i=1, #items, 1 do
|
||||
table.insert(elements, {label = 'x' .. items[i].count .. ' ' .. items[i].label, value = items[i].name})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'stocks_menu',
|
||||
{
|
||||
title = 'Mecano Stock',
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local itemName = data.current.value
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count',
|
||||
{
|
||||
title = 'Quantité'
|
||||
},
|
||||
function(data2, menu2)
|
||||
|
||||
local count = tonumber(data2.value)
|
||||
|
||||
if count == nil then
|
||||
ESX.ShowNotification('Quantité invalide')
|
||||
else
|
||||
menu2.close()
|
||||
menu.close()
|
||||
OpenGetStocksMenu()
|
||||
|
||||
TriggerServerEvent('esx_mecanojob:getStockItem', itemName, count)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
function OpenPutStocksMenu()
|
||||
|
||||
ESX.TriggerServerCallback('esx_mecanojob:getPlayerInventory', function(inventory)
|
||||
|
||||
local elements = {}
|
||||
|
||||
for i=1, #inventory.items, 1 do
|
||||
|
||||
local item = inventory.items[i]
|
||||
|
||||
if item.count > 0 then
|
||||
table.insert(elements, {label = item.label .. ' x' .. item.count, type = 'item_standard', value = item.name})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'stocks_menu',
|
||||
{
|
||||
title = 'Inventaire',
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local itemName = data.current.value
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count',
|
||||
{
|
||||
title = 'Quantité'
|
||||
},
|
||||
function(data2, menu2)
|
||||
|
||||
local count = tonumber(data2.value)
|
||||
|
||||
if count == nil then
|
||||
ESX.ShowNotification('Quantité invalide')
|
||||
else
|
||||
menu2.close()
|
||||
menu.close()
|
||||
OpenPutStocksMenu()
|
||||
|
||||
TriggerServerEvent('esx_mecanojob:putStockItems', itemName, count)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
RegisterNetEvent('esx_mecanojob:onHijack')
|
||||
AddEventHandler('esx_mecanojob:onHijack', function()
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
@@ -275,4 +275,83 @@ ESX.RegisterUsableItem('carokit', function(source)
|
||||
TriggerClientEvent('esx_mecanojob:onCarokit', _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, 'Vous avez utilisé un ~b~Kit de carosserie')
|
||||
|
||||
end)
|
||||
|
||||
----------------------------------
|
||||
---- Ajout Gestion Stock Boss ----
|
||||
----------------------------------
|
||||
|
||||
RegisterServerEvent('esx_mecanojob:getStockItem')
|
||||
AddEventHandler('esx_mecanojob:getStockItem', function(itemName, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mecano', function(inventory)
|
||||
|
||||
local item = inventory.getItem(itemName)
|
||||
|
||||
if item.count >= count then
|
||||
inventory.removeItem(itemName, count)
|
||||
xPlayer.addInventoryItem(itemName, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, 'Quantité invalide')
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, 'Vous avez retiré x' .. count .. ' ' .. item.label)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_mecanojob:getStockItems', function(source, cb)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mecano', function(inventory)
|
||||
cb(inventory.items)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
-------------
|
||||
-- AJOUT 2 --
|
||||
-------------
|
||||
|
||||
RegisterServerEvent('esx_mecanojob:putStockItems')
|
||||
AddEventHandler('esx_mecanojob:putStockItems', function(itemName, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mecano', function(inventory)
|
||||
|
||||
local item = inventory.getItem(itemName)
|
||||
|
||||
if item.count >= 0 then
|
||||
xPlayer.removeInventoryItem(itemName, count)
|
||||
inventory.addItem(itemName, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, 'Quantité invalide')
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, 'Vous avez ajouté x' .. count .. ' ' .. item.label)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
--ESX.RegisterServerCallback('esx_mecanojob:putStockItems', function(source, cb)
|
||||
|
||||
-- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_policestock', function(inventory)
|
||||
-- cb(inventory.items)
|
||||
-- end)
|
||||
|
||||
--end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_mecanojob:getPlayerInventory', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local items = xPlayer.inventory
|
||||
|
||||
cb({
|
||||
items = items
|
||||
})
|
||||
|
||||
end)
|
||||
Reference in New Issue
Block a user