samp isnull
#1

Hi,

Can i check is null a variable after sscanf, if player not wrote a full command with all parametres? for ex:

Код:
new STOREPLAYERNAME[ 25 ];
new reaaaaaaaaaaason[ 128 ];
if(sscanf(params, "s[25]s[128]", STOREPLAYERNAME, reaaaaaaaaaaason ))
	{
	    if( isnull( STOREPLAYERNAME ) )
{

}
 if( isnull(reaaaaaaaaaaason) )
{

}
		return 1;
	}
Reply
#2

do it like this:
pawn Код:
new a[25],b[128];
if(sscanf(params,"ss",a,b)) return SendClientMessage(playerid,-1,"USAGE: /cmd [a] [b]");
that message will pop up when you missed one of the params
Reply
#3

That's why you check if sscanf doesn't return 0 so it will send an error message about wrong usage (parameters).

Just to let you know though, that if you want to use part of player's name or the playerid, the specifier is u or r (not NPC included) instead of using s (with size) for online players.

@CutX: Use the size:
pawn Код:
if(sscanf(params,"s[25]s[128]",a,b)) ...
otherwise will be 32 by default.
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
@CutX: Use the size:
pawn Код:
if(sscanf(params,"s[25]s[128]",a,b)) ...
otherwise will be 32 by default.
ty didn't know abt. that
Reply
#5

You could try it this way:

pawn Код:
new
    str[64],
    string[64];

if (sscanf(params, "s[64]S(\1)[64]", str, string))
    return 0;

if (isnull(string))
{
    // ...
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)