Raised This Month: $ Target: $400
 0% 

[CS:S] How to get weapon index?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_pHabb
Senior Member
Join Date: Jul 2013
Location: GetCountry(pHabb);
Old 05-09-2015 , 17:32   [CS:S] How to get weapon index?
Reply With Quote #1

Hello!

How to get weapon index in "Player Hurt" and "Player Death" events?

Thanks!
_pHabb is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 05-09-2015 , 18:36   Re: [CS:S] How to get weapon index?
Reply With Quote #2

https://wiki.alliedmods.net/Counter-..._Source_Events https://sm.alliedmods.net/api/index....ad=show&id=744
Miu is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 05-09-2015 , 20:07   Re: [CS:S] How to get weapon index?
Reply With Quote #3

He is looking for the weapon index not the weapon classname.
Darkness_ is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 05-09-2015 , 20:23   Re: [CS:S] How to get weapon index?
Reply With Quote #4

oh! my bad. guess you'd get the attacker instead and the weapon would be GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon")
Miu is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 05-10-2015 , 03:48   Re: [CS:S] How to get weapon index?
Reply With Quote #5

In the case of a grenade, using m_hActiveWeapon won't work as the player might have switch weapon.

I'd use SDKHook_OnTakeDamage/SDKHook_OnTakeDamageAlive instead (use the 'inflictor' argument to get the weapon classname).

Note that the if the weapon is a "normal" one (inflictor == attacker && attacker <= MaxClients; I believe), then using m_hActiveWeapon should work.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 05-10-2015 at 03:48.
RedSword is offline
_pHabb
Senior Member
Join Date: Jul 2013
Location: GetCountry(pHabb);
Old 05-10-2015 , 16:41   Re: [CS:S] How to get weapon index?
Reply With Quote #6

Thanks, men.
_pHabb is offline
cam0
Senior Member
Join Date: Feb 2015
Old 05-11-2015 , 01:12   Re: [CS:S] How to get weapon index?
Reply With Quote #7

You can always use CS_WeaponIDToAlias() and CS_AliasToWeaponID() to interchange.
cam0 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 08:13.


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