mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 09:01:32 +00:00
Use new boss menu + Add chest
This commit is contained in:
+136
-80
@@ -286,10 +286,20 @@ function OpenResellerMenu()
|
||||
{label = _U('get_rented_vehicles'), value = 'get_rented_vehicles'},
|
||||
{label = _U('set_vehicle_owner_sell'), value = 'set_vehicle_owner_sell'},
|
||||
{label = _U('set_vehicle_owner_rent'), value = 'set_vehicle_owner_rent'},
|
||||
{label = 'Déposer Stock', value = 'put_stock'},
|
||||
{label = 'Prendre Stock', value = 'get_stock'}
|
||||
}
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
if data.current.value == 'put_stock' then
|
||||
OpenPutStocksMenu()
|
||||
end
|
||||
|
||||
if data.current.value == 'get_stock' then
|
||||
OpenGetStocksMenu()
|
||||
end
|
||||
|
||||
if data.current.value == 'pop_vehicle' then
|
||||
OpenPopVehicleMenu()
|
||||
end
|
||||
@@ -559,10 +569,8 @@ function OpenBossActionsMenu()
|
||||
title = _U('dealer_boss'),
|
||||
align = 'top-left',
|
||||
elements = {
|
||||
{label = _U('buy_vehicle'), value = 'buy_vehicle'},
|
||||
{label = _U('withdraw_money'), value = 'withdraw_society_money'},
|
||||
{label = _U('deposit_money'), value = 'deposit_money'},
|
||||
{label = _U('wash_money'), value = 'wash_money'}
|
||||
{label = _U('buy_vehicle'), value = 'buy_vehicle'},
|
||||
{label = 'Action Patron', value = 'boss_actions'}
|
||||
}
|
||||
},
|
||||
function(data, menu)
|
||||
@@ -571,82 +579,10 @@ function OpenBossActionsMenu()
|
||||
OpenShopMenu()
|
||||
end
|
||||
|
||||
if data.current.value == 'withdraw_society_money' then
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'withdraw_society_money_amount',
|
||||
{
|
||||
title = _U('withdraw_amount'),
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local amount = tonumber(data.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(_U('invalid_amount'))
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:withdrawMoney', 'cardealer', amount)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
if data.current.value == 'deposit_money' then
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'deposit_money_amount',
|
||||
{
|
||||
title = _U('deposit_money'),
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local amount = tonumber(data.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(_U('invalid_amount'))
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:depositMoney', 'cardealer', 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 = _U('bleach_amount'),
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local amount = tonumber(data.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(_U('invalid_amount'))
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:washMoney', 'cardealer', amount)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
if data.current.value == 'boss_actions' then
|
||||
TriggerEvent('esx_society:openBossMenu', 'cardealer', function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
end
|
||||
|
||||
end,
|
||||
@@ -663,6 +599,126 @@ function OpenBossActionsMenu()
|
||||
|
||||
end
|
||||
|
||||
|
||||
function OpenGetStocksMenu()
|
||||
|
||||
ESX.TriggerServerCallback('esx_vehicleshop: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 = 'Concession 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_vehicleshop: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_vehicleshop: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_vehicleshop:putStockItems', itemName, count)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ INSERT INTO `addon_account` (name, label, shared) VALUES
|
||||
('society_cardealer','Händler',1)
|
||||
;
|
||||
|
||||
INSERT INTO `addon_inventory` (name, label, shared) VALUES
|
||||
('society_cardealer','Concesionnaire',1)
|
||||
;
|
||||
|
||||
INSERT INTO `jobs` (name, label) VALUES
|
||||
('cardealer','Händler')
|
||||
;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
USE `essentialmode`;
|
||||
|
||||
INSERT INTO `addon_inventory` (name, label, shared) VALUES
|
||||
('society_cardealer','Concesionnaire',1)
|
||||
;
|
||||
|
||||
INSERT INTO `jobs` (name, label) VALUES
|
||||
('cardealer','Händler')
|
||||
;
|
||||
|
||||
@@ -4,6 +4,10 @@ INSERT INTO `addon_account` (name, label, shared) VALUES
|
||||
('society_cardealer','Concessionnaire',1)
|
||||
;
|
||||
|
||||
INSERT INTO `addon_inventory` (name, label, shared) VALUES
|
||||
('society_cardealer','Concesionnaire',1)
|
||||
;
|
||||
|
||||
INSERT INTO `jobs` (name, label) VALUES
|
||||
('cardealer','Concessionnaire')
|
||||
;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
USE `essentialmode`;
|
||||
|
||||
INSERT INTO `addon_inventory` (name, label, shared) VALUES
|
||||
('society_cardealer','Concesionnaire',1)
|
||||
;
|
||||
|
||||
INSERT INTO `jobs` (name, label) VALUES
|
||||
('cardealer','Concessionnaire')
|
||||
;
|
||||
|
||||
@@ -163,6 +163,50 @@ AddEventHandler('esx_vehicleshop:setVehicleForAllPlayers', function(props, x, y,
|
||||
TriggerClientEvent('esx_vehicleshop:setVehicle', -1, props, x, y, z, radius)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_vehicleshop:getStockItem')
|
||||
AddEventHandler('esx_vehicleshop:getStockItem', function(itemName, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_vehicleshop', 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)
|
||||
|
||||
RegisterServerEvent('esx_vehicleshop:putStockItems')
|
||||
AddEventHandler('esx_vehicleshop:putStockItems', function(itemName, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_vehicleshop', 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_vehicleshop:getCategories', function(source, cb)
|
||||
cb(Categories)
|
||||
end)
|
||||
@@ -397,6 +441,26 @@ ESX.RegisterServerCallback('esx_vehicleshop:resellVehicle', function(source, cb,
|
||||
|
||||
end)
|
||||
|
||||
|
||||
ESX.RegisterServerCallback('esx_vehicleshop:getStockItems', function(source, cb)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_vehicleshop', function(inventory)
|
||||
cb(inventory.items)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_vehicleshop:getPlayerInventory', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local items = xPlayer.inventory
|
||||
|
||||
cb({
|
||||
items = items
|
||||
})
|
||||
|
||||
end)
|
||||
|
||||
if Config.EnablePvCommand then
|
||||
|
||||
TriggerEvent('es:addCommand', 'pv', function(source, args, user)
|
||||
|
||||
Reference in New Issue
Block a user