SA-MP Forums Archive
How many && can you use in a IF structure? - 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 many && can you use in a IF structure? (/showthread.php?tid=599646)



How many && can you use in a IF structure? - Lucky13 - 28.01.2016

The question is simple. I'm wondering how many && can you use in a if structure-..is there a limit or?


Re: How many && can you use in a IF structure? - SumX - 28.01.2016

I don't think that it has a limit, but I may be wrong, just guessing, but why?


Re: How many && can you use in a IF structure? - Lucky13 - 28.01.2016

I'm developing a Roleplay server and some commands require you to have certain things. ( such as not be cuffed, be spawned, not AFK etc-.. )


Re: How many && can you use in a IF structure? - JamalMaddox - 28.01.2016

Well I'm not sure but it can be used after "%d", &[...]. Not quite sure tho.


Re: How many && can you use in a IF structure? - Sithis - 28.01.2016

I don't believe there is a limit, but do take performance into account. Using lots of && might have worse performance than a well structured database query.


Re: How many && can you use in a IF structure? - Lucky13 - 28.01.2016

Thank you for the answers and Sithis, nice posts count xD


Re: How many && can you use in a IF structure? - Misiur - 28.01.2016

As a sidenote: If you are interested check out y_groups, you can filter commands by player groups.


Re: How many && can you use in a IF structure? - Sithis - 28.01.2016

y_groups is a good feature indeed!

To Lucky13: What kind of code are you creating, are you using mysql? If you want, I might be able to assist you with joins and stuff if you really want an efficient system. Feel free to drop me a PM and we'll sort it out via Skype.


Re: How many && can you use in a IF structure? - Pottus - 28.01.2016

Quote:
Originally Posted by Lucky13
Посмотреть сообщение
I'm developing a Roleplay server and some commands require you to have certain things. ( such as not be cuffed, be spawned, not AFK etc-.. )
In that case you are best to just stack if() return one lines ex.

Код:
if(!p_DATA[playerid][p_Cuffed]) return SendClientMessage(...);
if(!p_DATA[playerid][p_AFK]) return SendClientMessage(...);



Re: How many && can you use in a IF structure? - xTURBOx - 29.01.2016

Quote:
Originally Posted by Pottus
Посмотреть сообщение
In that case you are best to just stack if() return one lines ex.

Код:
if(!p_DATA[playerid][p_Cuffed]) return SendClientMessage(...);
if(!p_DATA[playerid][p_AFK]) return SendClientMessage(...);
i prefer this cause you can have separate error messages(eg: if cuffed"ERRORlayer is cuffed, you cannot use this cmd on him",if afk"ERRORlayer is afk. you cannot use this command on him"