Raised This Month: $ Target: $400
 0% 

how to format bit values


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-09-2011 , 13:49   how to format bit values
Reply With Quote #1

i'm trying to log all the parameters of Ham_TakeDamage but for damagebits i get 32 if i fell to my death.
But how do i format it to see which bits are used ?

PHP Code:
public FwdTakeDamagePlayerPre(victiminflictorattackerFloatDamagedamagebits)
{
    
    new 
Data[128];
    
formatex(Datacharsmax(Data), "^nvictim = %i^ninflictor = %i^nattacker = %i^n Damage = %.2f^n bits = %i",
    
victiminflictorattackerDamagedamagebits);
    
    
log_to_file("addons/amxmodx/takedamagelog.txt"Data);

i know this is a bad way to log it, but it's just to see the parameters.

This is the output when i fell to my death:
Code:
L 01/09/2011 - 19:44:10: Log file started (file "cstrike\addons\amxmodx\takedamagelog.txt") (game "cstrike") (amx "1.8.1.3746")
L 01/09/2011 - 19:44:10: 
victim = 1
inflictor = 0
attacker = 0
 Damage = 312.50
 bits = 32
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2011 , 14:13   Re: how to format bit values
Reply With Quote #2

It's binary, there is only one answer. http://acc6.its.brooklyn.cuny.edu/~g.../nav2tool.html

Programmatically, you can loop and compare each bit to the damage bit variables (hlsdk_const.inc).
__________________

Last edited by fysiks; 01-09-2011 at 14:16.
fysiks is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-09-2011 , 14:17   Re: how to format bit values
Reply With Quote #3

I get the binary stuff, but i don't know how to convert it to (1<<0) for example.
I'll try to loop and compare them.

Thanks.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2011 , 14:20   Re: how to format bit values
Reply With Quote #4

Quote:
Originally Posted by drekes View Post
I get the binary stuff, but i don't know how to convert it to (1<<0) for example.
I'll try to loop and compare them.

Thanks.
1<<0 is just a scripting representation of a binary number. There are probably ways to find out the bit position without looping. I would suggest looking at the link Bugsy posted for "bit hacks".
__________________
fysiks is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-09-2011 , 14:22   Re: how to format bit values
Reply With Quote #5

will do, thanks.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-09-2011 , 15:21   Re: how to format bit values
Reply With Quote #6

If you don't find anything in the thread fysiks directed you to, try this.

PHP Code:
for ( new 32 p++ )
{
     if ( 
iDmgBits & ( << ) )
          
client_printprint_chat "( 1 << %d ) was found" );

__________________
Bugsy is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-09-2011 , 15:24   Re: how to format bit values
Reply With Quote #7

Thanks Bugsy, and thanks for your bit tutorial too, it's been very helpful.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
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 02:02.


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