Damage message, help with DamageType
How do I use damagetype to filter out damage ONLY done by bullets?
Like this? Code:
register_event("Damage", "takedamage","b", "2>1", "3 = (1<<1)");From hlsdk_const I found that list if damage types and for bullets it states: Code:
#define DMG_BULLET 1<<1Or alternatively how could I read value of the third parameter and filter the rest with a simple if statement? |
Re: Damage message, help with DamageType
i think this could be used in ham_takedamage
|
Re: Damage message, help with DamageType
register_event("Damage", "takedamage","b", "2>1", "3=2");
|
Re: Damage message, help with DamageType
Quote:
I even put client_print in it to check, but nothing happens. Is there some other way I can hook a function to be called from only bullet damage? Or possibly use ham_takedamage (which I don't know how to use) for the same purpose? (Would loading hamsandvich just for that one thing be worth it more than using register_event...)? |
Re: Damage message, help with DamageType
Well using ham is better and simple.
Hook PHP Code:
Function PHP Code:
|
Re: Damage message, help with DamageType
Quote:
Code:
public plugin_init()Thanks for trying atleast! My version with Damage message worked sorta, but the user would get healed if he took fall damage. Should I post the entire plugin instead? |
Re: Damage message, help with DamageType
I suppose it should work fine
Code:
public plugin_init() |
Re: Damage message, help with DamageType
Shouldn't it be (damagebits & DMG_BULLET) ?
|
Re: Damage message, help with DamageType
Quote:
(damagebits & DMG_BULLET) its if damagebits contain 2 >> lets imagine thats damagebits carry this bitsum value which is 1111 and DMG_BULLET value its 2 which in bitsum its 0010 so the & operator works like this (1111 & 0010) will return this bitsum value 0010 which its 2. and (damagebits == DMG_BULLET) this condition will only works when its only a bullet damage. |
Re: Damage message, help with DamageType
I agree with kristi, you should use bit-wise operators when working with bitsums. Yes, a direct == will work, but it's more proper to check the specific bit(s) you're looking for. If you are checking for multiple bits then you need to use equals on the result of the operation, such as: if ( ( BitSum & ( FLAG_1 | FLAG_2 ) ) == ( FLAG_1 | FLAG_2 ) ). This will ensure the result includes both bits, not only one or the other.
Also, 0100 is 4, 0010 (1<<1) is 2. So to check for only bullet damage, if ( damagebits & DMG_BULLET ) is good. |
| All times are GMT -4. The time now is 09:56. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.