Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OpenPlayerInventoryMenu(property, owner)
- ESX.TriggerServerCallback('esx_property:getPlayerInventory', function(inventory)
- local elements = {}
- if inventory.blackMoney > 0 then
- table.insert(elements, {
- label = _U('dirty_money', ESX.Math.GroupDigits(inventory.blackMoney)),
- type = 'item_account',
- value = 'black_money'
- })
- end
- 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
- for i=1, #inventory.weapons, 1 do
- local weapon = inventory.weapons[i]
- table.insert(elements, {
- label = weapon.label .. ' [' .. weapon.ammo .. ']',
- type = 'item_weapon',
- value = weapon.name,
- ammo = weapon.ammo
- })
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'player_inventory',
- {
- title = property.label .. ' - ' .. _U('inventory'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- if data.current.type == 'item_weapon' then
- menu.close()
- TriggerServerEvent('esx_property:putItem', owner, data.current.type, data.current.value, data.current.ammo)
- ESX.SetTimeout(300, function()
- OpenPlayerInventoryMenu(property, owner)
- end)
- else
- ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'put_item_count', {
- title = _U('amount')
- }, function(data2, menu2)
- local quantity = tonumber(data2.value)
- if quantity == nil then
- ESX.ShowNotification(_U('amount_invalid'))
- else
- menu2.close()
- TriggerServerEvent('esx_property:putItem', owner, data.current.type, data.current.value, tonumber(data2.value))
- ESX.SetTimeout(300, function()
- OpenPlayerInventoryMenu(property, owner)
- end)
- end
- end, function(data2, menu2)
- menu2.close()
- end)
- end
- end, function(data, menu)
- menu.close()
- end)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement