Overview
Create a bank system to your game, check balance, do withdraw and deposit how much money you want no matter if your game is online or offline. Very easy to implement, just download some custom events and network events and learn how to manage them.
Introduction
This guide requires a basic knowledge of the engine, so I’m assuming that you aren’t a new user and will understand some nomenclatures.
Before learn how to use this system you need to download the events that will be used on it. Download the files in the link below and use the “Import Resources” icon to import the files:
[link]
This guide will teach you how to add a full bank system to your game, whatever if it is online or offline the process is similar. The bank system doesn’t use the default money system, but it gives the tools that you need to do it, also, the system is very modular, it won’t change how your game works.
To get started, create a global variable named as “retrieveBalance” (without quotes) and a table named as “bank” (without quotes). Once it done, you’re able to continue to the next section!
How to manage Offline
After import all the events you may access the new custom events:
1. Change Balance
Account ID parameter is who is accessing the account and will have the balance changed, Amount is how much to change and Operation is if you want to add to the account or subtract from it.
2. Create Account
Account ID parameter is the account that will be registered, if the account already exists it will take the second path of the branch and if the account was created with success it will take the first path.
3. Show Balance
This is a return value, when you need to know how is the balance of a certain Account ID, use it.
All these events need to exist for the online game too, but you shall not use them because the network logic won’t work by this way.
How to manage Online
After import all the events you may access the new network events:
1. Change Balance
Account ID parameter is who is accessing the account and will have the balance changed, Amount is how much to change and Operation is if you want to add to the account or subtract from it. This event will execute no matter if the operation is impossible, so if you want to check if the player has enough money to transfer, do it before using this event.
2. Create Account
Account ID parameter is the account that will be registered. Network events don’t have branches so if you want to put some code whether the account could be created or not, edit the network event script and place the events that you want inside the Sub-Script boxes, there is a comment in each Sub-Script event to show who is it.
3. Show Balance
Network events don’t have return values, for this reason you’ve created the “retrieveValue” global variable, this variable will store the balance of the specified Account ID in this event, also, if you want to add some code when the value arrives at client, you can easily do it by editing this event and adding your code inside the Sub-Script box.
This is all you need to implement the system, hope you’ve liked. Please let me know if anything runs wrong.