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

Get slot of tf_wearable?


Post New Thread Reply   
 
Thread Tools Display Modes
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-16-2015 , 22:11   Re: Get slot of tf_wearable?
Reply With Quote #11

Quote:
Originally Posted by pheadxdll View Post
I would instead recommend looking at the m_hMyWearables netprop
(ignoring the other part as it should work)

m_hMyWearables is a CUtlVector datatable, which SourceMod can't (yet?) read.

There's a reason for this: CUtlVector datatables are totally fake. Their datatable is just a clever wrapper that contains information about the CUtlVector, such as the pointer to it, the number of elements in it, and the size of each element. The base pointer needs to be obtained via a method call from there, which all the numbered entries are offset from.

I've done some research on this, but this is only one of the uses of CUtlVector netprops... the other is for nested netprops which would require a significant restructuring of the netprops system in order to work.

If I ever get off my butt working on the alternative way of reading netprops (i.e. needing the entire "path" for a netprop), the ability to read CUtlVectors will show up in it.

Quote:
Originally Posted by boynedmaster View Post
But that activates once for every hat.
Yes, it does.

It's also the best way to block a player from wearing / equipping an item.

Granted, it doesn't work for removing them later on.
__________________
Not currently working on SourceMod plugin development.

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

Quote:
Originally Posted by Powerlord View Post
m_hMyWearables is a CUtlVector datatable, which SourceMod can't (yet?) read.

There's a reason for this: CUtlVector datatables are totally fake. Their datatable is just a clever wrapper that contains information about the CUtlVector, such as the pointer to it, the number of elements in it, and the size of each element. The base pointer needs to be obtained via a method call from there, which all the numbered entries are offset from.

I've done some research on this, but this is only one of the uses of CUtlVector netprops... the other is for nested netprops which would require a significant restructuring of the netprops system in order to work.

If I ever get off my butt working on the alternative way of reading netprops (i.e. needing the entire "path" for a netprop), the ability to read CUtlVectors will show up in it.



Yes, it does.

It's also the best way to block a player from wearing / equipping an item.

Granted, it doesn't work for removing them later on.
But what I'm doing is I have a bool array with length MAXPLAYERS+1, and it basically says if a player is wearing the item or not.
Using the forward wouldn't help.
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-16-2015 , 22:19   Re: Get slot of tf_wearable?
Reply With Quote #13

Quote:
Originally Posted by boynedmaster View Post
But what I'm doing is I have a bool array with length MAXPLAYERS+1, and it basically says if a player is wearing the item or not.
Using the forward wouldn't help.
Maybe it'd help if you explained what you were trying to do so we can address the actual problem instead of the XY problem.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-16-2015 , 22:48   Re: Get slot of tf_wearable?
Reply With Quote #14

Quote:
Originally Posted by Powerlord View Post
Maybe it'd help if you explained what you were trying to do so we can address the actual problem instead of the XY problem.
I'm trying to give a specific hat a custom attribute.
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 07-16-2015 , 23:52   Re: Get slot of tf_wearable?
Reply With Quote #15

Quote:
Originally Posted by Powerlord View Post
m_hMyWearables is a CUtlVector datatable, which SourceMod can't (yet?) read.
TF2Attributes iterates a CUtlVector from a plugin. Not pretty, but possible.

Quote:
I'm trying to give a specific hat a custom attribute.
You are much better off using the TF2Items_OnGiveNamedItem forward, catching the creation of the hat you are interested in, and then applying what ever custom attributes you want.
__________________
pheadxdll is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-17-2015 , 00:04   Re: Get slot of tf_wearable?
Reply With Quote #16

Quote:
Originally Posted by pheadxdll View Post
TF2Attributes iterates a CUtlVector from a plugin. Not pretty, but possible.



You are much better off using the TF2Items_OnGiveNamedItem forward, catching the creation of the hat you are interested in, and then applying what ever custom attributes you want.
But the attribute is meant to run before player_death.
__________________
I mean Venusaur...with a question mark
boynedmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-17-2015 , 15:00   Re: Get slot of tf_wearable?
Reply With Quote #17

Quote:
Originally Posted by pheadxdll View Post
TF2Attributes iterates a CUtlVector from a plugin. Not pretty, but possible.
Doing this requires that you hard-code memory offsets... and you will get burned if you try to copy code written for a CUtlVector with one CAllocator type to one that uses a different CAllocator type.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
boynedmaster
Member
Join Date: Jun 2012
Old 07-17-2015 , 16:46   Re: Get slot of tf_wearable?
Reply With Quote #18

I got it. It's a really hacky way of doing it and I can't really explain how but I got it.
__________________
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 19:02.


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