How would I create SQL tables for this?
#1

My old DB manager left us and deleted the DB (I don't quite understand why), I scripted the majority of this script but he added the db/sql stuff to it. Now, i have 0 knowledge of SQL, but I figure if I can be shown how to make a table for this registration then I'll be able to figure out how to do it for other things.

pawn Код:
public OnPlayerRegister(playerid, password[])
{
    //FuncLog("OnPlayerRegister");
    if(IsPlayerConnected(playerid))
    {
        MySQLCheckConnection();
        new playername[MAX_PLAYER_NAME];
        new playername3[MAX_PLAYER_NAME];
        new newpass[64];
        GetPlayerName(playerid, playername3, sizeof(playername3));
        mysql_real_escape_string(playername3, playername);
        mysql_real_escape_string(password, newpass);
        new query[128];//PASSWORD
        format(query, sizeof(query), "INSERT INTO `userinfo` (UserName) VALUES ('%s');", playername);
        mysql_query(query);
        new newaccountsqlid = MySQLCheckAccount(playername3);
        if (newaccountsqlid != 0)
        {
            format(query, sizeof(query), "INSERT INTO `uservehicles` (ID, UserName) VALUES (%d, '%s');", newaccountsqlid, playername);
            mysql_query(query);
            format(query, sizeof(query), "INSERT INTO `userstrings` (ID, UserName, Password) VALUES (%d, '%s', '%s');", newaccountsqlid, playername, newpass);
            mysql_query(query);
            format(query, sizeof(query), "INSERT INTO `userlocker` (ID, Username) VALUES (%d, '%s');", newaccountsqlid, playername);
            mysql_query(query);
            PlayerInfo[playerid][pSQLID] = newaccountsqlid;
            strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 127);
            //SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you can now login.");
            //ShowPlayerDialog(playerid, 115, DIALOG_STYLE_INPUT, "{00BFFF}San Diego Roleplay", "This account is Registered!\nPlease enter your Password!", "Login", "Exit");
            gPlayerAccount[playerid] = 1;
            OnPlayerLogin(playerid, password);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_BRIGHTRED, "There was an error creating your account. You will be disconnected now!.");
            gPlayerLogged[playerid] = 0;
            Kick(playerid);
            return 0;
        }
    }
    return 0;
}
Reply
#2

It isn't hard but it can get messy because you are never 100% sure what the table contained, now if I'm not mistaken you created a topic about this a few days ago and I told you the simplest thing to do is ask your scripter nicely to give you the database dump.

You obviously need a mysql server running and I would recommend you to have an webserver with phpmyadmin, it makes your job a lot easier.

You can however execute queries soley on the mysql server without using the phpmyadmin interface, however because you have zero knowledge about SQL that can get kind of hard.

Here are a few queries your going to need

http://www.w3schools.com/sql/sql_create_db.asp
http://www.w3schools.com/sql/sql_create_table.asp

I recommend you also take a look at the tutorials here https://sampforum.blast.hk/showthread.php?tid=360911 if you scroll down to Tutorials about register and login, you'll find some about mysql. They'll teach you some basics. Depending on how big your script is, it can be a pain in the ass to reconstructe the database.
Reply
#3

I contacted the scripter, but no luck. We do have a MySQL server running with phpmyadmin interface (KINGJ). It's creating tables that's giving me the trouble, I'll have alook at those tutorials. Thank you.
Reply
#4

Try and contact KingJ maybe they have an backup, or see if you have one yourself (.sql file)
Reply
#5

KINGJ don't keep backups, and he deleted the .sql file. This is really annoying, as I've been working on this script for the past 6 months now...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)