sscanf warning: Format specifier does not match parameter count.
#1

sscanf warning: Format specifier does not match parameter count.

It has something to do with the loading stats

Anyone that can help?
Will +Rep

Quote:

[11:53:45] Incoming connection: 127.0.0.1:49866
[11:53:45] [join] Jason_Smith has joined the server (0:127.0.0.1)
[11:53:51] sscanf warning: String buffer overflow.
[11:53:51] sscanf warning: Format specifier does not match parameter count.
[11:53:51] Loaded
[11:53:51] Loaded 2
[11:53:58] Player Saved
[11:53:58] [part] Jason_Smith has left the server (0:1)

Here is the code:
Код:
stock LoadStats(playerid)
{
	new Query[2048];
	format(Query, sizeof(Query), "SELECT * FROM playerdata WHERE Name = '%s'", GetName(playerid));
	mysql_query(Query);
	mysql_store_result();
	mysql_fetch_row_format(Query, "|");
	sscanf(Query, "e<p<|>s[23]s[24]dddddfffdddddd>",
	PlayerInfo[playerid][Name],
	PlayerInfo[playerid][Password],
	PlayerInfo[playerid][Cash],
	PlayerInfo[playerid][Bank],
	PlayerInfo[playerid][PH],
	PlayerInfo[playerid][Level],
	PlayerInfo[playerid][Skin],
	PlayerInfo[playerid][PosX],
	PlayerInfo[playerid][PosY],
	PlayerInfo[playerid][PosZ],
	PlayerInfo[playerid][Int],
	PlayerInfo[playerid][VW],
	PlayerInfo[playerid][Job],
	PlayerInfo[playerid][Job2],
	PlayerInfo[playerid][Jail],
	PlayerInfo[playerid][Bail]);
	print("Loaded");
	mysql_free_result();
	
	format(Query, sizeof(Query), "SELECT * FROM playerdata WHERE Name = '%s'", GetName(playerid));
	mysql_query(Query);
	mysql_store_result();
	mysql_fetch_row_format(Query, "|");
	sscanf(Query, "e<p<|>dddddddddd>",
	PlayerInfo[playerid][Faction],
	PlayerInfo[playerid][FacRank],
	PlayerInfo[playerid][Phone],
	PlayerInfo[playerid][Mats],
	PlayerInfo[playerid][Pot],
	PlayerInfo[playerid][Crack],
	PlayerInfo[playerid][Heroin],
	PlayerInfo[playerid][VIPLevel],
	PlayerInfo[playerid][Moderator],
	PlayerInfo[playerid][Admin]);
	print("Loaded 2");
	mysql_free_result();
	return 1;
}
Reply
#2

PlayerInfo[playerid][Name] is smaller than 23, or PlayerInfo[playerid][Password] is smaller than 24. Also unless you like server lags, consider moving to threaded queries.
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
PlayerInfo[playerid][Name] is smaller than 23, or PlayerInfo[playerid][Password] is smaller than 24. Also unless you like server lags, consider moving to threaded queries.
Doesn't string buffer overflow mean that the lenght is greater than the one was specified? The max name can be 21 (including null) so I guess the password is greater than 24.
Reply
#4

Yeah, but OP passed 23 as name length to sscanf, so it assumes it can allocate 23 chars (while the Name field is probably at most MAX_PLAYER_NAME + 1 big). Without seeing the enum it's just a guess though
Reply
#5

Ok I fixed that part. But now it is not loading the admin part...
Here is the enum:
Код:
enum pInfo
{
	Name[23],
	Password[24],
	Cash,
	Bank,
	PH,
	Level,
	Skin,
	Float:PosX,
	Float:PosY,
	Float:PosZ,
	Int,
	VW,
	Job,
	Job2,
	Jail,
	Bail,
	Faction,
	FacRank,
	Phone,
	Mats,
	Pot,
	Crack,
	Heroin,
	VIPLevel,
	Moderator,
	Admin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)