SA-MP Forums Archive
How to check if a variable is set? - 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: How to check if a variable is set? (/showthread.php?tid=616498)



How to check if a variable is set? - godless_phoenix - 05.09.2016

new myvar;
if(random condition) myvar=playerid;

At that point i want to know that myvar have a playerid or null.
But in here (https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables) i read that always initial value is 0. But playerid can be 0 too.

I set myvar to -1 before actions now. But i believe its not logical. So..

Could you help me about that topic please?

Are there any function like isnull,isset etc.


Re: How to check if a variable is set? - Vince - 05.09.2016

An invalid playerid should logically be specified with INVALID_PLAYER_ID. There isn't any null in Pawn.


Re: How to check if a variable is set? - godless_phoenix - 05.09.2016

So how can i do that then,

new myvararrl[MAX_PLAYERS][10]={{INVALID_PLAYER_ID}};

without using a loop to set.