From ba59418b6d2baa805f8a4599186f83ce0a5d54ba Mon Sep 17 00:00:00 2001 From: oosayeroo <98313914+oosayeroo@users.noreply.github.com> Date: Wed, 18 Jun 2025 19:30:21 +0100 Subject: [PATCH] return values (boolean) - added return values on following functions :fundPlayer :chargePlayer - added check for Config.System in Notify.lua --- shared/notify.lua | 1 + shared/playerfunctions.lua | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/shared/notify.lua b/shared/notify.lua index 9959106..fde1e41 100644 --- a/shared/notify.lua +++ b/shared/notify.lua @@ -31,6 +31,7 @@ --- triggerNotify("Alert", "You have been warned for misconduct.", "error", playerId) --- ``` function triggerNotify(title, message, type, src) + if not Config.System or not Config.System.Notify then debugPrint("Notify triggered but not set up") return end if Config.System.Notify == "okok" then if not src then TriggerEvent('okokNotify:Alert', title, message, 6000, type) diff --git a/shared/playerfunctions.lua b/shared/playerfunctions.lua index 5f84207..5e8e275 100644 --- a/shared/playerfunctions.lua +++ b/shared/playerfunctions.lua @@ -176,6 +176,7 @@ end --- chargePlayer(100, "cash", playerId) --- ``` function chargePlayer(cost, moneyType, newsrc) + local is_success = false local src = newsrc or source local fundResource = "" if cost < 0 then @@ -184,33 +185,35 @@ function chargePlayer(cost, moneyType, newsrc) end if moneyType == "cash" then if isStarted(OXInv) then fundResource = OXInv - exports[OXInv]:RemoveItem(src, "money", cost) + is_success = exports[OXInv]:RemoveItem(src, "money", cost) elseif isStarted(QBExport) or isStarted(QBXExport) then fundResource = QBExport - Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost) + is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost) elseif isStarted(RSGExport) then fundResource = RSGExport - Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost) + is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost) elseif isStarted(ESXExport) then fundResource = ESXExport ESX.GetPlayerFromId(src).removeMoney(cost, "") + is_success = true end elseif moneyType == "bank" then if isStarted(QBExport) or isStarted(QBXExport) then fundResource = QBExport - Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost) + is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost) elseif isStarted(RSGExport) then fundResource = RSGExport - Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost) + is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost) elseif isStarted(ESXExport) then fundResource = ESXExport ESX.GetPlayerFromId(src).removeMoney(cost, "") + is_success = true end end @@ -219,6 +222,7 @@ function chargePlayer(cost, moneyType, newsrc) else debugPrint("^6Bridge^7: ^2Charging ^2Player^7: '^6"..cost.."^7'", moneyType, fundResource) end + return is_success end RegisterNetEvent(getScript()..":server:ChargePlayer", function(cost, moneyType, newsrc) debugPrint(GetInvokingResource()) @@ -240,39 +244,42 @@ end) --- fundPlayer(150, "cash", playerId) --- ``` function fundPlayer(fund, moneyType, newsrc) + local is_success = false local src = newsrc or source local fundResource = "" if moneyType == "cash" then if isStarted(OXInv) then fundResource = OXInv - exports[OXInv]:AddItem(src, "money", fund) + is_success = exports[OXInv]:AddItem(src, "money", fund) elseif isStarted(QBExport) or isStarted(QBXExport) then fundResource = QBExport - Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund) + is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund) elseif isStarted(RSGExport) then fundResource = RSGExport - Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund) + is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund) elseif isStarted(ESXExport) then fundResource = ESXExport ESX.GetPlayerFromId(src).addMoney(fund, "") + is_success = true end elseif moneyType == "bank" then if isStarted(QBExport) or isStarted(QBXExport) then fundResource = QBExport - Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund) + is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund) elseif isStarted(RSGExport) then fundResource = RSGExport - Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund) + is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund) elseif isStarted(ESXExport) then fundResource = ESXExport ESX.GetPlayerFromId(src).addMoney(fund, "") + is_success = true end end @@ -281,6 +288,7 @@ function fundPlayer(fund, moneyType, newsrc) else debugPrint("^6Bridge^7: ^2Funding Player: '^2"..fund.."^7'", moneyType, fundResource) end + return is_success end -------------------------------------------------------------