Raised This Month: $ Target: $400
 0% 

Detect Grenade Damage


Post New Thread Reply   
 
Thread Tools Display Modes
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 03-26-2009 , 09:20   Re: Detect Grenade Damage
Reply With Quote #11

Quote:
Originally Posted by Exolent[jNr] View Post
Why not do this:
Code:
public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "FwdPlayerDamage"); } public FwdPlayerDamage(client, inflictor, attacker, Float:damage, damagebits) {     if( fm_is_ent_classname(inflictor, "grenade") && cs_get_weapon_id(inflictor) == CSW_HEGRENADE )     {         // damage from grenade     } }
I have a question related to your code.
Why do you need to do this check?
PHP Code:
cs_get_weapon_id(inflictor) == CSW_HEGRENADE 
Shouldn't this be enough?

Code:
public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "FwdPlayerDamage"); } public FwdPlayerDamage(client, inflictor, attacker, Float:damage, damagebits) {     if( fm_is_ent_classname(inflictor, "grenade") )     {         // damage from grenade     } }
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 03-26-2009 at 09:28.
ot_207 is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 03-26-2009 , 09:44   Re: Detect Grenade Damage
Reply With Quote #12

I believe(but probably not right) that if you don't check it, then any damage from any grenade will be counted. You can damage someone with a flash/smoke.

He's checking that because he wants to make sure it's a HE grenade.

Although, I may be wrong.
BOYSplayCS is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-26-2009 , 10:36   Re: Detect Grenade Damage
Reply With Quote #13

BOYSplayCS wanted to specifically hook HE damage, so as I said in my last post - cs_get_weapon_id() is enough.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-26-2009 , 11:25   Re: Detect Grenade Damage
Reply With Quote #14

My above code does exactly that, try it. It requires no additional function calls.
__________________
Bugsy is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-26-2009 , 11:27   Re: Detect Grenade Damage
Reply With Quote #15

DMG_GRENADE is enough ; what's wrong whit that ?
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 03-26-2009 , 13:50   Re: Detect Grenade Damage
Reply With Quote #16

Quote:
Originally Posted by ot_207 View Post
I have a question related to your code.
Why do you need to do this check?
PHP Code:
cs_get_weapon_id(inflictor) == CSW_HEGRENADE 
Shouldn't this be enough?[/pawn]
I thought about it and I know now what was that for. No need to explain .

And one more thing.
I think that using this will not be good as a condition:
PHP Code:
damagebits DMG_GRENADE 
Because if someone uses ExecuteHamB(Ham_TakeDamage,victim,inflictor,a ttacker,damage,DMG_GRENADE | ANOTHER_TYPE_DAMAGE)
Then we will have problems.
So this is the right way.
PHP Code:
damagebits == DMG_GRENADE 
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 03-26-2009 at 13:57.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-26-2009 , 14:24   Re: Detect Grenade Damage
Reply With Quote #17

Whatever & or ==, it's up to your need.
Arkshine is offline
Old 03-26-2009, 19:27
khios
This message has been deleted by khios. Reason: People prefer seeing multi-threads for the same answer.... Fine with me!
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 03-26-2009 , 19:35   Re: Detect Grenade Damage
Reply With Quote #18

Oh, thank you for hi-jacking my thread. Get out.
BOYSplayCS is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-26-2009 , 21:42   Re: Detect Grenade Damage
Reply With Quote #19

Quote:
Originally Posted by ot_207 View Post
And one more thing.
I think that using this will not be good as a condition:
PHP Code:
damagebits DMG_GRENADE 
Because if someone uses ExecuteHamB(Ham_TakeDamage,victim,inflictor,a ttacker,damage,DMG_GRENADE | ANOTHER_TYPE_DAMAGE)
Then we will have problems.
So this is the right way.
PHP Code:
damagebits == DMG_GRENADE 
He made a simple request and I posted a simple solution. The bottom line is (DMG_GRENADE & damage) will return true when injured by a grenade. Of course there is a list of what-if's that can be thrown into the equation but he did not specify anything. Your statement\method can be what causes a problem since doing a (damage == DMG_GRENADE) check on ExecuteHamB(Ham_TakeDamage,victim,inflictor,a ttacker,damage,DMG_GRENADE | ANOTHER_TYPE_DAMAGE) would fail to detect grenade damage.
__________________

Last edited by Bugsy; 03-26-2009 at 22:15.
Bugsy is offline
Old 03-26-2009, 23:57
Dores
This message has been deleted by Dores.
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 03-27-2009 , 01:52   Re: Detect Grenade Damage
Reply With Quote #20

Quote:
Originally Posted by Bugsy View Post
He made a simple request and I posted a simple solution. The bottom line is (DMG_GRENADE & damage) will return true when injured by a grenade. Of course there is a list of what-if's that can be thrown into the equation but he did not specify anything. Your statement\method can be what causes a problem since doing a (damage == DMG_GRENADE) check on ExecuteHamB(Ham_TakeDamage,victim,inflictor,a ttacker,damage,DMG_GRENADE | ANOTHER_TYPE_DAMAGE) would fail to detect grenade damage.
By DMG_GRENADE | ANOTHER_TYPE_DAMAGE I meant that you could use that but not as a grenade damage. Damage of a weapon or something else...
Anyway it doesn't matter. It depends on what you want to do...
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
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 21:33.


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