sscanf warrning
#1

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

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

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

Код:
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;
}
Reply
#5

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

Код:
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;
}
Reply
#7

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)