SQLite & rBits Help.
#1

Alright, so I just started learning SQLite today, along with the usage of rBits(By Ryder`)
My problem is that when I register a account, and logout, it doesn't save.
It use too, when I did everything by the tutorial by Lorenc_ and then I tried adding more stuff to save
And it messed it up, I know what to do to get it back how it was, but my question is what is wrong with what I did?
If I try to login it says I'm not registered(Even though I previously did register.) and my SKILL is set to 3 instead of 0.
I typed in /skill which sets that Players skill to 3, and then logged out and made a NEW account, and that players skill is also 3. Here is my Login / Register dialogs:

pawn Код:
if(dialogid == 1)
    {
        if(response)
        {
           
            format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));
           
            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, "SKILL", Field, 30);
                Bit8_Set(pData_8Bit[e_Skill], playerid, strval(Field));
                db_get_field_assoc(Result, "VOWNED", Field, 30);
                Bit8_Set(pData_8Bit[e_vOwned], playerid, strval(Field));
                db_get_field_assoc(Result, "AROUNDS", Field, 30);
                Bit8_Set(pData_8Bit[e_aRounds], playerid, strval(Field));
                db_get_field_assoc(Result, "ADMINLEVEL", Field, 30);
                Bit16_Set(g_AdminLevel, playerid, strval(Field));
                Bit1_Set(g_PlayerLogged, playerid, true);
                SendClientMessage(playerid, -1, "You have "COL_GREEN"successfully{FFFFFF} logged in! ");
            }
            else
            {
                format(Query, sizeof(Query), "{FFFFFF}Welcome "COL_BLUE" %s(%d){FFFFFF} to Neptune T:DM\nPlease login below.", name, playerid);
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Login System", Query, "Login", "Leave");
                SendClientMessage(playerid, -1, ""COL_RED"Invalid password, {FFFFFF}Reinput your pass.");
            }
            db_free_result(Result);
        }
        else return Kick(playerid);
    }
    if(dialogid == 0)
    {
        if(response)
        {
            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 System", 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`, `SKILL`, `VOWNED`, `AROUNDS`, `ADMINLEVEL`) VALUES('%s','%s','%s', '0', '500', '0', '0', '0', '0')", DB_Escape(name), DB_Escape(inputtext), DB_Escape(ip));
                db_query(Database, Query);
                Bit1_Set(g_PlayerLogged, playerid, true);
                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);
    }
Other stuff you might need?
pawn Код:
// On Player Connect
new
        Query[ 150 ],
        DBResult: Result,
        name[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName(playerid, name, sizeof(name));

    Bit1_Set(g_PlayerLogged, playerid, false);

    format(Query, sizeof(Query), "SELECT `NAME` FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE", DB_Escape(name));
    Result = db_query(Database, Query);
    if(db_num_rows(Result))
    {
        format(Query, sizeof(Query), "{FFFFFF}Hello "COL_BLUE"%s(%d){FFFFFF} Welcome back to Neptune Gaming T:DM !\n\nEnter your password below.", name, playerid);
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Account System", Query, "Login", "Leave");
    }
    else
    {
        format(Query, sizeof(Query), "{FFFFFF}Welcome "COL_BLUE" %s(%d){FFFFFF} to the server, you're "COL_RED"NOT{FFFFFF} registered\n\nPlease register below.", name, playerid);
        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "{FFFFFF}Register System", Query, "Register", "Leave");
    }
    db_free_result(Result);


//Top of Script
enum e_Bit8_pData
{
    e_Skill,
    e_vOwned,
    e_aRounds
};

new
    Bit8: pData_8Bit[e_Bit8_pData] <MAX_PLAYERS>
;

new
    Bit1:  g_PlayerLogged       <MAX_PLAYERS>, // Creates a 1 bit array
    Bit16: g_AdminLevel         <MAX_PLAYERS>, // Creates a 16 bit array again.
    DB: Database
;
As I said, I'm just learning SQLite and usage of rBits today, so if I did anything wrong or there is a better way, please let me know! It'd be greatly appreciated.
Reply
#2

In OnDialogResponse, are you sure the size of Query is enough to store the whole text? If it's not enough, the query will fail so it won't insert a new row.
Also do you get the name at the top of the callback? Because I see you use: "DB_Escape(name)" and if you don't, the query will probably fail.
Reply
#3

Yes it's getting the name. I upped the Query size alot, and I still get the same issue.
Reply
#4

This might help you: https://sampforum.blast.hk/showthread.php?tid=468260
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)