Raised This Month: $32 Target: $400
 8% 

[TF2] How to check player is holding Bonk / Crit-a-Cola / Sandvich / Buffalo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Steveh
Member
Join Date: Oct 2010
Old 06-21-2011 , 14:38   [TF2] How to check player is holding Bonk / Crit-a-Cola / Sandvich / Buffalo
Reply With Quote #1

Hello,

I need some help with my plugin, How would I check a client to see if their current weapon is Bonk / Crit-a-Cola / Buffalo Steak / Sandvich?

Thanks in advance
Steveh
Steveh is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-21-2011 , 14:49   Re: [TF2] How to check player is holding Bonk / Crit-a-Cola / Sandvich / Buffalo
Reply With Quote #2

You'd use GetClientWeapon and compare the value you get against the weapon names given on the Team Fortress 2 Weapons page.

I'm not sure how up to date that page is... the Demoman in particular appears to be missing a lot of his melee weapons.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Tylerst
Veteran Member
Join Date: Oct 2010
Old 06-21-2011 , 21:51   Re: [TF2] How to check player is holding Bonk / Crit-a-Cola / Sandvich / Buffalo
Reply With Quote #3

You can also check the active weapon and compare the weapon index for specific things.

PHP Code:
new activeweapon FindSendPropOffs("CTFPlayer""m_hActiveWeapon");
for (new 
1<= MaxClientsi++)  
{
     new 
weapon GetEntDataEnt2(iactiveweapon);
     if(
IsValidEntity(weapon))
     {
          new 
weaponindex GetEntProp(weaponProp_Send"m_iItemDefinitionIndex");
          switch(
weaponindex)
          {
               case 
46:
               {
                    
//Dostuff if Bonk
               
}
               case 
163:
               {
                    
//Dostuff if Crit-a-Cola
               
}
               case 
42:
               {
                    
//Dostuff if Sandvich
               
}
               case 
311:
               {
                    
//DoStuff if Buffalo Steak
               
}
          }
          
/*Or alternatively
          switch(weaponindex)
          {
               case 46, 163, 42, 311:
               {
                    //DoStuff for any of them
               }
          }
          */
     



Item Indexes(Can also be found in tf/scripts/items_game.txt)

Last edited by Tylerst; 06-21-2011 at 22:36.
Tylerst is offline
Steveh
Member
Join Date: Oct 2010
Old 06-22-2011 , 02:31   Re: [TF2] How to check player is holding Bonk / Crit-a-Cola / Sandvich / Buffalo
Reply With Quote #4

Thanks for the replies. This thread has now been solved.

Steveh
Steveh is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-22-2011 , 10:20   Re: [TF2] How to check player is holding Bonk / Crit-a-Cola / Sandvich / Buffalo
Reply With Quote #5

I forgot to mention that I updated the TF2 Weapons page on the Wiki yesterday... it was missing the samurai weapons (and a whole boatload of hats, but no one in this thread cares about those).

I just have to remember to update it again on Thursday. As of right now, we know Thursday's update will have 13 new weapons for Heavy, Spy, Sniper, Demoman, and Scout (as well as 1 hat for each and 1 misc for Spy), and will likely have more announced today.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 17:28.


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