Raised This Month: $ Target: $400
 0% 

1, 2, 4, 8, 16... system


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 04-28-2016 , 16:14   Re: 1, 2, 4, 8, 16... system
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
PHP Code:
enum Knives (<<= 1)
{
    
Knife_First 1
    Knife_Second
,
    
Knife_Third
    Knife_Nth
};

new 
Knivesg_PlayerKnives[33]; 
To add a knife to a player:
PHP Code:
g_PlayerKnives[id] |= Knife_First
To remove it:
PHP Code:
g_PlayerKnives[id] &= ~Knife_First
And somewhere later on to check if they have a specific knife
PHP Code:
if(g_PlayerKnives[id] & Knife_First)
{
    
// They have the first knife
}
if(
g_PlayerKnives[id] & (Knife_Second Knife_Third))
{
    
// They have at least the second or third knife
}
if(
g_PlayerKnives[id] & (Knife_Second Knife_Third) == (Knife_Second Knife_Third))
{
    
// They have both the second and third knives

Search and read up on a few tutorials on bitsums and bit arithmetic around AlliedModders (or even somewhere else). There you will most likely find some useful macros to make it easier for you to deal with bitsums.
g_PlayerKnives[id] |= Knife_First; that gives me an error
__________________
skz 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 18:42.


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