Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESX = nil
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- if Config.MaxInService ~= -1 then
- TriggerEvent('esx_service:activateService', 'hosameki', Config.MaxInService)
- end
- TriggerEvent('esx_phone:registerNumber', 'hosameki', _U('hosameki_customer'), true, true)
- TriggerEvent('esx_society:registerSociety', 'hosameki', 'hosameki', 'society_hosameki', 'society_hosameki', 'society_hosameki', {type = 'private'})
- RegisterServerEvent('esx_hosameki:getStockItem')
- AddEventHandler('esx_hosameki:getStockItem', function(itemName, count)
- local xPlayer = ESX.GetPlayerFromId(source)
- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_hosameki', function(inventory)
- local item = inventory.getItem(itemName)
- if item.count >= count then
- inventory.removeItem(itemName, count)
- xPlayer.addInventoryItem(itemName, count)
- else
- TriggerClientEvent("esx:showNotification", source, 'Quantità non valida!')
- end
- end)
- end)
- ESX.RegisterServerCallback('esx_hosameki:getStockItems', function(source, cb)
- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_hosameki', function(inventory)
- cb(inventory.items)
- end)
- end)
- RegisterServerEvent('esx_hosameki:putStockItems')
- AddEventHandler('esx_hosameki:putStockItems', function(itemName, count)
- local xPlayer = ESX.GetPlayerFromId(source)
- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_hosameki', function(inventory)
- local item = inventory.getItem(itemName)
- local playerItemCount = xPlayer.getInventoryItem(itemName).count
- if item.count >= 0 and count <= playerItemCount then
- xPlayer.removeInventoryItem(itemName, count)
- inventory.addItem(itemName, count)
- else
- TriggerClientEvent("esx:showNotification", source, 'Quantità non valida!')
- end
- end)
- end)
- RegisterServerEvent('esx_hosameki:getFridgeStockItem')
- AddEventHandler('esx_hosameki:getFridgeStockItem', function(itemName, count)
- local xPlayer = ESX.GetPlayerFromId(source)
- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_hosameki_fridge', function(inventory)
- local item = inventory.getItem(itemName)
- if item.count >= count then
- inventory.removeItem(itemName, count)
- xPlayer.addInventoryItem(itemName, count)
- else
- TriggerClientEvent("esx:showNotification", source, 'Quantità non valida!')
- end
- end)
- end)
- ESX.RegisterServerCallback('esx_hosameki:getFridgeStockItems', function(source, cb)
- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_hosameki_fridge', function(inventory)
- cb(inventory.items)
- end)
- end)
- RegisterServerEvent('esx_hosameki:putFridgeStockItems')
- AddEventHandler('esx_hosameki:putFridgeStockItems', function(itemName, count)
- local xPlayer = ESX.GetPlayerFromId(source)
- TriggerEvent('esx_addoninventory:getSharedInventory', 'society_hosameki_fridge', function(inventory)
- local item = inventory.getItem(itemName)
- local playerItemCount = xPlayer.getInventoryItem(itemName).count
- if item.count >= 0 and count <= playerItemCount then
- xPlayer.removeInventoryItem(itemName, count)
- inventory.addItem(itemName, count)
- else
- TriggerClientEvent("esx:showNotification", source, 'Quantità non valida!')
- end
- end)
- end)
- ESX.RegisterServerCallback('esx_hosameki:getVaultWeapons', function(source, cb)
- TriggerEvent('esx_datastore:getSharedDataStore', 'society_hosameki', function(store)
- local weapons = store.get('weapons')
- if weapons == nil then
- weapons = {}
- end
- cb(weapons)
- end)
- end)
- ESX.RegisterServerCallback('esx_hosameki:addVaultWeapon', function(source, cb, weaponName)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- xPlayer.removeWeapon(weaponName)
- TriggerEvent('esx_datastore:getSharedDataStore', 'society_hosameki', function(store)
- local weapons = store.get('weapons')
- if weapons == nil then
- weapons = {}
- end
- local foundWeapon = false
- for i=1, #weapons, 1 do
- if weapons[i].name == weaponName then
- weapons[i].count = weapons[i].count + 1
- foundWeapon = true
- end
- end
- if not foundWeapon then
- table.insert(weapons, {
- name = weaponName,
- count = 1
- })
- end
- store.set('weapons', weapons)
- cb()
- end)
- end)
- ESX.RegisterServerCallback('esx_hosameki:removeVaultWeapon', function(source, cb, weaponName)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- xPlayer.addWeapon(weaponName, 1000)
- TriggerEvent('esx_datastore:getSharedDataStore', 'society_hosameki', function(store)
- local weapons = store.get('weapons')
- if weapons == nil then
- weapons = {}
- end
- local foundWeapon = false
- for i=1, #weapons, 1 do
- if weapons[i].name == weaponName then
- weapons[i].count = (weapons[i].count > 0 and weapons[i].count - 1 or 0)
- foundWeapon = true
- end
- end
- if not foundWeapon then
- table.insert(weapons, {
- name = weaponName,
- count = 0
- })
- end
- store.set('weapons', weapons)
- cb()
- end)
- end)
- ESX.RegisterServerCallback('esx_hosameki:getPlayerInventory', function(source, cb)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- local items = xPlayer.inventory
- cb({items = items})
- end)
Add Comment
Please, Sign In to add comment