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

[SNIPPET] TF2 deathflags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r5053
SourceMod Donor
Join Date: May 2007
Location: Germany
Old 06-06-2009 , 12:34   [SNIPPET] TF2 deathflags
Reply With Quote #1

PHP Code:
new deathflags GetEventInt(event"death_flags")
    new 
bool:nofakekill true
    
new bool:df_firstblood false
    
new bool:df_assisterrevenge false
    
new bool:df_killerrevenge false
    
new bool:df_assisterdomination false
    
new bool:df_killerdomination false
    
    
if (deathflags >= 32)
    {
    
deathflags deathflags 32
    nofakekill 
false    
    
}
    if (
deathflags >= 16)
    {
    
deathflags deathflags 16
    df_firstblood 
true    
    
}
    if (
deathflags >= 8)
    {
    
deathflags deathflags 8
    df_assisterrevenge 
true    
    
}
    if (
deathflags >= 4)
    {
    
deathflags deathflags 4
    df_killerrevenge 
true    
    
}
    if (
deathflags >= 2)
    {
    
deathflags deathflags 2
    df_assisterdomination 
true    
    
}
    if (
deathflags == 1)
    {
    
df_killerdomination true    
    

__________________
Visit HLPortal.de (this is not my Page)


r5053 is offline
Send a message via ICQ to r5053 Send a message via Skype™ to r5053
psychonic

BAFFLED
Join Date: May 2008
Old 06-06-2009 , 12:38   Re: [SNIPPET] TF2 deathflags
Reply With Quote #2

Why all the extra math instead of just checking the bits?
Code:
#define killerdomination (1 << 0)
#define assisterdomination (1 << 1)
#define killerrevenge (1 << 2)
#define assisterrevenge (1 << 3)
#define firstblood (1 << 4)
#define feigndeath (1 << 5)

Ex.
if (deathflags & firstblood) {
    //firstblood
}

Last edited by psychonic; 06-18-2009 at 12:10.
psychonic is offline
r5053
SourceMod Donor
Join Date: May 2007
Location: Germany
Old 06-08-2009 , 15:59   Re: [SNIPPET] TF2 deathflags
Reply With Quote #3

damn doku, searched for this but found nothing
__________________
Visit HLPortal.de (this is not my Page)


r5053 is offline
Send a message via ICQ to r5053 Send a message via Skype™ to r5053
r5053
SourceMod Donor
Join Date: May 2007
Location: Germany
Old 06-08-2009 , 16:06   Re: [SNIPPET] TF2 deathflags
Reply With Quote #4

found !!!:

These two operators are also important, but not used often. They are the bitwise shift operators, << is a left shift and >> is a right shift. They shift the bits in a number to one direction.
//This takes the number 3 (00011) and shifts it three places to binary (11000), or 24.
(3 << 3)
//This takes the number 24 (11000) and shifts it three places to binary (00011), or 3.
(24 >> 3)
__________________
Visit HLPortal.de (this is not my Page)


r5053 is offline
Send a message via ICQ to r5053 Send a message via Skype™ to r5053
r5053
SourceMod Donor
Join Date: May 2007
Location: Germany
Old 06-08-2009 , 16:12   Re: [SNIPPET] TF2 deathflags
Reply With Quote #5

ok ... found this:

//4 (00100) is not a bit inside 16 (10000) and this will return 0.
(16 & 4)

means the correct code to check for
killerrevenge is:

#define killerrevenge 4

if (deathflag &
killerrevenge)

(as example)
I think this is better readable
__________________
Visit HLPortal.de (this is not my Page)



Last edited by r5053; 06-08-2009 at 16:24.
r5053 is offline
Send a message via ICQ to r5053 Send a message via Skype™ to r5053
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:24.


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