SA-MP Forums Archive
sscanf warrning - 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: sscanf warrning (/showthread.php?tid=635276)



sscanf warrning - Elvinas - 04.06.2017

Hello guys,
Maybe someone can help me?

Код:
new Check[ 2 ][ 128 ];
	sscanf( params, "s[ 128 ]s[ 128 ]", Check[ 0 ], Check[ 1 ] );

	if( !strcmp( Check[ 0 ], "say" ) )
	{
		if( !Check[ 1 ][ 0 ] ) return SendMessage( playerid, BLUE, "COMMAND: /a say <text>." );
		if( strlen( Check[ 1 ] ) > 128) return SendMessage( playerid, RED, "ERROR." );
		new string[ 256 ];
		format( string, sizeof( string ), "Admin %s  | %s", NameRPG( playerid ), Check[ 1 ] );
		SendClientMessageToAll(-1, string );
		return true;
	}
I got a few warrning:
Код:
[20:09:13] sscanf warning: Invalid data length.
[20:09:13] sscanf warning: Invalid character in data length.



Re: sscanf warrning - skuller12 - 04.06.2017

Try this code

Код:
new s[128];
if(sscanf(params, "s[128]", s)) return SendMessage( playerid, BLUE, "COMMAND: /a say <text>." );
{
 	if( strlen( s ) > 128) return SendMessage( playerid, RED, "ERROR." );
	new string[ 256 ];
	format( string, sizeof( string ), "Admin %s  | %s", NameRPG( playerid ), s );
	SendClientMessageToAll(-1, string );
	return true;
}



Re: sscanf warrning - Elvinas - 04.06.2017

Not working.
All command:
Код:
CMD:a( playerid, params[ ] )
{
	if( isnull( params ) )
	{
		new string[ 512 ]; // change
		if( pInfo[ playerid ][ Admin ] > 0 )
		{
			strcat( string, "CMD LIST" );
		}
		ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""DIALOG_TITLE" ADMIN CMDS", string, "Close", "" );
		return true;
	}

	new Check[ 2 ][ 128 ];
	sscanf( params, "s[ 128 ]s[ 128 ]", Check[ 0 ], Check[ 1 ] );

	if( !strcmp( Check[ 0 ], "say" ) )
	{
		if( !Check[ 1 ][ 0 ] ) return SendMessage( playerid, BLUE, "COMMAND: /a say <text>." );
		if( strlen( Check[ 1 ] ) > 128) return SendMessage( playerid, RED, "ERROR." );
		new string[ 256 ];
		format( string, sizeof( string ), "Admin %s  | %s", NameRPG( playerid ), Check[ 1 ] );
		SendClientMessageToAll(-1, string );
		return true;
	}
	return true;
}



Re: sscanf warrning - skuller12 - 04.06.2017

Код:
CMD:a(playerid, params[])
{
	new s[128], string[512];
	if(sscanf(params, "s[128]", s)) return SendMessage( playerid, BLUE, "COMMAND: /a say <text>." );
	{
	 	if( strlen(s) == 0)
	 	{
			if( pInfo[ playerid ][ Admin ] > 0 )
			{
				strcat( string, "CMD LIST" );
			}
			ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""DIALOG_TITLE" ADMIN CMDS", string, "Close", "" );
			return true;
		}
		else
		{
			format( string, sizeof( string ), "Admin %s  | %s", NameRPG( playerid ), s );
			SendClientMessageToAll(-1, string );
			return true;
		}
	}
	return 1;
}



Re: sscanf warrning - Elvinas - 04.06.2017

But now it works like:
/a <text>
but I want:
/a s <text>


Re: sscanf warrning - skuller12 - 04.06.2017

Код:
CMD:a(playerid, params[])
{
	new string[512];
	if(isnull(params))
	{
	 	if( pInfo[ playerid ][ Admin ] > 0 )
		{
			strcat( string, "CMD LIST" );
		}
		ShowPlayerDialog( playerid, DIALOG_EMPTY, DIALOG_STYLE_MSGBOX, ""DIALOG_TITLE" ADMIN CMDS", string, "Close", "" );
		return true;
	}
	else
	{
		format( string, sizeof( string ), "Admin %s  | %s", NameRPG( playerid ), params );
		SendClientMessageToAll(-1, string );
		return true;
	}
	return 1;
}



Re: sscanf warrning - Toroi - 04.06.2017

Код:
"s[ 128 ]s[ 128 ]"
You can't use spaces when assigning a length to a string in sscanf. afaik


Re: sscanf warrning - Elvinas - 04.06.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Код:
"s[ 128 ]s[ 128 ]"
You can't use spaces when assigning a length to a string in sscanf. afaik
Thanks.