SConomy NG Database Plugin adds the database storage to SConomy NG (MariaDB / MySQL / PostgreSQL) [v1.1].
Setup [not needed if sinusbot >= 1.0]:
In the config.ini files (next to the script folder), add the 2 following lines (allow the database connection):
[Scripts.Privileges]
sconomy-ng-db = ["db"]
Database credentials / info:
Place the script into the script folder. Reboot the bot and configure your database credentials in the settings, like the other scripts.
Apply:
Now, you'll need to restart the bot in order to apply the changes.
Once this is done, you will need to activate the plugin in the settings (check the checkbox).
Needed permissions:
Your database user will need CREATE, INSERT, SELECT and UPDATE (and DELETE for migration command) privileges for the database.
Warning: having a database will make it (a little bit) harder for plugin-maker to manage your money
Added migration arguments:
*
*
*
DB plugin version | Supported SConomy NG version
1.0 | 1.5.2
1.1.x | 1.6.x → 1.8.x
1.0 | 1.5.2
1.1.x | 1.6.x → 1.8.x
Setup [not needed if sinusbot >= 1.0]:
In the config.ini files (next to the script folder), add the 2 following lines (allow the database connection):
[Scripts.Privileges]
sconomy-ng-db = ["db"]
Database credentials / info:
Place the script into the script folder. Reboot the bot and configure your database credentials in the settings, like the other scripts.
Apply:
Now, you'll need to restart the bot in order to apply the changes.
Once this is done, you will need to activate the plugin in the settings (check the checkbox).
Script integration
First, the example:
Then, the notes:
The plugin works like a library and you'll need to use it after all the scripts are loaded (
There is three mains functions that are usable:
-
-
-
The set and get functions use (almost) the same parameters:
-
-
-
* If you use custom strings, please note that the concatenaion of the userUID (a key, then, here) and the type must not exceed 32 characters.
Examples:
- Getting an user currency:
- Setting an user currency:
- Setting a custom integer
First, the example:
JavaScript:
event.on('load', function()
{
var sconomyDB = require('sconomy-ng-db.js');
if (!sconomyDB || !sconomyDB.isEnabled())
{
// Disable the support
sconomyDB = null;
}
else
{
// Connection is handled by SConomy NG
engine.log('SConomy NG DB loaded');
}
}
Then, the notes:
The plugin works like a library and you'll need to use it after all the scripts are loaded (
event.on('load'
).There is three mains functions that are usable:
-
sconomyDB.isEnabled()
Self-explanatory-
sconomyDB.setData(userUID, type, value);
See below-
sconomyDB.getData(userUID, type);
See belowThe set and get functions use (almost) the same parameters:
-
userUID
user UID (if one, or any key)-
type
the string 'sconomy', 'progress' or any other string* (if you use the last one, the value must be an integer).-
value
the float (sconomy) or integer (progress or any custom type) value to be saved* If you use custom strings, please note that the concatenaion of the userUID (a key, then, here) and the type must not exceed 32 characters.
Examples:
- Getting an user currency:
var sconomy = sconomyDB.getData('CoolButInvalidUID', 'sconomy');
- Setting an user currency:
sconomyDB.setData('CoolButInvalidUID', 'sconomy', 42);
- Setting a custom integer
sconomyDB.setData('RemainingItemsID85', 'quantity', value);
Note: a lot of these functions are here for Sconomy NG only and therefor not usefull in your case.
isEnabled
getTick
start
getMigrationFunctions
setData
setAllData
getData
isEnabled
getTick
start
getMigrationFunctions
setData
setAllData
getData
Needed permissions:
Your database user will need CREATE, INSERT, SELECT and UPDATE (and DELETE for migration command) privileges for the database.
Warning: having a database will make it (a little bit) harder for plugin-maker to manage your money
Added migration arguments:
*
public_db
=> Copy data from public to the database storage*
db_public
=> Copy data from database to the public storage*
unset_db
=> Clean all data from the database (only sconomy data, don't worry)