About This File
UPDATE
I highly recommending using my more updated resource "MySQL Accounts" instead as it fixes known issues and runs better:
This resource will stay up, however I will not be giving any help for this resource as I don't believe it should be used for serious projects.
----
Basic MySQL Gamemode
Github Link: https://github.com/MrPancakers/ragemp-mysql
Resource Thread:
Discord: MrPancakers#9283
This is a template of a very basic login/registration system you can implement into your game mode to get started. This template only stores usernames, passwords(encrypted with BCrypt), position and money so anything extra will need to be implemented yourself. This is intended for beginners so the code is pretty basic and nothing fancy has been done so it is easily readable.
If you find any issues, leave a comment on my thread or leave a comment on this resource.
Installation
You'll need to have a MySQL server setup, either using WAMP/XAMPP/or from a server. To keep this short I will not go through setting these up, simply Google 'How to set up WAMP' for example to get it set up.
- Unzip the source and place it inside of your server files folder.
- Open your command prompt and change your directory to your server folder. Then do 'npm install' to install the required node_modules.
- Create a new database and call it whatever you want (Inside the script it is called 'ragemp-mysql'). Once created, import the ragemp-mysql.sql into your newly created database.
- Go to packages/mysql/mysql.js and open it. At the top is the connection info, change this to whatever your IP and MySQL username/password is. If you're hosting this locally and you haven't made/changed the MySQL info, the default should be fine.
- You're all set to go.
Edited by MrPancakers
What's New in Version 1.2 See changelog
Released
- You can now retrieve player money clientside (player.money changed to player.data.money)
- Renamed the browser variable from browser1 to loginBrowser
- Changed /updatemoney to /setmoney
- Basic error handling for /setmoney (Should now return a message if you didn't put anything in or you didn't put a number in)
- Fixed error for those who quit before logging in
- Shortened player position values, now only goes to 2 decimal places
- Added health and armour to the database to further show examples
- Added /sethealth and /setarmour for more examples of usage
- Added double checking for user passwords on registration to avoid typos in passwords when registering
- Added error handling on MySQL queries