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

Double Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-13-2020 , 12:49   Re: Double Damage
Reply With Quote #21

Quote:
Originally Posted by Bugsy View Post
Depends on the value stored. There are 8 bits in a byte, if the value of the byte is 0 the bits will be 0000 0000. If the byte holds 1, the bits will be 0000 0001.

0 = 0000 0000
1 = 0000 0001
2 = 0000 0010
3 = 0000 0011
4 = 0000 0100
5 = 0000 0101
6 = 0000 0110
How about 7? will that be 0000 0111 ?
and 8 would be 0000 1000?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-13-2020 , 12:55   Re: Double Damage
Reply With Quote #22

yup
__________________
Bugsy is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-13-2020 , 13:20   Re: Double Damage
Reply With Quote #23

Awesome, thanks guys
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-13-2020 , 15:43   Re: Double Damage
Reply With Quote #24

Here's a mini tutorial for weapons:

new g_WeaponList = ( 1 << CSW_AK47 ) | ( 1 << CSW_M4A1 ) | ( 1 << CSW_AWP )

PHP Code:
#define CSW_AWP             18
#define CSW_M4A1            22
#define CSW_AK47            28 
Step 1 for the bitsum is to take 1 and shift it left the number of slots for the weapon ID.

For AWP, take 1 and shift it left 18 slots:
0000 0000 0000 0000 0000 0000 0000 0001 = 1
0000 0000 0000 0100 0000 0000 0000 0000‬ = 1 << 18

Do this for each weapon, bit-wise OR'ing the 3 together and you end up with this:
0001 0000 0100 0100 0000 0000 0000 0000

If a player is currently carrying an AWP, you can check this bit against the bitsum g_WeaponList

0000 0000 0000 0100 0000 0000 0000 0000‬ = 1 << get_user_weapon( id ) -- (assumption is he is holding AWP)
0001 0000 0100 0100 0000 0000 0000 0000 = g_WeaponList
0000 0000 0000 0100 0000 0000 0000 0000‬ = & operation between the above 2

See the matching bit in green? This would make the resulting & operation return non-zero making the condition return true if currently holding AWP.

if ( g_WeaponList & ( 1 << get_user_weapon( id ) ) )
__________________

Last edited by Bugsy; 01-13-2020 at 15:46.
Bugsy is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-14-2020 , 09:15   Re: Double Damage
Reply With Quote #25

Awesome, i'm starting to get a hold of it, thanks for your time & effort both of you!
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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:08.


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