MySQL issue
#1

Hello there, I have a small issue caused by MySQL and Sscanf I suppose, I don't know where the problem lies and how can you get rid of it, but whenever someone tries to login, the Sscanf format appears to be broken on the console and basically the player gets kicked. I suppose the script is correct, but the question is, can anyone tell me where the problem may lie? Here's the code:

Код:
	if(dialogid == DIALOG_LOGIN)
	{
	    if(!isnull(inputtext))
	    {
	        new EscapeString[3][MAX_PLAYER_NAME], password[30];

			GetPlayerIp(playerid, EscapeString[1], MAX_PLAYER_NAME);

			GetPlayerName(playerid, pData[playerid][Name], MAX_PLAYER_NAME);
			mysql_real_escape_string(EscapeString[1], EscapeString[2]); // used to prevent SQL-Injections.
	        mysql_real_escape_string(pData[playerid][Name], EscapeString[0]); // used to prevent SQL-Injections.

			mysql_debug(1);
			format(bigstr, sizeof(bigstr), "SELECT `password` FROM `satc players` WHERE `name` = '%s'", EscapeString[0]);
			mysql_query(bigstr);
			mysql_store_result();
			
			mysql_fetch_row(password);

			printf("[DEBUG]: Password: %s", password);
			
			mysql_free_result();
			mysql_debug(0);

			format(bigstr, sizeof(bigstr), "SELECT * FROM `satc players` WHERE `name` = '%s'", EscapeString[0]);
			mysql_query(bigstr);
			mysql_store_result();

			if(!strcmp(password, inputtext, true))
			{
			    mysql_fetch_row(bigstr);

			    if(!sscanf(bigstr, MYSQL_DATABASE_PLAYER_FORMAT, pData[playerid])) // Uses sscanf enumerate specifier to insert into the pdata array by enum order, Yay for ****** !
				{
				    if(pData[playerid][Banned] == 1)
				    {
				        format(str, sizeof(str), "[Auto Kick] %s has been automaticlly kicked. (Reason: Ban Evading)", pData[playerid][Name]);
						SendClientMessageToAll(COLOR_ALERT, str);

						format(str, sizeof(str), "You have been banned from %s Community...", GLOBAL_SERVER_NAME);
						SendClientMessage(playerid, COLOR_ADMIN, str);
						format(str, sizeof(str), "Your IP: %s", pData[playerid][IP]);
						SendClientMessage(playerid, COLOR_ADMIN, str);
						format(str, sizeof(str), "Please visit http://%s for unban appeals and provide this information in the appeal.", GLOBAL_SERVER_WEBSITE);
						SendClientMessage(playerid, COLOR_ADMIN, str);

						printf("[LOGIN]: Playerid (%d) Is a banned username, auto kicked !", playerid);
						Kick(playerid);
						return 1;
					}

                    SendClientMessage(playerid, COLOR_SUCCESS, "You are now logged in!");
                    
                    if(pData[playerid][Level] >= 1)
                    {
						format(str, sizeof(str), "%s %s has joined the server !", aData[pData[playerid][Level]][Name], pData[playerid][Name]);
						SendClientMessageToAll(COLOR_LIGHTGREEN, str);
					}
					else
					{
					    format(str, sizeof(str), "Player %s has joined the server !", pData[playerid][Name]);
    					SendClientMessageToAll(COLOR_LIGHTGREEN, str);
					}

					pData[playerid][Bools] |= PLAYER_LOGGED; // Turning the bit PLAYER_LOGGED ON.
					
					if(pData[playerid][Muted] == 1)
					{
					    pData[playerid][Bools] |= PLAYER_MUTED;
					}
					if(pData[playerid][Jailed] == 1)
					{
					    pData[playerid][Bools] |= PLAYER_JAILED;
					}

                    SetSpawnInfo(playerid, GetPlayerTeam(playerid), pData[playerid][Skins][0], sData[pData[playerid][Loc]][x], sData[pData[playerid][Loc]][y], sData[pData[playerid][Loc]][z], sData[pData[playerid][Loc]][r], 0, 0, 0, 0, 0, 0);
					SpawnPlayer(playerid);
					SetPlayerInterior(playerid, sData[pData[playerid][Loc]][interior]);
					SetCameraBehindPlayer(playerid);

					format(bigstr, sizeof(bigstr), "UPDATE `satc players` SET `ip` = '%s' WHERE `name` = '%s'", EscapeString[2], EscapeString[0]);
					mysql_query(bigstr);
					mysql_free_result();

				    printf("[LOGIN]: Playerid (%d) Logged in!", playerid);
				    return 1;
				}
				printf("[LOGIN]: Playerid (%d) ERROR! MYSQL SSCANF FORMAT IS BROKEN !", playerid);
				Kick(playerid);
				return 1;
			}
			return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, LOGIN_DIALOG_CAPTION, LOGIN_DIALOG_INFO, "Login", "Cancel");
		}
		return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, LOGIN_DIALOG_CAPTION, LOGIN_DIALOG_INFO, "Login", "Cancel");
	}
Cheers and Kind Regards.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)