Return sscanf
#1

Hello!

Код:
command(test,playerid,params[])
{
    new String1[64], String2[64];

	if(!sscanf(params,"ss",String1,String2))
	{
	  SendClientMessageToAll(COLOR_RED,String1);
	  SendClientMessageToAll(COLOR_WHITE,String2);
	}
	else
	{
	  SendClientMessage(playerid,COLOR_RED,"Usage: /test Word1 Word2");
	}
	return 1;
}
This is my code. If I write '/test' it will return how to use it. If I write '/test bla bla' it will show them to all players. But if I write '/test bla' it will also return how to use it. The question is, how can I make, that when you write '/test bla' it will return that just one word is missing like 'Usage: /test bla Word2'?

Sorry for my English...
Reply
#2

pawn Код:
sscanf(params, "ss ", String1, String2);
if(!strlen(String1[0])) return SendClientMessage(playerid, COLOR_RED, "Usage: /test (Word1) (Word2)");
if(!strlen(String2[0])) return SendClientMessage(playerid, COLOR_RED, "Usage: /test Word1 (Word2)");
or:
pawn Код:
if(sscanf(params, "s ", String1)) return SendClientMessage(playerid, COLOR_RED, "Usage: /test (Word1) (Word2)");
if(sscanf(params[strlen(String1)], "s ", String2)) return SendClientMessage(playerid, COLOR_RED, "Usage: /test Word1 (Word2)");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)