SA-MP Forums Archive
samp isnull - 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: samp isnull (/showthread.php?tid=485316)



samp isnull - audriuxxx - 03.01.2014

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;
	}



AW: samp isnull - CutX - 03.01.2014

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


Re: samp isnull - Konstantinos - 03.01.2014

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.


AW: Re: samp isnull - CutX - 03.01.2014

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


Re: samp isnull - Emmet_ - 03.01.2014

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))
{
    // ...
}