Raised This Month: $ Target: $400
 0% 

Constant in if statements?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-04-2011 , 11:08   Re: Constant in if statements?
Reply With Quote #1

Could use bit field, not sure what exactly youre doing but its just an idea. You are limited to using a min of 0 and max of 31 but you can extend it with a little more code. Let me know if you have any questions.
PHP Code:
const NUMBERS << 10 << 15 |<< 30;

var = 
<< << 15;
//true if at least one exists
if ( var & NUMBERS )
     
//true since 1<<15 exists

var = << 15;
// true if only 1 << 15 exists, you can | additional flags
if ( ( var & NUMBERS) == << 15 )
      
//true since only 1<<15 exists
 
var = << 10 << 15 << 20;
//true if all exist
if ( ( var & NUMBERS ) == NUMBERS )
    
//true since all exist 
__________________

Last edited by Bugsy; 08-04-2011 at 11:39.
Bugsy is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 08-04-2011 , 12:52   Re: Constant in if statements?
Reply With Quote #2

Quote:
Originally Posted by Bugsy View Post
Could use bit field, not sure what exactly youre doing but its just an idea. You are limited to using a min of 0 and max of 31 but you can extend it with a little more code. Let me know if you have any questions.
Acually bit wise seems kind of hard. What I'd like to do is just check if the variable is any of the numbers inside the constant. And if it returns true send a fuction.
Erox902 is offline
Reply



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