script_trigger_type = 'On Connect';
--note:
--the withdraw, deposit, getBalance, getRichest, fixedAdjustment
--MUST return value(s);
function fixedAdjustment(viewerId, amount)
--code to set the viewerId's currency to the exact amount
return amount; --return the new balance
end
function getRichest(howMany)
--this is used for extension leaderboard data. the data returned here will be displayed on the extension
--try to grab the top howMany requested and put it into a richest array like so...
--this array will be sorted correctly so order doesnt matter, just ensure it's the richest users.
local richestArray = {
{ displayName = 'clonzeh', points = 1234 },
{ displayName = 'Person2', points = 442 },
{ displayName = 'Person3', points = 14532 }
};
return richestArray; --return the richest users array
end
function getBalance(viewerId)
--code to check lua balance of viewerId;
return 1234; --return the balance of the viewer
end
function deposit(viewerId, amount)
--code to add points to the viewerid
local newBalance = 1234 + amount;
--finish code
return newBalance; --return the new balance of the viewer
end
function withdraw(viewerId, amount)
local balanceFound = 1234;
local success = false;
if balanceFound > amount then
--code to subtract points from the viewerId
local newBalance = balanceFound - amount;
--if the subtraction works then
--set success to true...
success = true;
return success, newBalance;
end
return success, balanceFound; --return the new balance of the user
end
function massDeposit(viewerIds, amounts)
--efficiently deposit large amounts points to users...
--this is useful if a custom bot currency system has an endpoint to adjust multiple users at once.
--or just do it one at a time inside a loop the deposit(viewerId, amount); function
for key, value in ipairs(viewerIds) do
deposit(value, amounts[key]);
end
end
return function()
setupBankController(); --adds all required events for the bank controlling system.
--NOTE: All functions above must exist with the same parameters specificed.
keepAlive();
end