Strange sscanf warning?
#1

Hello
Im trying to do a simple command with sscanf but the server console says this: sscanf warning: Strings without a length are deprecated, please add a destination size. Anyone know's why?
The code:
pawn Код:
command(ooc, playerid, params[])
{
    new text[128], string[128];
    if (sscanf(params, "s", text)) SendClientMessage(playerid, GREY, "USAGE: /Ooc [Text]");
    else
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(string, sizeof(string), "((OOC Chat: %s: %s ))" , Name, text);
        SendClientMessageToAll(WHITE, string);
    }
    return 1;
}
(Yes I know its bad scripted but thats not the problem right now) :P
Reply
#2

pawn Код:
// Use sscanf2
if (sscanf(params, "s[128]", text)) SendClientMessage(playerid, GREY, "USAGE: /Ooc [Text]");
Reply
#3

Oh.. I see Thanks
Reply
#4

Quote:
Originally Posted by Fj0rtizFredde
Oh.. I see Thanks
i see a issue make the string 256
Reply
#5

Make the string 128 or [MAX_STRING].
Reply
#6

Quote:
Originally Posted by IamNotKoolllll
Quote:
Originally Posted by Fj0rtizFredde
Oh.. I see Thanks
i see a issue make the string 256
Strings should never be 256 .. that's a hella big string.
Reply
#7

Quote:
Originally Posted by _❼_
Quote:
Originally Posted by IamNotKoolllll
Quote:
Originally Posted by Fj0rtizFredde
Oh.. I see Thanks
i see a issue make the string 256
Strings should never be 256 .. that's a hella big string.
I use 256 all the time, and use 128 for name strings. 256 for things like formatting, or I use tmp as a string all the time, which is 256...
Reply
#8

Quote:
Originally Posted by Teh_Dude
Quote:
Originally Posted by _❼_
Quote:
Originally Posted by IamNotKoolllll
Quote:
Originally Posted by Fj0rtizFredde
Oh.. I see Thanks
i see a issue make the string 256
Strings should never be 256 .. that's a hella big string.
I use 256 all the time, and use 128 for name strings. 256 for things like formatting, or I use tmp as a string all the time, which is 256...
128 > 256
Reply
#9

This command should look like this:
pawn Код:
command(ooc, playerid, params[])
{
    if(isnull(params)) SendClientMessage(playerid, GREY, "USAGE: /Ooc [Text]");
    else
    {
        GetPlayerName(playerid, Name, sizeof(Name)); new string[128];
        format(string, sizeof(string), "((OOC Chat: %s: %s ))" , Name, params);
        SendClientMessageToAll(WHITE, string);
    }
    return 1;
}
Don't use sscanf where you have only one parameter.
Reply
#10

Quote:
Originally Posted by Teh_Dude
Quote:
Originally Posted by _❼_
Quote:
Originally Posted by IamNotKoolllll
Quote:
Originally Posted by Fj0rtizFredde
Oh.. I see Thanks
i see a issue make the string 256
Strings should never be 256 .. that's a hella big string.
I use 256 all the time, and use 128 for name strings. 256 for things like formatting, or I use tmp as a string all the time, which is 256...
128 is the maximum a message can be to be sent in game. And 24 is the maximum player name length. Plus most of the time the whole string isn't even used. The only time you would need a bigger string is maybe in a textdraw.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)