@@ -433,34 +433,35 @@ function CreateExtendedPlayer(playerId, identifier, ssn, group, accounts, invent
433433 reason = reason or " Unknown"
434434 if not tonumber (money ) then
435435 error ((" Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1" ):format (accountName , self .playerId , money ))
436- return false
437- end
438- if money <= 0 then
439- error ((" Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1" ):format (accountName , self .playerId , money ))
440- return false
441- end
442- local account = self .getAccount (accountName )
443- if not account then
444- error ((" Tried To Set Add To Invalid Account ^5%s^1 For Player ^5%s^1!" ):format (accountName , self .playerId ))
445- return false
446- end
447- money = account .round and ESX .Math .Round (money ) or money
448- if self .accounts [account .index ].money - money > self .accounts [account .index ].money then
449- error ((" Tried To Underflow Account ^5%s^1 For Player ^5%s^1!" ):format (accountName , self .playerId ))
450- return false
436+ return
451437 end
438+ if money > 0 then
439+ local account = self .getAccount (accountName )
452440
453- if Config .CustomInventory == " ox" and Inventory and Inventory .accounts and Inventory .accounts [accountName ] then
454- local removed = Inventory .RemoveItem (self .source , accountName , money )
455- if not removed then
456- return false , 0
441+ if account then
442+ money = account .round and ESX .Math .Round (money ) or money
443+ if self .accounts [account .index ].money - money > self .accounts [account .index ].money then
444+ error ((" Tried To Underflow Account ^5%s^1 For Player ^5%s^1!" ):format (accountName , self .playerId ))
445+ return
446+ end
447+
448+ if Config .CustomInventory == " ox" and Inventory and Inventory .accounts and Inventory .accounts [accountName ] then
449+ local removed = Inventory .RemoveItem (self .source , accountName , money )
450+ if not removed then
451+ return
452+ end
453+ end
454+
455+ self .accounts [account .index ].money = self .accounts [account .index ].money - money
456+
457+ self .triggerEvent (" esx:setAccountMoney" , account )
458+ TriggerEvent (" esx:removeAccountMoney" , self .source , accountName , money , reason )
459+ else
460+ error ((" Tried To Set Add To Invalid Account ^5%s^1 For Player ^5%s^1!" ):format (accountName , self .playerId ))
457461 end
462+ else
463+ error ((" Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1" ):format (accountName , self .playerId , money ))
458464 end
459-
460- self .accounts [account .index ].money = self .accounts [account .index ].money - money
461- self .triggerEvent (" esx:setAccountMoney" , account )
462- TriggerEvent (" esx:removeAccountMoney" , self .source , accountName , money , reason )
463- return true , money
464465 end
465466
466467 function self .getInventoryItem (itemName )
0 commit comments