• We would like to invite you to check out the latest 1.0 alpha versions. You can read more about what's new here. Please note, that this is still an early release and will contain new bugs ¯\_(ツ)_/¯
  • If you need help or want to discuss things, you now can also join us on our Discord Server!
Resource icon

SConomy NG Database Plugin 1.1.1

No permission to download
SConomy NG Database Plugin adds the database storage to SConomy NG (MariaDB / MySQL / PostgreSQL) [v1.1].

DB plugin version | Supported SConomy NG version

1.0 | 1.5.2
1.1.x | 1.6.x → 1.8.x

Setup:
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:

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 below

The 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

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)
Author
Mmoi
Downloads
45
Views
106
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Mmoi

Latest updates

  1. Improvement in the migration functions

    Improved reliability of the public_db migration function. Note: the db_public one still needs a...
  2. Improvements & compatibility

    Added: in-settings database configuration (no more file editing) Added: support for SConomy NG 1.6.x
Top