SA-MP Forums Archive
Function "isnull" isn't working properly for me. - 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: Function "isnull" isn't working properly for me. (/showthread.php?tid=581645)



Function "isnull" isn't working properly for me. - Riwerry - 14.07.2015

Hello, I have a little problem. I have defined isnull function. It works without any problem for usual string:
pawn Код:
new string[] = "Hello.";
if(isnull(string))
{
    //Works
}
But I want to check string like this, but it gives me compile error.
pawn Код:
if(isnull(cmdtext[i + 1]))
{
    //Compile errors
}
//Also this works:
if(!strlen(cmdtext[i + 1]))
{
    //Works
}
So, I have loop to check offset of params in command, and I want to check it, if it's null, but it gives me errors ^. Thanks.


Re: Function "isnull" isn't working properly for me. - Virtual1ty - 14.07.2015

Because "isnull" checks if a given string is NULL and it does so cleverly by checking the first element of string, or the second (if it exists).
If you want to check if a given character is NULL take your pick:
PHP код:
new ch '\0';
if (
ch == '\0')
if (
ch == EOS)
if (
ch == 0)
// etc.