Creating 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

https://sampforum.blast.hk/showthread.php?tid=159785

This tutorial explains how to create tables.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)