MrPancakers

Base MySQL Gamemode [Login/Registration System]

Recommended Posts

13 hours ago, Zow said:

Do you plan to update another small feature? like spawn position, spawn after dead, admin level, camera view on login/register etc.

This resource is awesome anyway.

Spawn position as in? The database already saves the players last known position when they quit.

spawn position after death doesn’t need to be in the database

admin level is easy for anyone to add

camera view can again be easily edited

This resource is basically a template, it should have all the code necessary for you to see how it works and to easily add in things like an admin level yourself. I can’t overcomplicate this script by also giving players the option to change camera views etc. It’s just a MySQL template and that’s it. If you need help with these things the RageMP discord has plenty of people who can help

Share this post


Link to post
Share on other sites

Any idea to add "if statement" to check if the letters is not a-z or 0-9 then give them errors
I find some function to check it but I don't know how to use it
Sorry about this question I'm pretty new

        case 1: //Register State
        {
            if(username.length >= 3 && pass.length >= 5){
                gm.mysql.handle.query('SELECT * FROM `accounts` WHERE `username` = ?', [username], function(err, res){
                    if(res.length > 0){
                        player.call("loginHandler", ["takeninfo"]);
                    } else {
                        bcrypt.hash(pass, null, null, function(err, hash) {
                            if(!err){
                                gm.mysql.handle.query('INSERT INTO `accounts` SET username = ?, password = ?', [username, hash], function(err, res){
                                    if(!err){
                                        player.name = username;
                                        player.call("loginHandler", ["registered"]);
                                        gm.auth.registerAccount(player);
                                        console.log("\x1b[92m" + username + "\x1b[39m has just registered.");
                                    } else {
                                        console.log("\x1b[31m[ERROR] " + err)
                                    }
                                });
                            } else {
                                console.log("\x1b[31m[BCrypt]: " + err)
                            }
                        });
                    }
                });
            } else {
                player.call("loginHandler", ["tooshort"]);
            }            
            break;
        }

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.