Strange sscanf warning? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Strange sscanf warning? (
/showthread.php?tid=143222)
Strange sscanf warning? -
Fj0rtizFredde - 21.04.2010
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
Re: Strange sscanf warning? -
smeti - 21.04.2010
pawn Код:
// Use sscanf2
if (sscanf(params, "s[128]", text)) SendClientMessage(playerid, GREY, "USAGE: /Ooc [Text]");
Re: Strange sscanf warning? -
Fj0rtizFredde - 21.04.2010
Oh.. I see
Thanks
Re: Strange sscanf warning? -
IamNotKoolllll - 21.04.2010
Quote:
Originally Posted by Fj0rtizFredde
Oh.. I see Thanks
|
i see a issue make the string 256
Re: Strange sscanf warning? -
Goobiiify - 21.04.2010
Make the string 128 or [MAX_STRING].
Re: Strange sscanf warning? -
dcmd_crash - 26.04.2010
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.
Re: Strange sscanf warning? -
IamNotKoolllll - 09.05.2010
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...
Re: Strange sscanf warning? -
dcmd_crash - 09.05.2010
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
Re: Strange sscanf warning? -
Sergei - 09.05.2010
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.
Re: Strange sscanf warning? -
Backwardsman97 - 09.05.2010
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.