sscanf warning: String buffer overflow.
#1

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");
            }
        }
    }
}
Reply
#2

What is it you want?
Reply
#3

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;
}
Reply
#4

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.
Reply
#5

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;
}
Reply
#6

I'm not talking about the parameters guys! -.-
I just want to use ****** method for "String buffer overflow" instead of using "Strlen"
Reply


Forum Jump:


Users browsing this thread: