SA-MP Forums Archive
Useful Snippet - 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: Useful Snippet (/showthread.php?tid=146538)



Useful Snippet - novox - 08.05.2010

Hey guys!
I haven't seen one of these yet, & I made one a while ago to use in my scripts. It's a small stock to check if a string is empty. It works identical to the PHP function, empty, hence the same function name. It's a tad shorter than using strcmp. If someone has already done this then ignore mine, just figured someone could use it.
pawn Код:
stock empty(const string[])
{
   new _s=(string[0]!=0)?0:1;
   return _s;
}
Usage:
pawn Код:
if(!empty("test"))
{
   print("full");
}
else
{
   print("empty");
}
&& Sorry if this is wrong section, wasn't exactly sure where to place something like this.


Re: Useful Snippet - -Rebel Son- - 08.05.2010

There is a useful Snippet topic..


Re: Useful Snippet - RyDeR` - 08.05.2010

http://forum.sa-mp.com/index.php?topic=12197.0


Re: Useful Snippet - novox - 08.05.2010

Quote:
Originally Posted by [N
BL!nk [DMU - 208.43.133.131:6600] ]
There is a useful Snippet topic..
My bad, I did notice that about 10 hours too late.