SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 08/08/2011, 04:38 PM   #11
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,513
Reputation: 398
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Does this work with enums? Forgot to question this.
__________________
Zh3r0 is offline   Reply With Quote
Old 08/08/2011, 04:54 PM   #12
Double-O-Seven
Guest
 
Posts: n/a
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

How about this:
pawn Code:
bitLim = ((1 << (1 << _: bitShift)) - 1)
//Case Bit1: (1 << (1 << 0) - 1 =  (1 << 1) - 1 = 2 - 1 = 1 is correct!
//Case Bit2: (1 << (1 << 1) - 1 =  (1 << 2) - 1 = 4 - 1 = 3 is correct!
//Case Bit4: (1 << (1 << 2) - 1 =  (1 << 4) - 1 = 16 - 1 = 15 is correct!
//Case Bit8: (1 << (1 << 3) - 1 =  (1 << 8) - 1 = 256 - 1 = 255 is correct!
//Case Bit16: (1 << (1 << 4) - 1 =  (1 << 16) - 1 = 65536 - 1 = 65535 is correct!
//I had to test it because I wasn't sure 100% test.
//OK; Now I'm sure because a shift is a multiplication by 2. And 1 << x == 2 ^ x where ^ denotes power.

Instead of this:
pawn Code:
bitLim = ((1 << floatround(floatpower(2.0, _: bitShift))) - 1)
  Reply With Quote
Old 08/08/2011, 05:06 PM   #13
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,513
Reputation: 398
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Can anyone answer my question? I'm kinda in a hurry, thanks.
__________________
Zh3r0 is offline   Reply With Quote
Old 08/08/2011, 05:08 PM   #14
vyper
Huge Clucker
 
vyper's Avatar
 
Join Date: Jul 2009
Location: Hell. x_x
Posts: 276
Reputation: 68
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Great include I gonna use it thanks
vyper is offline   Reply With Quote
Old 08/08/2011, 05:14 PM   #15
OUL
Big Clucker
 
Join Date: Jun 2011
Posts: 89
Reputation: 2
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

One more question, what about YSI - ybit's are that work on this way too?

And how to use 'if' statement with this rBits (if i can use) or i need to make something like this evry time?

pawn Code:
IsAVariable ( playerid ) return Bit1_Get ( iVariable, playerid );
OUL is offline   Reply With Quote
Old 08/08/2011, 05:21 PM   #16
Double-O-Seven
Guest
 
Posts: n/a
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Quote:
Originally Posted by OUL View Post
One more question, what about YSI - ybit's are that work on this way too?

And how to use 'if' statement with this rBits (if i can use) or i need to make something like this evry time?

pawn Code:
IsAVariable ( playerid ) return Bit1_Get ( iVariable, playerid );
y_bit only supports BitArrays (1bit-arrays, Bit1 in this include).
For if-statements: if (BitX_Get (...)) { /*do something*/ }...
  Reply With Quote
Old 08/08/2011, 05:22 PM   #17
OUL
Big Clucker
 
Join Date: Jun 2011
Posts: 89
Reputation: 2
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Thanks, then very good work Ryder

Is BitGet in boolean type?

so i can use:

pawn Code:
if( BitN_Get ( iVariable, playerid ) == false/true)
OUL is offline   Reply With Quote
Old 08/08/2011, 05:23 PM   #18
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 700
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Quote:
Originally Posted by Zh3r0 View Post
Does this work with enums? Forgot to question this.
What do you exactly mean. Give me an example with normal arrays.

Quote:
Originally Posted by Double-O-Seven View Post
How about this:
pawn Code:
bitLim = ((1 << (1 << _: bitShift)) - 1)
//Case Bit1: (1 << (1 << 0) - 1 =  (1 << 1) - 1 = 2 - 1 = 1 is correct!
//Case Bit2: (1 << (1 << 1) - 1 =  (1 << 2) - 1 = 4 - 1 = 3 is correct!
//Case Bit4: (1 << (1 << 2) - 1 =  (1 << 4) - 1 = 16 - 1 = 15 is correct!
//Case Bit8: (1 << (1 << 3) - 1 =  (1 << 8) - 1 = 256 - 1 = 255 is correct!
//Case Bit16: (1 << (1 << 4) - 1 =  (1 << 16) - 1 = 65536 - 1 = 65535 is correct!
//I had to test it because I wasn't sure 100% test.
//OK; Now I'm sure because a shift is a multiplication by 2. And 1 << x == 2 ^ x where ^ denotes power.

Instead of this:
pawn Code:
bitLim = ((1 << floatround(floatpower(2.0, _: bitShift))) - 1)
That's even better! Changing right now, thanks.
__________________

Sup?
RyDeR` is offline   Reply With Quote
Old 08/08/2011, 05:26 PM   #19
OUL
Big Clucker
 
Join Date: Jun 2011
Posts: 89
Reputation: 2
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Ryder @enums

pawn Code:
enum iData { SomeVar };
new
     PlayerInfo[MAX_PLAYERS][iData];

How to use in that case rBit?
OUL is offline   Reply With Quote
Old 08/08/2011, 05:26 PM   #20
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,513
Reputation: 398
Default Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays]

Quote:
Originally Posted by RyDeR` View Post
What do you exactly mean. Give me an example with normal arrays.



That's even better! Changing right now, thanks.
I mean, I have an enum, and want to use the enum.

pawn Code:
enum pData { level, etc, etc2 };
new Pi[MAX_PLAYERS][pData];

That's an example, how do I do it with enums?

@OUL Same time, sorry

@Edit, How do I increment or decrease a value?
Ah, nevermind, I use bitx_get() + 1. Right?
__________________
Zh3r0 is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] vDealer, probally the most simple vehicledealer system (Supports Y_INI & MYSQL!) Make your own vehicleshops in 1 line! gamer931215 Includes 122 19/05/2014 03:54 PM
TrueServe doesn't supports Hosted Tab? Ouch_Charlie General 3 14/05/2011 03:30 PM
[FilterScript] [FS] ezConverter - Now supports CreateVehicle! Rzzr Filterscripts 13 16/03/2010 10:25 PM
[DAntiCheat] Bye Bye cheaters ... (0.12, SUPPORTS ONLY 0.1b) DracoBlue Filterscripts 261 20/10/2009 11:20 AM


All times are GMT. The time now is 08:33 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.