SHARE
TWEET

Untitled

a guest Jul 21st, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ESX = nil
  2.  
  3. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  4.  
  5. if Config.MaxInService ~= -1 then
  6.     TriggerEvent('esx_service:activateService', 'cartel', Config.MaxInService)
  7. end
  8.  
  9.  
  10. TriggerEvent('esx_society:registerSociety', 'cartel', 'Kartel', 'society_cartel', 'society_cartel', 'society_cartel', {type = 'private'})
  11.  
  12. RegisterServerEvent('esx_carteljob:getStockItem')
  13. AddEventHandler('esx_carteljob:getStockItem', function(itemName, count)
  14.  
  15.     local xPlayer = ESX.GetPlayerFromId(source)
  16.  
  17.     TriggerEvent('esx_addoninventory:getSharedInventory', 'society_cartel', function(inventory)
  18.  
  19.         local item = inventory.getItem(itemName)
  20.  
  21.         if item.count >= count then
  22.             inventory.removeItem(itemName, count)
  23.             xPlayer.addInventoryItem(itemName, count)
  24.         else
  25.             TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
  26.         end
  27.  
  28.         TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. count .. ' ' .. item.label)
  29.  
  30.     end)
  31.  
  32. end)
  33.  
  34. ESX.RegisterServerCallback('esx_carteljob:getStockItems', function(source, cb)
  35.  
  36.     TriggerEvent('esx_addoninventory:getSharedInventory', 'society_cartel', function(inventory)
  37.         cb(inventory.items)
  38.     end)
  39.  
  40. end)
  41.  
  42. RegisterServerEvent('esx_carteljob:putStockItems')
  43. AddEventHandler('esx_carteljob:putStockItems', function(itemName, count)
  44.  
  45.     local xPlayer = ESX.GetPlayerFromId(source)
  46.  
  47.     TriggerEvent('esx_addoninventory:getSharedInventory', 'society_cartel', function(inventory)
  48.  
  49.         local item = inventory.getItem(itemName)
  50.  
  51.         if item.count >= 0 then
  52.             xPlayer.removeInventoryItem(itemName, count)
  53.             inventory.addItem(itemName, count)
  54.         else
  55.             TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
  56.         end
  57.  
  58.         TriggerClientEvent('esx:showNotification', xPlayer.source, _U('added') .. count .. ' ' .. item.label)
  59.  
  60.     end)
  61. end)
  62.  
  63. ESX.RegisterServerCallback('esx_carteljob:getPlayerInventory', function(source, cb)
  64.  
  65.     local xPlayer    = ESX.GetPlayerFromId(source)
  66.     local items      = xPlayer.inventory
  67.  
  68.     cb({
  69.         items      = items
  70.     })
  71.  
  72. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top