Some problems with sscanf 2.0
#1

I have some problems with this function:

Code:
stock LoadPlayerInfo(playerid)
{
    new query[512];
    format(query, sizeof(query), "SELECT * FROM `useraccounts` WHERE `User`= %s", GetUserName(playerid));
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows())
    if(mysql_fetch_row_format(query))
    {
		sscanf(query, "e<is[24]s[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[24]iiiis[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[32]iiiiiiiiiiiiiiiiiiiiiis[24]i>",PlayerInfo[playerid]);
    }
}
The query load right, but sscanf saves the ints and strings not in die PlayerInfo enum.

What I am doing wrong?
Reply
#2

Here is the new function:

Code:
stock LoadPlayerInfo(playerid)
{
    new query[512];
	format(query, sizeof(query), "SELECT * FROM `useraccounts` WHERE `User`= %s", GetUserName(playerid));
	printf("1: %s",query);
	mysql_query(query);
	printf("2: %s",query);
	mysql_store_result();
	printf("3: %s",query);
    if(mysql_num_rows())
    printf("4: %s",query);
    if(mysql_fetch_row_format(query))
	{
	    printf("5: %s",query);
		sscanf(query, "e<is[24]s[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[24]iiiis[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[32]iiiiiiiiiiiiiiiiiiiiiis[24]i>",PlayerInfo[playerid]);
	}
}
Output:

Code:
[14:47:58] 1: SELECT * FROM `useraccounts` WHERE `User`= test
[14:47:58] 2: SELECT * FROM `useraccounts` WHERE `User`= test
[14:47:58] 3: SELECT * FROM `useraccounts` WHERE `User`= test
[14:47:58] 4: SELECT * FROM `useraccounts` WHERE `User`= test

5 didnt come ???
Mysql_log:
Code:
[14:47:58] CMySQLHandler::Query(SELECT * FROM `useraccounts` WHERE `User`= test) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test' at line 1)
You are right!
But why the query doesnt load? Can you help me?
Reply
#3

Now I have it done right:

Function:
Code:
stock LoadPlayerInfo(playerid)
{
    new query[512];
    new user[MAX_PLAYER_NAME];
	GetPlayerName(playerid,user,sizeof(user));
	format(query, sizeof(query), "SELECT * FROM `useraccounts` WHERE `User`= '%s'", user);
	printf("1: %s",query);
	mysql_query(query);
	printf("2: %s",query);
	mysql_store_result();
	printf("3: %s",query);
    if(mysql_num_rows())
    printf("4: %s",query);
    if(mysql_fetch_row_format(query))
	{
	    printf("5: %s",query);
		sscanf(query, "e<is[24]s[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[24]iiiis[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[32]iiiiiiiiiiiiiiiiiiiiiis[24]i>",PlayerInfo[playerid]);
	}
}
Output:

Code:
[15:06:12] 1: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:06:13] 2: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:06:13] 3: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:06:13] 4: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:06:13] 5: 2|test||1|0|0|0|0|0|0|1|0|0|0|0|1100|1000|0|0|0|0|0|0|0|0|0|0|964|0|0|0|111|0|0|0|255|0|43|0|0|0|0|0|0|0|50.000000|80.000000|0|255|3|101|2959|255|255|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|nice|0|0|0|0|11.11.11.111|98|100|98|76|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|satis|1290023471|0|7|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|modern|0
Reply
#4

No it doesnt work:

Function:

Code:
stock LoadPlayerInfo(playerid)
{
    new query[512];
    new user[MAX_PLAYER_NAME];
	GetPlayerName(playerid,user,sizeof(user));
	format(query, sizeof(query), "SELECT * FROM `useraccounts` WHERE `User`= '%s'", user);
	printf("1: %s",query);
	mysql_query(query);
	printf("2: %s",query);
	mysql_store_result();
	printf("3: %s",query);
    if(mysql_num_rows())
    printf("4: %s",query);
    if(mysql_fetch_row_format(query))
	{
	    printf("5: %s",query);
		sscanf(query, "p<|>e<is[24]s[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[24]iiiis[128]iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis[32]iiiiiiiiiiiiiiiiiiiiiis[24]i>",PlayerInfo[playerid]);
	}
	printf("ID: %d", PlayerInfo[playerid][pID]);
	printf("User: %s", PlayerInfo[playerid][pUser]);
	printf("Pass: %s", PlayerInfo[playerid][pPass]);
}
Output:

Code:
[15:33:02] 1: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:33:02] 2: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:33:02] 3: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:33:02] 4: SELECT * FROM `useraccounts` WHERE `User`= 'test'
[15:33:02] 5: 2|test|A78C5BF69B40D464B954EF76815C6FA0|5|1338|0|2|24|30|756|1|1|11|0|70|697|3901560|240|69|1634|3|0|1|0|0|0|0|910|0|0|0|111|0|0|0|255|0|43|0|0|0|0|0|0|0|50.000000|100.000000|0|255|3|299|7372|255|255|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|1|0|0|0|0|nice|0|0|0|0|11.11.11.111|99|100|98|77|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|satis|1290023471|0|7|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1290086044|modern|0
[15:33:02] ID: 0
[15:33:02] User: 
[15:33:02] Pass:
Reply
#5

I know, it is already in the same order. It starts with 1: pID, 2: pUser, 3: pPass, 4: pLevel, 5: pAdmin, and so on...

In the MySQL data it is also in the same order.
Reply
#6

Can someone help me?
Reply
#7

Can you post the PlayerInfo enum?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)