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

Get slot of tf_wearable?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
boynedmaster
Member
Join Date: Jun 2012
Old 07-16-2015 , 15:12   Get slot of tf_wearable?
Reply With Quote #1

How can I get the slot # of a tf_wearable through TF2Items_OnGiveNamedItem
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-16-2015 , 16:48   Re: Get slot of tf_wearable?
Reply With Quote #2

Any particular reason you need to know the slot number?

Hell, TF2 can't even get cosmetic items slots correct for its own internal functions, such as CTFPlayer::GetEntityForLoadoutSlot, which returns nothing for slots 7 or 10, which are cosmetic 1 and 3 respectively.

For reference, loadout slots are:

0 = Primary
1 = Secondary
2 = Melee
3 = Utility
4 = Building
5 = Unknown
6 = PDA2
7 = Misc
8 = Misc
9 = Action
10 = Misc
11 = Taunt
12 = Taunt
13 = Taunt
14 = Taunt
15 = Taunt
16 = Taunt
17 = Taunt
18 = Taunt

Note: This was taken from g_szLoadoutStringsForDisplay in server_srv.so a while back, so Valve may have given them better names since then.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-16-2015 at 16:52.
Powerlord is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-16-2015 , 16:49   Re: Get slot of tf_wearable?
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
Any particular reason you need to know the slot number?

Hell, TF2 can't even get cosmetic items slots correct for its own internal functions, such as CTFPlayer::GetEntityForLoadoutSlot, which returns nothing for slots 7 or 10, which are cosmetic 1 and 3 respectively.
I need to check if they have a certain hat on, and I was thinking I could check their primary hat and see if the IDs match.
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-16-2015 , 18:31   Re: Get slot of tf_wearable?
Reply With Quote #4

Is there another way I can check if a player has an item on?
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-16-2015 , 20:19   Re: Get slot of tf_wearable?
Reply With Quote #5

You can check an item's item definition index in TF2Items_OnGiveNamedItem.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 07-16-2015 , 20:37   Re: Get slot of tf_wearable?
Reply With Quote #6

Quote:
Originally Posted by boynedmaster View Post
I need to check if they have a certain hat on, and I was thinking I could check their primary hat and see if the IDs match.
All the hats are in the same slot ( misc/8 ). So if you check by slot you will probably only get one hat the player is wearing. I would instead recommend looking at the m_hMyWearables netprop or by looping through all the wearables that belong to the player:
PHP Code:
int wearable MaxClients+1;
while((
wearable FindEntityByClassname(wearable"tf_wearable")) > MaxClients)
{
    if(
GetEntPropEnt(wearableProp_Send"m_hOwnerEntity") == client)
    {
        
// Wearable belongs to player.
    
}

__________________
pheadxdll is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-16-2015 , 20:45   Re: Get slot of tf_wearable?
Reply With Quote #7

Quote:
Originally Posted by Powerlord View Post
You can check an item's item definition index in TF2Items_OnGiveNamedItem.
But that activates once for every hat.
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-16-2015 , 21:23   Re: Get slot of tf_wearable?
Reply With Quote #8

Quote:
Originally Posted by pheadxdll View Post
All the hats are in the same slot ( misc/8 ). So if you check by slot you will probably only get one hat the player is wearing. I would instead recommend looking at the m_hMyWearables netprop or by looping through all the wearables that belong to the player:
PHP Code:
int wearable MaxClients+1;
while((
wearable FindEntityByClassname(wearable"tf_wearable")) > MaxClients)
{
    if(
GetEntPropEnt(wearableProp_Send"m_hOwnerEntity") == client)
    {
        
// Wearable belongs to player.
    
}

How can I get the item ID?
GetEntPropEnt(wearable, Prop_Send, "m_iItemDefinitionIndex") returns -1
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 07-16-2015 , 21:30   Re: Get slot of tf_wearable?
Reply With Quote #9

You almost had it! Use GetEntProp to get the integer value of the m_iItemDefinitionIndex netprop:
Code:
if(GetEntProp(wearable, Prop_Send, "m_iItemDefinitionIndex") == 1157)
__________________

Last edited by pheadxdll; 07-16-2015 at 21:30.
pheadxdll is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-16-2015 , 21:46   Re: Get slot of tf_wearable?
Reply With Quote #10

Quote:
Originally Posted by pheadxdll View Post
You almost had it! Use GetEntProp to get the integer value of the m_iItemDefinitionIndex netprop:
Code:
if(GetEntProp(wearable, Prop_Send, "m_iItemDefinitionIndex") == 1157)
Code:
PrintToServer("%d", GetEntProp(wearable, Prop_Send, "m_iItemDefinitionIndex"));
always prints -1
__________________
I mean Venusaur...with a question mark
boynedmaster 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 20:34.


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