Whirlpool and SQLite issue
#1

So I'm trying to hash player passwords with SQLite but it doesn't create the players account. Here is the code:

pawn Код:
new
        Query[ 256 ],
        DBResult: Result,
        name[ MAX_PLAYER_NAME ],
        ip[ 16 ]
    ;
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerIp(playerid, ip, sizeof(ip));

    if(dialogid == 1)
    {
        if(response)
        {
            new hashpass [129];
            WP_Hash (hashpass, sizeof (hashpass), inputtext);
            format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(hashpass));
            Result = db_query(Database, Query);
            if(db_num_rows(Result))
            {
                new Field[ 20 ];
                db_get_field_assoc(Result, "SCORE", Field, 30);
                SetPlayerScore(playerid, strval(Field));

                db_get_field_assoc(Result, "CASH", Field, 30);
                GivePlayerMoney(playerid, strval(Field));

                db_get_field_assoc(Result, "ADMINLEVEL", Field, 30);
                SInfo[playerid][pAdmin] = strval(Field);
               
                db_get_field_assoc(Result, "BANNED", Field, 30);
                SInfo[playerid][pBan] = strval(Field);
               
                db_get_field_assoc(Result, "REGULAR", Field, 30);
                SInfo[playerid][pRegular] = strval(Field);
               
                db_get_field_assoc(Result, "KILLS", Field, 30);
                SInfo[playerid][pKills] = strval(Field);
               
                db_get_field_assoc(Result, "DEATHS", Field, 30);
                SInfo[playerid][pDeaths] = strval(Field);
                SendClientMessage(playerid, -1, "You have "COL_GREEN"successfully{FFFFFF} logged in! ");
            }
            else
            {
                format(Query, sizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're registered\n\nPlease log in by inputting your password. ", name, playerid);
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Register", Query, "Login", "Leave");
                SendClientMessage(playerid, -1, ""COL_RED"Wrong{FFFFFF} password, try again!");
            }
            db_free_result(Result);
        }
        else return Kick(playerid);
    }
    if(dialogid == 0)
    {
        if(response)
        {
            new hashpass [129];
            WP_Hash (hashpass, sizeof (hashpass), inputtext);
            if(strlen(inputtext) > 24 || strlen(inputtext) < 3)
            {
                format(Query, sizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're "COL_RED"not{FFFFFF} registered\n\nPlease log in by inputting your password. ", name, playerid);
                ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "{FFFFFF}Register", Query, "Register", "Leave");
                SendClientMessage(playerid, -1, "Your password length must be from 3 - 24 characters!");
            }
            else
            {
                format(Query, sizeof(Query), "INSERT INTO `USERS` (`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMINLEVEL`, `KILLS`, `DEATHS`, `REGULAR`) VALUES('%s','%s','%s', '0', '500', '0','0','0','0')", DB_Escape(name), DB_Escape(hashpass), DB_Escape(ip));
                db_query(Database, Query);
                GivePlayerMoney(playerid, 500);
                SetPlayerScore(playerid, 0);
                SendClientMessage(playerid, -1, "You have "COL_GREEN"successfully{FFFFFF} registered! You have been automatically logged in!");
            }
        }
        else return Kick(playerid);
    }
    return 0;
}
Reply
#2

Do you have any debug log file for us? Not sure which plugin you use, but check if you can enable debug logging so we can figure out what's wrong.
Reply
#3

What plugin? I only use whirlpool!
Reply
#4

Which Sql Lite plugin ?
Reply
#5

Aah, wait, I understand. You use the built-in sqlite module from the sa-mp server.exe. I've checked the wiki, and there's no such thing as a debug logger built in, as far as I can see. What you can do, is print the query so we can see what happens. Example:
pawn Код:
else
            {
                format(Query, sizeof(Query), "INSERT INTO `USERS` (`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMINLEVEL`, `KILLS`, `DEATHS`, `REGULAR`) VALUES('%s','%s','%s', '0', '500', '0','0','0','0')", DB_Escape(name), DB_Escape(hashpass), DB_Escape(ip));
                db_query(Database, Query);
                print(Query); //Add this to see what exactly the script is querying, so we can check if the problem lies there
                GivePlayerMoney(playerid, 500);
                SetPlayerScore(playerid, 0);
                SendClientMessage(playerid, -1, "You have "COL_GREEN"successfully{FFFFFF} registered! You have been automatically logged in!");
            }
Most likely there's an error in the sql syntax, or there's too much data for the Query string, I can't say that just by the looks of it.
Reply
#6

Well its hashing the pass but its not saving it.

Quote:

----------------------------------------
[11:50:23] United States Invasion DeathMatch! V1.0
[11:50:23] -----------------------------------------

[11:50:23] Number of vehicle models: 176
[11:51:27] Incoming connection: 127.0.0.1:2108
[11:51:28] [join] [DDP]xXitsgodzillaXx has joined the server (0:127.0.0.1)
[11:51:36] INSERT INTO `USERS` (`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMINLEVEL`, `KILLS`, `DEATHS`, `REGULAR`) VALUES('[DDP]xXitsgodzillaXx','528490106E8A620AF17DCDC88A4462D9 2C27F614125E0F34A14E098C72852E733761D2A2618CDE2801 8A505C2FE148B4419A7AAD5B634A6EB455
[11:51:48] RCON (In-Game): Player #0 ([DDP]xXitsgodzillaXx) has logged in.
[11:51:55] [part] [DDP]xXitsgodzillaXx has left the server (0:1)
[11:52:06] --- Server Shutting Down.
[11:52:08]

Reply
#7

It hashes it, but that's not the problem.. It looks like it's not executing the whole query, it stops after the password. You can try increasing the Query size, and try again.
Reply
#8

what size would you recommend? and what size comes after 256?
Reply
#9

Not sure what size I would use here. After 256 comes 512 I guess, you can try that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)