Skip to content

Commit f5c030c

Browse files
authored
feat(server/player): add hooks for add/remove/set money methods
1 parent e4b36f4 commit f5c030c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

server/player.lua

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local config = require 'config.server'
22
local defaultSpawn = require 'config.shared'.defaultSpawn
33
local logger = require 'modules.logger'
44
local storage = require 'server.storage.main'
5+
local triggerEventHooks = require 'modules.hooks'
56
local maxJobsPerPlayer = GetConvarInt('qbx:max_jobs_per_player', 1)
67
local maxGangsPerPlayer = GetConvarInt('qbx:max_gangs_per_player', 1)
78
local setJobReplaces = GetConvar('qbx:setjob_replaces', 'true') == 'true'
@@ -1208,6 +1209,12 @@ function AddMoney(identifier, moneyType, amount, reason)
12081209

12091210
if amount < 0 or not player.PlayerData.money[moneyType] then return false end
12101211

1212+
if not triggerEventHooks('addMoney', {
1213+
source = player.PlayerData.source,
1214+
moneyType = moneyType,
1215+
amount = amount
1216+
}) then return false end
1217+
12111218
player.PlayerData.money[moneyType] += amount
12121219

12131220
if not player.Offline then
@@ -1249,6 +1256,12 @@ function RemoveMoney(identifier, moneyType, amount, reason)
12491256

12501257
if amount < 0 or not player.PlayerData.money[moneyType] then return false end
12511258

1259+
if not triggerEventHooks('removeMoney', {
1260+
source = player.PlayerData.source,
1261+
moneyType = moneyType,
1262+
amount = amount
1263+
}) then return false end
1264+
12521265
for _, mType in pairs(config.money.dontAllowMinus) do
12531266
if mType == moneyType then
12541267
if (player.PlayerData.money[moneyType] - amount) < 0 then
@@ -1298,6 +1311,12 @@ function SetMoney(identifier, moneyType, amount, reason)
12981311

12991312
if amount < 0 or not player.PlayerData.money[moneyType] then return false end
13001313

1314+
if not triggerEventHooks('setMoney', {
1315+
source = player.PlayerData.source,
1316+
moneyType = moneyType,
1317+
amount = amount
1318+
}) then return false end
1319+
13011320
player.PlayerData.money[moneyType] = amount
13021321

13031322
if not player.Offline then

0 commit comments

Comments
 (0)