[ProblemSolved] Explanation for ? : on off menu cvar changer
I have read about 40 posts where xeroblood replied and read menu tutorials, but I have a specific question on how a certain part of a plugin works.
I am trying to understand how exactly the atac menu for atac_cfg plugin changes ON to OFF and vice versa. Code:
2. I do not understand \R because \r is for red but what is \R ??? I understand that (1<<0) is key 1. I understand that it is checking to see if (1<<0) is a bit in option which is get_cvar_num("atac_options") which is = to 8183 in the atac.cfg file. I do not see how it is checking the cvar to know whether to change the menu to display ON or OFF because I do not see how Key 1 is represented by the slap cvar. Does this mean it is checking if Key 1 is a bit in 8183? Could someone explain this so I can understand it? I also do not understand the ? after (option & (1<<0)) or the : between "ON" and "OFF". Are they operators? I do not understand what exactly they are and what exactly they do. Does the ? mean to check if (option & (1<<0)) is true and then if it is true display "ON" and if false display "OFF"? If someone could explain this code and how that works that would help me out. Edit: Thank you for the below explanations I appreciate it everyone. |
I guess \r is case insensitive - I might be wrong though.
But what I can explain is the ?: operator. It's the only ternary operator we have! It has the form: Code:
And this means... If a evaluates to true (non-zero), the value of the expression is b. Otherwise, the value of the expression is c. So, Code:
Code:
|
hello pm!
yes, you are right, \r is case-sensitive. the meaning of the ? operator is pretty simple. it's like an if-condition but much smaller and you can use it for values only.. an example: Code:
you could use this, too, but nobody really likes such code parts: Code:
I hope I could clear that up for you. -- Ga.. Basic-Master |
\r is for the color red \R is to format the rest of the text on that line to the right. (Notice how the 1/2 is on the right of the line?) and yes what they said is true above for the ? and : operators
|
Quote:
Code:
Quote:
|
hello v3x
my code works as well as yours and it was only an example.. but yes, people should use your code then, it's bettAR |
| All times are GMT -4. The time now is 16:43. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.