[Library] samp-account - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Releases (https://forum.open.mp/forumdisplay.php?fid=13) ---- Forum: Libraries (https://forum.open.mp/forumdisplay.php?fid=31) ---- Thread: [Library] samp-account (/showthread.php?tid=1419) |
samp-account - Bakr - 2020-12-14 samp-account samp-account was created to allow extensive user-account systems to be streamlined by not worrying about implementation details. This means we can have a fully working user account system, with data loaded from a database, and stored to a database, all with one function call. samp-account uses the SA:MP native SQLite database system for storage, Slice?s pointers library for data binding, Y_Less? YSI hooks library for callback hooking, and Y_Less' Whirlpool plugin for encryption. Installation Simply install to your project: Code: sampctl package install bwhitmire55/samp-account Include in your code and begin using the library: Code: #include <account> Functions Code: /* Code: /* Code: /* Code: /* Code: /* Code: /* Usage Simply create variables in which to store your players? data Code: new Add that data to the system (and database) via AddAccountData Code: public OnGameModeInit() { Anytime a user logs into their account, their information will be loaded from the database and into the corresponding variables. Likewise for disconnecting, their data will be updated inside the database. NOTE: The variables do no reset themselves, so you should zero-out their values upon the player exiting the server. You are free to use the variables as normal with no effect: Code: public OnPlayerDeath(playerid, killerid, reason) { Now we just need to call RegisterPlayer or LoginPlayer. This will most likely be done via command/dialog Code: ZCMD:register(playerid, params[]) { And that?s it! You now have a fully working account system, which can store any data you like, without touching a database or file. Nice! Callbacks This library also includes two callbacks, OnPlayerRegister and OnPlayerLogin. Code: public OnPlayerRegister(playerid) { Macros All macros are as followed: Code: // The database file Code: // The database table to store the account data Code: // The amount of 'data' you wish to store Code: // The maximum length of a column name in the database All of these can be redefined to suite your script Code: #define ACCOUNT_DATABASE? ? ? ? "COD-DB.db" Testing To test, simply run the package: Code: sampctl package run RE: samp-account - Markski - 2020-12-19 This is very cool. A streamlined, simple installation user account system with support for custom fields is something that was never -properly- done before to my knoweldge. RE: samp-account - Awide - 2020-12-19 Great work, repped! RE: samp-account - Metro - 2020-12-26 What about password encryption? RE: samp-account - Bakr - 2020-12-26 (2020-12-26, 01:11 PM)Metro Wrote: What about password encryption? This uses Whirlpool. Seems I never reformatted the newer version of the readme to bbcode. RE: samp-account - justinnn - 2021-02-25 This is pretty neat! Thanks a lot! |