11local inventory = exports .ox_inventory
2+ local accounts = exports .ox_accounts
23
34lib .callback .register (' orp_banking:getBalance' , function (source )
4- local player = Player (source )
5- return player .getAccount (' bank' ) or 0
5+ return accounts :get (source , ' bank' ) or 0
66end )
77
88
99
1010RegisterNetEvent (' orp_banking:deposit' , function (data )
11- local player = Player (source )
1211 local amount = tonumber (data ?.amount )
1312
1413 if not amount or amount <= 0 or amount > inventory :GetItem (source , ' money' , false , true ) then
1514 TriggerClientEvent (' orp_banking:notify' , source , ' Invalid amount' , ' error' )
1615 else
1716 inventory :RemoveItem (source , ' money' , amount )
18- player . addAccount ( ' bank' , amount )
19- TriggerClientEvent (' orp_banking:update' , source , player . getAccount ( ' bank' ))
17+ accounts : add ( source , ' bank' , amount )
18+ TriggerClientEvent (' orp_banking:update' , source , accounts : get ( source , ' bank' ))
2019 TriggerClientEvent (' orp_banking:notify' , source , ' You have successfully deposited $' .. amount , ' success' )
2120 end
2221end )
2322
2423RegisterNetEvent (' orp_banking:withdraw' , function (data )
25- local player = Player (source )
26- local balance = player .getAccount (' bank' )
24+ local balance = accounts :get (source , ' bank' )
2725 local amount = tonumber (data ?.amount )
2826
2927 if not amount or amount <= 0 or amount > balance then
3028 TriggerClientEvent (' orp_banking:notify' , source , ' Invalid amount' , ' error' )
3129 else
32- player . removeAccount ( ' bank' , amount )
30+ accounts : remove ( source , ' bank' , amount )
3331 inventory :AddItem (source , ' money' , amount )
3432 TriggerClientEvent (' orp_banking:update' , source , balance - amount )
3533 TriggerClientEvent (' orp_banking:notify' , source , ' You have successfully withdrawn $' .. amount , ' success' )
@@ -46,19 +44,17 @@ RegisterNetEvent('orp_banking:transfer', function(data)
4644 elseif not amount or amount <= 0 then
4745 TriggerClientEvent (' orp_banking:notify' , source , ' Invalid amount' , ' error' )
4846 else
49- local player = Player (source )
50- local target = Player (data .target )
51- local balance = player .getAccount (' bank' )
47+ local balance = accounts :get (source , ' bank' )
5248
5349 if balance <= 0 or balance < amount or amount <= 0 then
5450 TriggerClientEvent (' orp_banking:notify' , source , ' You don\' t have enough money for this transfer' , ' error' )
5551 else
56- player . removeAccount ( ' bank' , amount )
52+ accounts : remove ( source , ' bank' , amount )
5753 TriggerClientEvent (' orp_banking:update' , source , balance - amount )
5854 TriggerClientEvent (' orp_banking:notify' , source , ' You have successfully transferred $' .. amount , ' success' )
5955
60- target . addAccount ( ' bank' , amount )
61- TriggerClientEvent (' orp_banking:update' , source , target . getAccount ( ' bank' ))
56+ accounts : add ( data . target , ' bank' , amount )
57+ TriggerClientEvent (' orp_banking:update' , source , accounts : get ( data . target , ' bank' ))
6258 TriggerClientEvent (' orp_banking:notify' , source , ' You just received $' .. amount .. ' via bank transfer' , ' success' )
6359 end
6460 end
0 commit comments