sscanf
#1

Код:
sscanf(String,"s[24] s[200] s[24] s[10] s[8]",PlayerBannedName[playerid],PlayerBannedReason[playerid],PlayerBannedAdministrator[playerid],PlayerBannedDate[playerid],PlayerBannedTime[playerid]);
Код:
new PlayerBannedName[MAXIMAL_PLAYERS][24];
new PlayerBannedReason[MAXIMAL_PLAYERS][200];
new PlayerBannedAdministrator[MAXIMAL_PLAYERS][24];
new PlayerBannedDate[MAXIMAL_PLAYERS][10];
new PlayerBannedTime[MAXIMAL_PLAYERS][8];
Quote:

[02:17:42] sscanf warning: String buffer overflow.
[02:17:42] sscanf warning: String buffer overflow.

Reply
#2

Are you sure the string size is big enough to handle this?

Might be the reason, not sure, never received this error.
Reply
#3

Код:
public OnPlayerConnect(playerid)
{
	new String[200];
	GetPlayerName(playerid,PlayerName[playerid],24);
	GetPlayerIp(playerid,PlayerIp[playerid],16);
	PlayerRconAdministrator[playerid] = 0;
	PlayerRconPasswordAttempt[playerid] = 0;
	format(String,200,"%s%s.ini",FOLDER_BANS,PlayerIp[playerid]);
	if(fexist(String))
	{
	    PlayerBanned[playerid] = 1;
		new File:File = fopen(String,io_read);
		fread(File,String);
		sscanf(String,"s[24] s[200] s[24] s[10] s[8]",PlayerBannedName[playerid],PlayerBannedReason[playerid],PlayerBannedAdministrator[playerid],PlayerBannedDate[playerid],PlayerBannedTime[playerid]);
		SendClientMessage(playerid,0,""WHITE">> Twoje ip zostało zbanowane.");
		format(String,200,""WHITE">> Nick na ktуrym zostałeś zbanowany to "DARK_WHITE"%s"WHITE".",PlayerBannedName[playerid]);
		SendClientMessage(playerid,0,String);
		format(String,200,""WHITE">> Powуd, za ktуry zostałeś zbanowany to "DARK_WHITE"%s"WHITE".",PlayerBannedReason[playerid]);
		SendClientMessage(playerid,0,String);
		format(String,200,""WHITE">> Administrator ktуry cię zbanował to "DARK_WHITE"%s"WHITE".",PlayerBannedAdministrator[playerid]);
		SendClientMessage(playerid,0,String);
		format(String,200,""WHITE">> Zostałeś zbanowany "DARK_WHITE"%s "WHITE"o godzinie "DARK_WHITE"%s"WHITE".",PlayerBannedDate[playerid],PlayerBannedTime[playerid]);
		SendClientMessage(playerid,0,String);
		Kick(playerid);
	}
	return 1;
}
Reply
#4

any help
Reply
#5

Quote:

sscanf warning: String buffer overflow.

This error comes up when people try and put too much data in to a string. For example:

pawn Code:
new str[10];
sscanf("Hello there, how are you?", "s[10]", str);

That code will try and put the string "Hello there, how are you?" in to the variable called "str". However, "str" is only 10 cells big and can thus only hold the string "Hello ther" (with a NULL terminator). In this case, the rest of the data is ignored - which could be good or bad:

pawn Code:
new str[10], num;
sscanf("Hello there you|42", "p<|>s[10]i", str, num);

In this case "num" is still correctly set to "42", but the warning is given for lost data ("e you").

Currently there is nothing you can do about this from a programming side (you can't even detect it - that is a problem I intend to address), as long as you specify how much data a user should enter this will simply discard the excess, or make the destination variable large enough to handle all cases.

I dont know how fix it...
Reply
#6

In simpler terms.
pawn Код:
sscanf(String,"s[24] s[200] s[24] s[10] s[8]
All the numbers in the [ ]'s are cell sizes, added together is 266. The number between [ ] in "String" is 200. So change
pawn Код:
new String[200];
to
pawn Код:
new String[266];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)