SA-MP Forums Archive
Problem loading accounts via MySQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem loading accounts via MySQL (/showthread.php?tid=640742)



Problem loading accounts via MySQL - Jing_Chan - 06.09.2017

Код:
stock LoadAccount(playerid)
{
	new Escape[2][MAX_PLAYER_NAME];

	mysql_real_escape_string(PlayerInfo[playerid][pName], Escape[0]);
	mysql_real_escape_string(mysql_account_table, Escape[1]);

	format(query, sizeof(query), "SELECT * FROM `%s` WHERE `username` = '%s'", Escape[1], Escape[0]);
	mysql_query(query);
	mysql_store_result();

	if(mysql_num_rows())
	{
		if(mysql_fetch_row(largestr))
		{
            if(!sscanf(largestr, mysql_user_string, PlayerInfo[playerid]))
			{
        		PlayerInfo[playerid][pLoggedIn] = 1;
        		PlayerInfo[playerid][pRegistered] = 1;
        		PlayerInfo[playerid][pIsNew] = 0;
                printf("[DEBUG]: Player %s(%d) Stats loaded!", PlayerInfo[playerid][pName], playerid);
				return 1;
			}
			format(str, sizeof(str), "Player %s(%d) - SSCANF loading error", PlayerInfo[playerid][pName], playerid);
			Error("MYSQL", str);
			AccountError(playerid);
			mysql_free_result();
			return 1;
		}
		format(str, sizeof(str), "Player %s(%d) - Cannot fetch player row", PlayerInfo[playerid][pName], playerid);
		Error("MYSQL", str);
		AccountError(playerid);
		mysql_free_result();
		return 1;
	}
	format(str, sizeof(str), "Player %s(%d) - Cannot find player in the mysql database", PlayerInfo[playerid][pName], playerid);
    Error("MYSQL", str);
    AccountError(playerid);
	mysql_free_result();
	return 1;
}
When I login and create a new account, it all saves to the database. When I log back in the server closes the connection with this error

Код:
		format(str, sizeof(str), "Player %s(%d) - SSCANF loading error", PlayerInfo[playerid][pName], playerid);
I'm obviously using a base MySQL script and do not understand what the issue at hand is, can someone please point me in the right direction here.


Re: Problem loading accounts via MySQL - 10MIN - 06.09.2017

Why you use sscanf on a login system?
sscanf is used for splitting strings into other strings / cells (or int)/Floats etc. ( sscanf means: StringSCANFormat, also known as unformat )


Re: Problem loading accounts via MySQL - Jing_Chan - 06.09.2017

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
Why you use sscanf on a login system?
sscanf is used for splitting strings into other strings / cells (or int)/Floats etc. ( sscanf means: StringSCANFormat, also known as unformat )
It's what the base came as, can't find any other working MySQL base rn so


Re: Problem loading accounts via MySQL - 10MIN - 06.09.2017

Base are for new scripters. True scripters script it themselves... Also as a login system I used something like:


Re: Problem loading accounts via MySQL - Jing_Chan - 06.09.2017

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
Base are for new scripters. True scripters script it themselves... Also as a login system I used something like:
  • Check if the user exists in the database
  • Get his password from DataBase
  • Compare it with the password he introduced in the dialog
  • If they match the player is logged in, else no
I learn through starting with a base and developing onwards, I will try do it from scratch anyway but..


Re: Problem loading accounts via MySQL - BadJih - 06.09.2017

check mysql logs


Re: Problem loading accounts via MySQL - Vince - 06.09.2017

A basic script is fine ... as long as you don't pick something that is ancient. When was that script released? 2010 maybe?