Kassa's Plugin Snippets

  • English

We've posted an important announcement regarding the current situation and the future of the game: Announcement

  • Kassa's Plugin Snippets

    Hi,

    I don't have finished a complete Plugin yet, so I will use this thread to post some plugin snippets others might want to use for study or to use in their own plugins. I will update this thread whenever I have something interesting to post, instead of creating new threads.

    Please feel free to ask questions or share improvements or if you spot any errors in the code snippets.

    Tools / Software

    SQLite Viewer (can open .db files and show the contents of the database): sqlitebrowser.org/dl/

    Attribute Database

    Code (Version of 8th of July 2019, 07:30): pastebin.com/JUubhvN9

    My first snippet is a small attribute database system. You can define attribute keys in the "attribute_keys" array and it will store the attribute values in an SQLite file located in the <plugin_folder>/database/ folder, named as "storage.db".
    The database table "attributes" stores the players UID (SteamID), the key of the attribute and the value of the attribute. On Player Spawn the attributes will be loaded from the database into the Server RAM. Then you can use setAttribute() or increaseAttribute() to alter the value of the attributes everywhere (in any function you wish).
    You can then use storeAttributes() to store the attributes saved in the RAM into the Database (should be called from an autosave function, not yet implemented).
    There is also an example function included in which the "strength" attribute increases by 1 everytime the player destroys a tree.

    The post was edited 12 times, last by Kassa ().