โ๏ธInstallation
Installation for SA-Money script
Buy script from Tebex
Download it from cfx โ Purchased Assets
Open the downloaded file and configure the config.Lua, functions.Lua, fxmanifest.Lua and locale by your preferences
Upload those files to your server
Create a new item in qb-core โ shared โ items.lua โ (Icon for the item you can upload into QB-Inventory โ html โ images)
['cash'] = {['name'] = 'cash', ['label'] = 'Money', ['weight'] = 0, ['type'] = 'item', ['image'] = 'cash.png', ['unique'] = false, ['useable'] = false, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Money?'},
Now edit functions in the player.lua. The destination is qb-core โ server โ player.lua
If you want you can also activate black & printed money, uncomment those lines, also you have to make a new item for it in items.lua. More about it here
function self.Functions.AddMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
if moneytype == 'cash' then
if self.PlayerData.money[moneytype] == self.PlayerData.money['cash'] then
exports['SA-Money-v2']:AddMoney(PlayerData, amount, reason)
end
--[[ elseif moneytype == 'blackmoney' then
if self.PlayerData.money[moneytype] == self.PlayerData.money['blackmoney'] then
exports['SA-Money-v2']:AddMoney(PlayerData, amount, reason, 'blackmoney')
end
elseif moneytype == 'printedbills' then
if self.PlayerData.money[moneytype] == self.PlayerData.money['printedbills'] then
exports['SA-Money-v2']:AddMoney(PlayerData, amount, reason, 'printedbills')
end ]]
else
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount
end
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true)
else
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
end
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, false)
end
return true
end
function self.Functions.RemoveMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
for _, mtype in pairs(QBCore.Config.Money.DontAllowMinus) do
if mtype == moneytype then
if (self.PlayerData.money[moneytype] - amount) < 0 then
return false
end
end
end
if moneytype == 'cash' then
if self.PlayerData.money[moneytype] == self.PlayerData.money['cash'] then
exports['SA-Money-v2']:RemoveMoney(PlayerData, amount, reason)
end
--[[ elseif moneytype == 'blackmoney' then
if self.PlayerData.money[moneytype] == self.PlayerData.money['blackmoney'] then
exports['SA-Money-v2']:RemoveMoney(PlayerData, amount, reason, 'blackmoney')
end
elseif moneytype == 'printedbills' then
if self.PlayerData.money[moneytype] == self.PlayerData.money['printedbills'] then
exports['SA-Money-v2']:RemoveMoney(PlayerData, amount, reason, 'printedbills')
end ]]
else
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
end
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true)
else
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
end
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, true)
if moneytype == 'bank' then
TriggerClientEvent('qb-phone:client:RemoveBankMoney', self.PlayerData.source, amount)
end
end
return true
end
function self.Functions.SetMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return false end
if not self.PlayerData.money[moneytype] then return false end
self.PlayerData.money[moneytype] = amount
if not self.Offline then
self.Functions.UpdatePlayerData()
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
end
return true
end
function self.Functions.GetMoney(moneytype)
local src = PlayerData.source
exports['SA-Money-v2']:GetCash(src)
if not moneytype then return false end
moneytype = moneytype:lower()
return self.PlayerData.money[moneytype]
end
If your server is already started follow also guide for migration
Now it's done and it should work. If it doesn't work try other tips or contact us on Discord
Last updated