Raised This Month: $51 Target: $400
 12% 

[TF2] Get active weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mnkras
Senior Member
Join Date: Mar 2009
Location: 127.0.0.1
Old 12-20-2009 , 20:34   [TF2] Get active weapon
Reply With Quote #1

How would i get the active weapon of a player? such as if he has a melee weapon out etc,

not if he has it equipped, but actually out,

Any help is appreciated! Thanks!
__________________
Mnkras is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 12-20-2009 , 20:40   Re: [TF2] Get active weapon
Reply With Quote #2

new hClientWeapon = GetEntPropEnt(Client, Prop_Send, "m_hActiveWeapon");

Double check that.
Wazz is offline
Chris-_-
SourceMod Donor
Join Date: Oct 2008
Old 12-20-2009 , 20:42   Re: [TF2] Get active weapon
Reply With Quote #3

http://docs.sourcemod.net/api/index....d=show&id=425&

Doesn't this work?
Chris-_- is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 12-20-2009 , 20:48   Re: [TF2] Get active weapon
Reply With Quote #4

Depends what he wants ;)
Wazz is offline
Mnkras
Senior Member
Join Date: Mar 2009
Location: 127.0.0.1
Old 12-21-2009 , 09:37   Re: [TF2] Get active weapon
Reply With Quote #5

which do you suggest? i am going to have it so that there is an effect on the player if they have that weapon out
__________________
Mnkras is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 12-21-2009 , 09:45   Re: [TF2] Get active weapon
Reply With Quote #6

It depends on if you need to do anything to the weapon entity. If so, get m_hActiveWeapon, otherwise just use getclientweapon.
Dragonshadow is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-21-2009 , 09:46   Re: [TF2] Get active weapon
Reply With Quote #7

Quote:
Originally Posted by Mnkras View Post
which do you suggest? i am going to have it so that there is an effect on the player if they have that weapon out
Looking up the m_hActiveWeapon will tell you the entity index of the weapon. From there, you can get the classname with GetEdictClassname (after checking IsValidEdict ofc) and easily get/set properties of the weapon.

If you only need the classname and nothing else (ex. "tf_weapon_flamethrower"), then the GetClientWeapon function is simpler to use and would be a better fit.
psychonic is offline
Mnkras
Senior Member
Join Date: Mar 2009
Location: 127.0.0.1
Old 12-21-2009 , 10:10   Re: [TF2] Get active weapon
Reply With Quote #8

i am going to be modifying the player's speed based on the weapon they have out like the knife in css
__________________
Mnkras is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 12-21-2009 , 14:48   Re: [TF2] Get active weapon
Reply With Quote #9

Quote:
Originally Posted by Mnkras View Post
i am going to be modifying the player's speed based on the weapon they have out like the knife in css
then GetClientWeapon will work just fine for you
Dragonshadow 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 15:57.


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