sscanf warning: Strings without a length are deprecated, please add a destination size. - 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: sscanf warning: Strings without a length are deprecated, please add a destination size. (
/showthread.php?tid=585973)
sscanf warning: Strings without a length are deprecated, please add a destination size. -
PowerF - 18.08.2015
Код:
COMMAND:top10(playerid, params[])
{
mysql_query("SELECT `playerName`, `playerXP` FROM `playerdata` WHERE `playerXP` > 0 ORDER BY `playerXP` DESC LIMIT 10");
mysql_store_result();
if(mysql_num_rows() > 0) {
new
playerName[MAX_PLAYER_NAME],
playerXP,
i = 1,
szMessage[640],
szReturn[640];
while(mysql_fetch_row(szReturn)) {
sscanf(szReturn, "p<|>s[120]d", playerName, playerXP);
format(szMessage, sizeof(szMessage), "%d. %s - %d XP", i, playerName, playerXP);
SendClientMessage(playerid, -1, szMessage);
i++;
}
return mysql_free_result();
}
return 1;
}
Re: sscanf warning: Strings without a length are deprecated, please add a destination size. -
dominik523 - 18.08.2015
So playerName is set to MAX_PLAYER_NAME, 24 characters long, and you've put a string specifier of 120 characters in your sscanf.