Skip to content

Commit

Permalink
tweak(server/conf): Support black_money accounts to Inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
renzuzu committed Sep 4, 2021
1 parent 7f97cb1 commit c6c3282
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions config.lua
Expand Up @@ -15,6 +15,7 @@ config.RandomAvatars = { -- if player pedshot is not uploaded yet, we will use I
-- EXTRA CONFIG
config.useSociety = false -- if using esx_society, society money will transfer to owned database renzu_jobs.accounts (first load only) -- set this to false if you are unsure, and manually transfer your society money to this script
config.defaultjob = 'unemployed' -- will be use for firing employee
config.black_money_item = false -- if true you want to use a black_money as item not accounts from ESX

--IMAGE CONFIG
config.inventory = 'esx_inventoryhud' -- resource name of your inventory script, with image folder
Expand Down
24 changes: 20 additions & 4 deletions server.lua
Expand Up @@ -620,6 +620,9 @@ end)
ESX.RegisterServerCallback('renzu_jobs:itemfunc', function(source, cb, type, amount, item, inv_type, slot)
local xPlayer = ESX.GetPlayerFromId(source)
local i = xPlayer.getInventoryItem(item)
if item == 'black_money' and not config.black_money_item then
i = {count = xPlayer.getAccount('black_money').money}
end
local amount = tonumber(amount)
--
local isweapon = string.find(item:upper(), "WEAPON_")
Expand All @@ -630,9 +633,12 @@ ESX.RegisterServerCallback('renzu_jobs:itemfunc', function(source, cb, type, amo
if isweapon then
label = ESX.GetWeaponLabel(item)
xPlayer.removeWeapon(item)
else
elseif item ~= 'black_money' or config.black_money_item and item == 'black_money' then
label = ESX.GetItemLabel(item)
xPlayer.removeInventoryItem(item, amount)
elseif item == 'black_money' and not config.black_money_item then
label = 'Black Money'
xPlayer.removeAccountMoney('black_money',tonumber(amount))
end
TriggerClientEvent('renzu_notify:Notify',xPlayer.source, 'success','Job', 'You deposit '..label..' x'..amount)
if config.Jobs[xPlayer.job.name]['inventory'][inv_type].webhook then
Expand All @@ -643,7 +649,7 @@ ESX.RegisterServerCallback('renzu_jobs:itemfunc', function(source, cb, type, amo
TriggerClientEvent('renzu_notify:Notify',xPlayer.source, 'error','Job', 'You dont have enough')
cb(false)
end
if not isweapon and type == 0 and amount > 0 and GetItems(xPlayer.job.name,inv_type,xPlayer)[slot][item] >= amount
if not isweapon and type == 0 and tonumber(amount) > 0 and GetItems(xPlayer.job.name,inv_type,xPlayer)[slot][item] >= amount
or type == 0 and isweapon and GetItems(xPlayer.job.name,inv_type,xPlayer)[slot][item]['data'] ~= nil then
local label = nil
if isweapon then
Expand All @@ -662,9 +668,12 @@ ESX.RegisterServerCallback('renzu_jobs:itemfunc', function(source, cb, type, amo
xPlayer.addWeaponComponent(tostring(item), tostring(v))
end
end
else
elseif item ~= 'black_money' or config.black_money_item then
label = ESX.GetItemLabel(item)
xPlayer.addInventoryItem(item, amount)
xPlayer.addInventoryItem(item, tonumber(amount))
elseif item == 'black_money' and not config.black_money_item then
label = 'Black Money'
xPlayer.addAccountMoney('black_money',tonumber(amount))
end
removeItem(xPlayer.job.name,item,amount,source,inv_type,xPlayer,slot)
TriggerClientEvent('renzu_notify:Notify',xPlayer.source, 'success','Job', 'You withdraw '..label..' x'..amount)
Expand Down Expand Up @@ -1052,6 +1061,8 @@ ESX.RegisterServerCallback('renzu_jobs:getPlayerInventory', function(source, cb,
item_type = 'weapon'
label = ESX.GetWeaponLabel(k)
amount = v['data'].ammo
elseif k == 'black_money' and not config.black_money_item then
label = 'Black Money'
else
label = ESX.GetItemLabel(k)
end
Expand Down Expand Up @@ -1087,6 +1098,11 @@ ESX.RegisterServerCallback('renzu_jobs:getPlayerInventory', function(source, cb,
})
end
end
table.insert(playerinventory, {
label = 'Black Money' .. ' x' .. blackMoney,
type = 'account',
name = 'black_money'
})

cb({
playerinventory = playerinventory,
Expand Down

0 comments on commit c6c3282

Please sign in to comment.