SQL Not reading the account in the database
#1

So I started developing an SQL Based Gamemode and I'm having an issue. I almost finished the registration part so I decided to hit up then login system but apperently it does not read or create the account in the Database.

My Codes

OnPlayerConnect
pawn Код:
if(IsARolePlayName(szName)) {
        FillingPassportDetails[playerid] = false;
        GetPlayerName(playerid, szName, sizeof(szName));
        format(szQuery, sizeof(szQuery), "SELECT `NAME` FROM `ACCOUNTS` WHERE `NAME` = '%s' COLLATE NOCASE", DB_Escape(szName));
        Result = db_query(Database, szQuery);
        if(db_num_rows(Result)) {
            SendClientMessage(playerid, -1, "REGISTERED"); // Checking if the account is registered
        }
        else {
            new szCName[128], szString[128];
            GetPlayerName(playerid, szCName, 128);
            SetSpawnInfo( playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
            SpawnPlayer(playerid);

            format(szString, sizeof(szString), ""COLOR_WHITE"Welcome "COLOR_LIGHTBLUE"%s"COLOR_WHITE",\nSelect your account password.", szCName);
            db_query(Database, szQuery);
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Chrome Roleplay", szString, "Validate", "");
        }
        db_free_result(Result);
    }
OnDialogResponse
pawn Код:
case DIALOG_REGISTER: {
            if(!response) Kick(playerid);
           
            if(response) {
                if(strlen(inputtext) < 4 || strlen(inputtext) > 24) {
                        new szString[128];
                        format(szString, sizeof(szString), ""COLOR_RED"Error: Password must be between 4 and 24 characters.\n"COLOR_WHITE"Welcome "COLOR_LIGHTBLUE"%s"COLOR_WHITE",\nSelect your account password.", szName);
                        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "", szString, "Validate", "");
                }
               
                else {
                    new sCzName[128];
                    GetPlayerName(playerid, sCzName, sizeof(sCzName));
                    format(szQuery, sizeof(szQuery), "INSERT INTO `ACCOUNTS` (`NAME`, `PASSWORD`, `MONEY`, `FACTION`, `LEVEL`, `ADMINLEVEL`, `HELPER`, `MODERATOR`, `DONATOR`, `FRANK`) VALUES('%s', '%s', '4000', '-1', '0', '0', '0', '0', '0', '0')", DB_Escape(sCzName), DB_Escape(inputtext));
                    db_query(Database, szQuery);
Please note that the above part is a part of the DialogResponse and contains the necessary scripts to save the data in the Database ( I didn't include the whole script since other parts were unneccesary )

Thanks.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)