Regisering problem [Help = +rep]
#1

1. Hello Guys
2. i am running a server on linux [VOLTHOST] , With mysql
3. I have problem with the register system it is: When i type the pass in the Dialog, Nothing shows...It should show "Account Registered" and it should create an Login dialog after that.
4. I already bulid a Sql in the Volthost and the database and pass are same in the script
5. Codes: it compiled already
Register COde:

pawn Код:
public OnPlayerRegister(playerid, password[])
{
    //FuncLog("OnPlayerRegister");
    if(IsPlayerConnected(playerid))
    {
        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}New york Roleplay", "This account is Registered!\nPlease enter your Password!", "Login", "Exit");
            gPlayerAccount[playerid] = 1;
            OnPlayerLogin(playerid, password);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "If you are bugged please relog.");
            return 0;
        }
    }
    return 0;
}
2. Public PlayerConnected

pawn Код:
public PlayerConnected(playerid)
{
    SpawnPlayer(playerid);
    new plname[MAX_PLAYER_NAME],string[150];
    GetPlayerName(playerid, plname, 24);
    new sqlaccountstatus = MySQLCheckAccount(plname);
    if(sqlaccountstatus > 0)
    {
        gPlayerAccount[playerid] = 1;
        PlayerInfo[playerid][pSQLID] = sqlaccountstatus;
        //Preload Password
        format(string, sizeof(string), "SELECT `Password` FROM `userstrings` WHERE `id`=%d LIMIT 1;",sqlaccountstatus);
        mysql_query(string);
        mysql_store_result();
        mysql_fetch_field("Password", PlayerInfo[playerid][pKey]);
        mysql_free_result();
        SendClientMessage(playerid, COLOR_ORANGE, "*******************");
        SendClientMessage(playerid, COLOR_ORANGE, "Welcome to NYRP!");
        SendClientMessage(playerid, COLOR_ORANGE, "This username is registered please login.");
        ShowPlayerDialog(playerid, 115, DIALOG_STYLE_INPUT, "{00BFFF}New York Roleplay", "{FFFFFF}This account is registered!\nPlease enter your password!", "Login", "Exit");
        return 1;
    }
    else
    {
        gPlayerAccount[playerid] = 0;
        SendClientMessage(playerid, COLOR_ORANGE, "*******************");
        SendClientMessage(playerid, COLOR_ORANGE, "Welcome to NYRP!");
        SendClientMessage(playerid, COLOR_ORANGE, "Please register to start playing.");
        ShowPlayerDialog(playerid, 116, DIALOG_STYLE_INPUT, "{00BFFF}New york Roleplay", "This account is not registered!\nPlease enter your Password!", "Register", "Exit");
        return 1;
    }
}
8. Fix it = +rep....Thank you guys!
Reply
#2

Uhm, show us MySQLCheckAccount.
And are the INSERT INTO `uservehicles` get inserted if you take a look at the database?
Reply
#3

Here bro...Check it
[/pawn]public MySQLCheckAccount(sqlplayersname[])
{
//FuncLog("MySQLCheckAccount");
new query[128];
new escstr[MAX_PLAYER_NAME];
mysql_real_escape_string(sqlplayersname, escstr);
format(query, sizeof(query), "SELECT `id` FROM `userinfo` WHERE LOWER(UserName) = LOWER('%s') LIMIT 1 ;", escstr);
mysql_query(query);
mysql_store_result();
if (mysql_num_rows()==0)
{
return 0;
}
else
{
new strid[32];
new intid;
mysql_fetch_row(strid);
intid = strval(strid);
return intid;
}
}[pawn]
Reply
#4

Ok seems fine, can you take a look at your database and see if the user row exist that should be regsitered.
Reply
#5

Where is that Excatly? In volthost...I opened my database
Reply
#6

Try to solve it if it is not exited..what can i do if it is not...i will brb after 30 Mins, Solve it and i swear i will rep you...
Reply
#7

I dont care for reps, I'm just bored, let starts at the point you enter a ; after a query inside the "", remove the ; at the query strings, not sure if it matters, but it's not needed. Now put mysql_debug(1); at ongamemodeinit, run it , test it, if it fails, send the mysql_log.txt in your server root map.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)