mirror of
https://github.com/project-error/qb-pefcl.git
synced 2026-04-05 00:54:09 -04:00
Update Readme
This commit is contained in:
114
README.md
114
README.md
@@ -15,4 +15,118 @@ of PEFCL and QBCore installed**
|
|||||||
- `type`: `"qb-target"`
|
- `type`: `"qb-target"`
|
||||||
- `enabled`: `true`
|
- `enabled`: `true`
|
||||||
|
|
||||||
|
4. Navigate to `qb-core\server\player.lua` and replace those functions:
|
||||||
|
- self.Functions.AddMoney =>
|
||||||
|
```
|
||||||
|
function self.Functions.AddMoney(moneytype, amount, reason)
|
||||||
|
reason = reason or 'unknown'
|
||||||
|
moneytype = moneytype:lower()
|
||||||
|
amount = tonumber(amount)
|
||||||
|
if amount < 0 then return end
|
||||||
|
if moneytype == 'bank' then
|
||||||
|
local data = {}
|
||||||
|
data.amount = amount
|
||||||
|
data.message = reason
|
||||||
|
exports.pefcl:addBankBalance(self.PlayerData.source, data)
|
||||||
|
else
|
||||||
|
if not self.PlayerData.money[moneytype] then return false end
|
||||||
|
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
|
||||||
|
```
|
||||||
|
- self.Functions.RemoveMoney =>
|
||||||
|
```
|
||||||
|
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
|
||||||
|
if moneytype == 'bank' then
|
||||||
|
if (exports.pefcl:getDefaultAccountBalance(self.PlayerData.source).data - amount) < 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if moneytype == 'bank' then
|
||||||
|
local data = {}
|
||||||
|
data.amount = amount
|
||||||
|
data.message = reason
|
||||||
|
exports.pefcl:removeBankBalance(self.PlayerData.source, data)
|
||||||
|
self.PlayerData.money[moneytype] = exports.pefcl:getDefaultAccountBalance(self.PlayerData.source).data or 0
|
||||||
|
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
|
||||||
|
```
|
||||||
|
- self.Functions.SetMoney
|
||||||
|
```
|
||||||
|
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 moneytype == 'bank' then
|
||||||
|
local data = {}
|
||||||
|
data.message = reason
|
||||||
|
data.amount = amount
|
||||||
|
exports.pefcl:setBankBalance(self.PlayerData.source, data)
|
||||||
|
self.PlayerData.money[moneytype] = exports.pefcl:getDefaultAccountBalance(self.PlayerData.source).data or 0
|
||||||
|
else
|
||||||
|
if not self.PlayerData.money[moneytype] then return false end
|
||||||
|
self.PlayerData.money[moneytype] = amount
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
```
|
||||||
|
- self.Functions.GetMoney
|
||||||
|
```
|
||||||
|
function self.Functions.GetMoney(moneytype)
|
||||||
|
if not moneytype then return false end
|
||||||
|
moneytype = moneytype:lower()
|
||||||
|
if moneytype == 'bank' then
|
||||||
|
self.PlayerData.money[moneytype] = exports.pefcl:getDefaultAccountBalance(self.PlayerData.source).data or 0
|
||||||
|
return exports.pefcl:getDefaultAccountBalance(self.PlayerData.source).data
|
||||||
|
end
|
||||||
|
return self.PlayerData.money[moneytype]
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
**Note this currently only works on PEFCL develop branch**
|
**Note this currently only works on PEFCL develop branch**
|
||||||
|
|||||||
Reference in New Issue
Block a user