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

Detecting Slot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Riotline
AlliedModders Donor
Join Date: Oct 2015
Location: Half Life 3
Old 04-09-2017 , 08:11   Detecting Slot
Reply With Quote #1

I want to see if a player is currently holding/using a slot so I can see if they attack with it!

How can I do this for TF2?
__________________
Riotline is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 04-09-2017 , 08:26   Re: Detecting Slot
Reply With Quote #2

PHP Code:
new activeWeapon GetEntPropEnt(clientProp_Data"m_hActiveWeapon");

if (
activeWeapon != -&& activeWeapon == GetPlayerWeaponSlot(clientSLOT)) 
You can combine it with SDKHook_WeaponEquipPost to detect the equipping
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 04-09-2017 at 08:26.
KissLick is offline
adma
Senior Member
Join Date: Oct 2015
Old 04-09-2017 , 08:39   Re: Detecting Slot
Reply With Quote #3

Adding onto kisslicks answer, if you need to detect all weapon attacks (flamethrower, melee, gunshot) then you can either loop through all clients OnGameFrame or use sdkhook prethink /postthink and then do a check for IN_ATTACK e.g if (GetClientButtons(client) & IN_ATTACK)...
adma is offline
sdz
Senior Member
Join Date: Feb 2012
Old 04-09-2017 , 15:50   Re: Detecting Slot
Reply With Quote #4

Quote:
Originally Posted by adma View Post
Adding onto kisslicks answer, if you need to detect all weapon attacks (flamethrower, melee, gunshot) then you can either loop through all clients OnGameFrame or use sdkhook prethink /postthink and then do a check for IN_ATTACK e.g if (GetClientButtons(client) & IN_ATTACK)...
OnPlayerRunCmd
sdz is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 04-09-2017 , 16:44   Re: Detecting Slot
Reply With Quote #5

Or you can SDKHook player damage and get attackers weapon...
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
adma
Senior Member
Join Date: Oct 2015
Old 04-09-2017 , 16:58   Re: Detecting Slot
Reply With Quote #6

Oh haha sorry my bad, I use prethink in one of my plugins for a weapon check (for something different) and I completely forgot about OnPlayerRunCmd and damage hook. It might have been a tad bit late for me to give any info
adma 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 01:48.


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