CreatorsServer exports
AddMoney
Last updated on
Gives money to a connected player.
local res = exports.opx_infinity:AddMoney(source, moneyType, amount, reason)Scope write · await it. It answers from memory today, but it is a write: use the promise form.
Parameters
-
source:
number -
moneyType:
string -
amount:
integer -
reason?:
string -
Money types are the server's
MONEY.TYPES(EDDIES,BANKshipped). -
amountis a whole number from 1 to 9 999 999 999. -
reasonis optional text, cut to 64 characters, stored asext:<your resource>:<reason>. -
Runs the same hooks as any other change and raises
opx:on:character:money.
Returns
integer— the new balance
Errors
money.badType,money.badAmount,money.tooLarge(the balance would pass ±(2^53−1)),money.vetoed,error.notLoggedIn,export.badArgument
CreateThread(function()
local pending, why = Open77.exports.call('opx_infinity', 'AddMoney', playerId, 'EDDIES', 250, 'tip')
if not pending then return print('not sent: ' .. tostring(why)) end
local res = pending:await()
if not (res and res.ok) then return print('refused: ' .. tostring(res and res.error)) end
print(('balance now %d'):format(res.value))
end)