Raised This Month: $12 Target: $400
 3% 

How to do with one variable


Post New Thread Reply   
 
Thread Tools Display Modes
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 11-13-2020 , 18:02   Re: How to do with one variable
Reply With Quote #11

If it makes no such difference in the back-end, then it makes the code easier to read/manage at most.
Add a bunch of macros to make it even better:


PHP Code:
#define give_user_option(%0, %1) g_Options[%0] |= %1 
PHP Code:
#define remove_user_option(%0, %1) g_Options[%0] &= ~(%1) 
PHP Code:
#define has_user_option(%0, %1) (g_Options[%0] & %1) 

Off-Topic: Who broke the forum's BBCode and why? lol

Last edited by redivcram; 11-13-2020 at 18:03.
redivcram is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 11-14-2020 , 03:21   Re: How to do with one variable
Reply With Quote #12

Quote:
Originally Posted by fysiks View Post
Just because you prefer something doesn't make it good code. We try to give you the best advice to help you learn which won't always be what you "prefer". If the states are mutually exclusive (meaning that you can't be more than one thing at a time) then you should use the method provided in post #2.

The example provided in post #9 shows a case where the states are not mutually exclusive which is a valid use case of bitwise operations.
I understand you, I already know the method used in post 2. And i wanted to learn the one in post 9 and also in my mod a player is one type at a time not 2 or more than that which I think makes sense to use the method of post 9.
Correct me if I am wrong
Abhinash is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-14-2020 , 08:25   Re: How to do with one variable
Reply With Quote #13

Quote:
in my mod a player is one type at a time not 2 or more than that which I think makes sense to use the method of post 9
Nope, it's the opposite. You need the method from post #2 in this case.
If the player can have more types at a time, then you would use post #9.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 11-14-2020 , 10:56   Re: How to do with one variable
Reply With Quote #14

Hey Oxi check this sma which I attached. I wanted to use as it's used in this sma. Tell me if it's not used properly in this sma.
Attached Files
File Type: sma Get Plugin or Get Source (ZPA62-CSBD UPDATED.sma - 47 views - 154.6 KB)
Abhinash is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-15-2020 , 08:22   Re: How to do with one variable
Reply With Quote #15

Quote:
Originally Posted by OciXCrom View Post
Code:
enum _:Types {     P_SNIPER,     P_NEMESIS } new g_iPlayerType[MAX_PLAYERS + 1][Types]

Code:
if(g_iPlayerType[id] == P_SNIPER) {     // your code here }
new Types:g_iPlayerType[MAX_PLAYERS + 1]
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply


Thread Tools
Display Modes

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 03:19.


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