Raised This Month: $ Target: $400
 0% 

Solved Check if a player was damaged by a grenade


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 10-30-2018 , 20:29   Check if a player was damaged by a grenade
Reply With Quote #1

How do I check if a player was damaged by a normal he-grenade?
I'm trying to do so in SDKHooks_OnTakeDamage. There is a parameter called &weapon, how do I use that? Printing the &weapon as an int returned -1.
Any other weapon would also be nice to know.

This is for CS:GO.

EDIT: Thank you to everyone!
For anyone interested, see how I did it at my last comment.

Last edited by joac1144; 10-31-2018 at 06:27.
joac1144 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 10-30-2018 , 23:36   Re: Check if a player was damaged by a grenade
Reply With Quote #2

You're best to check the damage type includes blast.
__________________
Neuro Toxin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-31-2018 , 02:29   Re: Check if a player was damaged by a grenade
Reply With Quote #3

attacker != inflictor

attacker would be client index and inflictor grenade projectile index

*edit
I remember, you not get "weapon" index from OnTakeDamage callbacks in counter strikes.
__________________
Do not Private Message @me

Last edited by Bacardi; 10-31-2018 at 02:30.
Bacardi is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 10-31-2018 , 03:48   Re: Check if a player was damaged by a grenade
Reply With Quote #4

https://wiki.garrysmod.com/page/Enums/DMG
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles] [Donate]
Dragokas is offline
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 10-31-2018 , 04:39   Re: Check if a player was damaged by a grenade
Reply With Quote #5

Quote:
Originally Posted by Neuro Toxin View Post
You're best to check the damage type includes blast.
Quote:
Originally Posted by Dragokas View Post
That's what I'm currently doing. The problem with it is that it also triggers when the C4 explodes which I do not want it to.
Can I somehow check for that?
joac1144 is offline
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 10-31-2018 , 04:41   Re: Check if a player was damaged by a grenade
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
attacker != inflictor

attacker would be client index and inflictor grenade projectile index

*edit
I remember, you not get "weapon" index from OnTakeDamage callbacks in counter strikes.
I've read a bit about that "projectile index", but I don't quite understand how I can use it. How do I check if it's a grenade?

Last edited by joac1144; 10-31-2018 at 04:41.
joac1144 is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 10-31-2018 , 05:30   Re: Check if a player was damaged by a grenade
Reply With Quote #7

Quote:
Originally Posted by joac1144 View Post
I've read a bit about that "projectile index", but I don't quite understand how I can use it. How do I check if it's a grenade?
GetEdictClassname(inflictor)

printtochatall(Classname);

Try this.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 10-31-2018 , 05:41   Re: Check if a player was damaged by a grenade
Reply With Quote #8

joac1144, did you compare an output of all parameters of SDK callback (for C4 and grenade)?
Are there any difference?

Does C4 deal unchangeable damage regardless of distance to explosion point?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles] [Donate]
Dragokas is offline
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 10-31-2018 , 06:24   Re: Check if a player was damaged by a grenade
Reply With Quote #9

Quote:
Originally Posted by eyal282 View Post
GetEdictClassname(inflictor)

printtochatall(Classname);

Try this.
Thank you so much, this worked perfectly!
joac1144 is offline
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 10-31-2018 , 06:25   Re: Check if a player was damaged by a grenade
Reply With Quote #10

Quote:
Originally Posted by Dragokas View Post
joac1144, did you compare an output of all parameters of SDK callback (for C4 and grenade)?
Are there any difference?

Does C4 deal unchangeable damage regardless of distance to explosion point?
I tried getting the inflictor for C4, but no message ever displayed as if the bomb didn't do any damage.
But I got it to work, so everything's okay, thanks!
__________________
joac1144 is offline
Reply


Thread Tools
Display Modes

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 19:05.


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