View Single Post
nosoop
Veteran Member
Join Date: Aug 2014
Old 03-21-2019 , 05:36   Re: [TF2] Econ Data (supercedes TF2IDB, TF2ItemsInfo)
Reply With Quote #4

Quote:
Originally Posted by 404UNF View Post
This thing's only been out for a day, I think it'd be safe to just scrap the old name entirely.
I like my backwards compatibility reeeee

Anyways, 0.7.1 has been released with support to convert item slot names to indices and vice-versa.

Considering what I just said about backwards compatibility, ironically enough, I do have to note that the slot values are not compatible with those in TF2IDB and TF2II. Those two plugins return values mapping approximately to the virtual CBaseCombatWeapon::GetSlot() function (which is what GetPlayerWeaponSlot() looks up), while TF2 itself has a slightly different mapping.

I'll refer to the former as "weapon slots", and the latter as "loadout slots".

Here is TF2IDB's list, and this is the current game-specific mapping for comparison (the indices go from 0 to 18 inclusive):

Code:
0: primary
1: secondary
2: melee
3: utility
4: building
5: pda
6: pda2
7: head
8: misc
9: action
11: taunt
So, if you're porting from one of the two to this plugin, don't use the TF2ItemSlot enum values when checking the result of TF2Econ_GetItemSlot() -- convert between slot indices and names with TF2Econ_TranslateLoadoutSlotIndexToName() and TF2Econ_TranslateLoadoutSlotNameToIndex().

If you want to access the entity in a specific loadout slot, it'd be preferable to use an SDKCall to CTFPlayer::GetEntityForLoadoutSlot() or use my maintained fork of Powerlord's TF2 Wearables API, which has a native to do just that.

Otherwise, you may want to grab a variation of GetSlotByName and translate from loadout slot → name → weapon slot.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 03-22-2019 at 00:34.
nosoop is offline