detecting null variable? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: detecting null variable? (
/showthread.php?tid=264431)
detecting null variable? -
plutoniumman - 26.06.2011
I need to detect if a variable (string) is null or contains no data.
If it were javascript, it'd look like this:
var name = prompt ("Enter your name","") //prompts user for name; stores it in variable 'name'
if (name == null) //if name is null...
{
//execute this code
} else {
//otherwise execute this
}
Re: detecting null variable? -
Bakr - 26.06.2011
You would need to use the isnull( ) function. This one is found inside zcmd.inc, credits to ZeeX.
pawn Код:
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
Re: detecting null variable? -
plutoniumman - 26.06.2011
Awesome works perfectly
Tyvm