30.08.2016, 15:34
susers
An easy-to-setup registration systemVersion: 0.1Introduction:A lot of new users here have problems with making an account system.Functions:
So I decided to make an include that simplifies that.Callbacks:Code:Registers the player using the entered password. User_Register(playerid, password[]); Returns whether the player is registered or not. User_IsRegistered(playerid); Attempts to login with the password entered. User_Login(playerid, password[]); Forces the player to login (No password needed) User_ForceLogin(playerid); Returns whether the player is logged in or not. User_IsLoggedIn(playerid); Use under OnPlayerDataLoad Attempts to load an integer from the player's saved data. User_LoadInt(entry[], &dest); Attempts to load a float from the player's saved data. User_LoadFloat(entry[], &dest); Attempts to load a string from the player's saved data. User_LoadString(entry[], dest[], dest_size); Attempts to load a hex value from the player's saved data. User_LoadHex(entry[], &dest); Use under OnPlayerLogout Attempts to save an integer. User_SaveInt(playerid, entry[], data); Attempts to save a float. User_SaveFloat(playerid, entry[], Float: data, accuracy = 6); Attempts to save a string. User_SaveString(playerid, entry[], data[]); Attempts to save a hex value. User_SaveHex(playerid, entry[], data); SQLite only! Use under OnGameModeInit or OnFilterScriptInit Adds a field to the table. field_types:field_int field_float field_stringUser_CreateField(name[], field_types: type, maxlength); Runs the table query and attempts to create the table. User_CreateTable();Notes:Code:Called when the player successfully logs in. forward OnPlayerLogin(playerid); Called when the player successfully registers. forward OnPlayerRegister(playerid); Called when the player's data is being loaded forward OnPlayerDataLoad(playerid, entry[], value[]); Called when the player logs out. forward OnPlayerLogout(playerid);Make sure to #define FILTERSCRIPT if you use this in a filterscript.Download:
Define one of the these before including susers.inc.Code:#define SUSERS_SAVING_INI #define SUSERS_SAVING_SQLITE
(Optional) Include sscanf 2 before including this to take advantage of its speed.
I might add MySQL soon.https://github.com/Stinged/susers