Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for ox_inventory per-item money system #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Config = {}
Config = {
ox_inventory = false -- Enable if you're using ox_inventory
}

Config.BusinessAccounts = {
['police'] = { -- Job Name
Expand Down
18 changes: 15 additions & 3 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@ local QBCore = exports["qb-core"]:GetCoreObject()

local function addCash(src, amount)
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.AddMoney("cash", amount)
if Config.ox_inventory then
exports.ox_inventory:addCash(src,amount)
else
Player.Functions.AddMoney("cash", amount)
end
end

local function removeCash(src, amount)
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.RemoveMoney("cash", amount)
if Config.ox_inventory then
exports.ox_inventory:removeCash(src,amount)
else
Player.Functions.RemoveMoney("cash", amount)
end
end

local function getCash(src)
local Player = QBCore.Functions.GetPlayer(src)
return Player.PlayerData.money["cash"] or 0
if Config.ox_inventory then
return exports.ox_inventory:getCash(src) or 0
else
return Player.PlayerData.money["cash"] or 0
end
end

local function loadPlayer(src, citizenid, name)
Expand Down