Raised This Month: $ Target: $400
 0% 

[ProblemSolved] Explanation for ? : on off menu cvar changer


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-02-2006 , 17:29   [ProblemSolved] Explanation for ? : on off menu cvar changer
Reply With Quote #1

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:
new option = get_cvar_num("atac_options") format(smenu, 63, "%L\R1/2", id, "MENU_CFG_PTITLE") format(menuoption[0], 63, "\w1. %L\R\y%s^n", id, "MENU_CFG_SLAP", (option & (1<<0)) ? "ON" : "OFF")
1. I do not understand \R1/2 or what it does ???
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.
SubStream is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode