sscanf warning: String buffer overflow. -
Juvanii - 24.06.2014
Quote:
Originally Posted by ******
fixes 2
pawn Код:
public OnServerMessage(const msg[]) { if (!strcmp(msg, "sscanf warning: ", false, 16)) { if (!strcmp(msg[16], "String buffer overflow.")) { SendClientMessage(gLastPlayer, X11_RED, "Please type something shorter"); } } }
|
May somebody tell me why it's not working! I decided to use this instead of using
"strlen" in each command, but it send the message with
returning true for the command.
Example:
pawn Код:
CMD:say(playerid, params[])
{
new text[50];
if(sscanf(params, "s[50]", text))return SendClientMessage(playerid, COLOR_WHITE, "/say [text]");
SendClientMessageToAll(COLOR_GREEN, text);
return 1;
}
So if the text is above 50 letters, it will send the message to all with
"Please type something shorter"
Just Like: /say "text above 50 letters"
Message would be like:
the text that above 50 letters.
Please type something shorter.
Note: I'm using it as a loop as far as gLastPlayer is not defined.
pawn Код:
public OnServerMessage(const msg[])
{
if (!strcmp(msg, "sscanf warning: ", false, 16))
{
if (!strcmp(msg[16], "String buffer overflow."))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SendClientMessage(i, COLOR_RED, "Please type something shorter");
}
}
}
}
Re: sscanf warning: String buffer overflow. -
Ciandlah - 25.06.2014
What is it you want?
Re: sscanf warning: String buffer overflow. -
]Rafaellos[ - 25.06.2014
Is this what you want?
pawn Код:
CMD:say(playerid, params[])
{
new text[50];
if(sscanf(params, "s[50]", text)) return SendClientMessage(playerid, COLOR_WHITE, "/say [text]");
if(strlen(text) > 50)
{
SendClientMessage(playerid, COLOR_GREEN, "The text that above 50 letters.");
SendClientMessage(playerid, COLOR_RED, "Please type something shorter.");
return 1;
}
SendClientMessageToAll(COLOR_GREEN, text);
return 1;
}
Re: sscanf warning: String buffer overflow. -
Juvanii - 25.06.2014
I just want to return the command to "false" and send only "Please type something shorter"
So if the text above 50 letters, it'll send "Please type something shorter".
And if it's below 50 letters, it'll send the text only.
Re: sscanf warning: String buffer overflow. -
Jefff - 25.06.2014
You don't need sscanf for command with only 1 argument
pawn Код:
CMD:say(playerid, params[])
{
if(isnull(params)) SendClientMessage(playerid, COLOR_WHITE, "/say [text]");
else if(strlen(params) > 50)
{
SendClientMessage(playerid, COLOR_GREEN, "The text that above 50 letters.");
SendClientMessage(playerid, COLOR_RED, "Please type something shorter.");
}else
SendClientMessageToAll(COLOR_GREEN, params);
return 1;
}
Re: sscanf warning: String buffer overflow. -
Juvanii - 25.06.2014
I'm not talking about the parameters guys! -.-
I just want to use ****** method for "String buffer overflow" instead of using "Strlen"