SA-MP Forums Archive
warning by sscanf - 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)
+--- Thread: warning by sscanf (/showthread.php?tid=595325)



warning by sscanf - yvoms - 01.12.2015

sscanf warning: Strings without a length are deprecated, please add a destination size.

Even tho i have set the string size..
Also my messages wont show up if there longer then lets say 20 characters, i cant type a full sentence i have to split it up.
the code is shown below, i have set the lenghts right?

Код:
CMD:a(playerid,params[])
{
	new aText[128],aName[MAX_PLAYER_NAME],string[128];
	if(sscanf(params,"s",aText)) return SendClientMessage(playerid,COLOR_WHITE,"{ff387a}[Syntax]:{ffffff} ''/a [text]''.");
	if(pData[playerid][Admin] == 0) return SendClientMessage(playerid,COLOR_WHITE,"{ff0000}[Error]:{ffffff} You are not an Administrator with the required level.");
	GetPlayerName(playerid,aName,sizeof(aName));
	format(string,sizeof(string),"{ff387a}[Admin] {ffffff}%s: %s",aName,aText);
	SendClientMessageToAdmins(COLOR_WHITE,string);
	return 1;
}



Re: warning by sscanf - AbyssMorgan - 01.12.2015

Код:
if(sscanf(params,"s[128]",aText)) return SendClientMessage(playerid,COLOR_WHITE,"{ff387a}[Syntax]:{ffffff} ''/a [text]''.");



Re: warning by sscanf - yvoms - 01.12.2015

omg, i did not see that, is a sscanf string not set lenght by default?


Re: warning by sscanf - DRIFT_HUNTER - 01.12.2015

Quote:
Originally Posted by yvoms
Посмотреть сообщение
omg, i did not see that, is a sscanf string not set lenght by default?
Old include that was written in pawn yes, but since plugin release no.


Re: warning by sscanf - yvoms - 01.12.2015

ah i see thanks for the help tho!


Re: warning by sscanf - Jefff - 01.12.2015

If you are using cmd only with one argument and this argument is string you don't need sscanf, params is your atext
pawn Код:
CMD:a(playerid,params[])
{
    if(pData[playerid][Admin] == 0) return SendClientMessage(playerid,COLOR_WHITE,"{ff0000}[Error]:{ffffff} You are not an Administrator with the required level.");
    if(isnull(params)) return SendClientMessage(playerid,COLOR_WHITE,"{ff387a}[Syntax]:{ffffff} ''/a [text]''.");

    new aName[MAX_PLAYER_NAME],string[145];
    GetPlayerName(playerid,aName,sizeof(aName));
    format(string,sizeof(string),"{ff387a}[Admin] {ffffff}%s: %s",aName,params);
    SendClientMessageToAdmins(COLOR_WHITE,string);
    return 1;
}