How many && can you use in a IF structure?
#1

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

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

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-.. )
Reply
#4

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

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.
Reply
#6

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

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

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.
Reply
#9

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(...);
Reply
#10

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"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)