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

Solved [TF2] Data Econ question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-22-2021 , 15:36   [TF2] Data Econ question
Reply With Quote #1

I'm having an issue with the function below. It works fine when I use it on myself. However, when used as part of a mass target (such as @all or @bots) I find that it only works on 20-50 % of the targets.

Any idea on how to improve the function so I don't get the dreaded "Item definition index 65535 is not valid"?

Here's the error I receive:
Code:
L 12/22/2021 - 12:28:10: [SM] Exception reported: Item definition index 65535 is not valid
L 12/22/2021 - 12:28:10: [SM] Blaming: tf_econ_data.smx
L 12/22/2021 - 12:28:10: [SM] Call stack trace:
L 12/22/2021 - 12:28:10: [SM]   [0] ThrowNativeError
L 12/22/2021 - 12:28:10: [SM]   [1] Line 127, tf_econ_data/item_definition.sp::Native_GetItemEquipRegionMask
L 12/22/2021 - 12:28:10: [SM]   [3] TF2Econ_GetItemEquipRegionMask
L 12/22/2021 - 12:28:10: [SM]   [4] Line 609, gimme.sp::RemoveConflictWearables
L 12/22/2021 - 12:28:10: [SM]   [5] Line 500, gimme.sp::Items_CreateNamedItem
L 12/22/2021 - 12:28:10: [SM]   [6] Line 349, gimme.sp::EquipItemByItemIndex
L 12/22/2021 - 12:28:10: [SM]   [7] Line 318, gimme.sp::Command_GiveItem
Here's the function I'm using:
PHP Code:
bool RemoveConflictWearables(int clientint newindex)
{
    
int wearable = -1;
    while ((
wearable FindEntityByClassname(wearable"tf_wearable*")) != -1)
    {
        if(
GetEntPropEnt(wearableProp_Send"m_hOwnerEntity") == client)
        {
            
int oldindex GetEntProp(wearableProp_Send"m_iItemDefinitionIndex");
            
//PrintToChatAll("Debug: Wearable: %i, Player: %N, Old Index: %i, New Index: %i, Mask Bit total: %i", wearable, client, oldindex, newindex, (TF2Econ_GetItemEquipRegionMask(oldindex) & TF2Econ_GetItemEquipRegionMask(newindex)));
            
if(TF2Econ_GetItemEquipRegionMask(oldindex) & TF2Econ_GetItemEquipRegionMask(newindex) > 0)
            {
                
//PrintToChatAll("Debug: Removed %N's item: %i", client, oldindex);
                
TF2_RemoveWearable (clientwearable);            
            }
        }
    }


Last edited by PC Gamer; 12-22-2021 at 17:25.
PC Gamer is offline
BeepIsla
Member
Join Date: Mar 2020
Location: Germany
Old 12-22-2021 , 17:03   Re: [TF2] Data Econ question
Reply With Quote #2

"65535" is an invalid item index, it does not exist. "65535" means the item has no definition index assigned to it. So just check if "oldindex" is "65535" and if so ignore it
BeepIsla is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-22-2021 , 17:22   Re: [TF2] Data Econ question
Reply With Quote #3

Quote:
Originally Posted by BeepIsla View Post
"65535" is an invalid item index, it does not exist. "65535" means the item has no definition index assigned to it. So just check if "oldindex" is "65535" and if so ignore it
Thanks for the response. Your answer would explain a lot. I'll try your solution.

edit: solution worked. Thanks BeepIsla!

Last edited by PC Gamer; 12-22-2021 at 17:24.
PC Gamer is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 12-23-2021 , 05:38   Re: [TF2] Data Econ question
Reply With Quote #4

The backpack used by the Medic is a non-economy "wearable" item. You're probably getting the item definition of one. Botkillers are also "extra" wearables if I remember correctly.

You can also test the item definition index using TF2Econ_IsValidItemDefinition, which should correctly return false if you're using version 0.16.6 or newer; prior versions returned true for any value.

(Item definition indices are represented in the schema as signed 2 byte values; 65535 (u16) is -1 (i16). However, Econ Data doesn't truncate or sign-extend values, and neither does the netprop. Both 65535 and -1 should return false.)
__________________
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; 12-23-2021 at 05:44.
nosoop is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-23-2021 , 15:48   Re: [TF2] Data Econ question
Reply With Quote #5

Thanks nosoop!

Here's what I ended up with. Works.
PHP Code:
bool RemoveConflictWearables(int clientint newindex)
{
    
int wearable = -1;
    while ((
wearable FindEntityByClassname(wearable"tf_wearable*")) != -1)
    {
        if(
GetEntPropEnt(wearableProp_Send"m_hOwnerEntity") == client)
        {
            
int oldindex GetEntProp(wearableProp_Send"m_iItemDefinitionIndex");
            
            if(
TF2Econ_IsValidItemDefinition(oldindex))
            {
                if(
TF2Econ_GetItemEquipRegionMask(oldindex) & TF2Econ_GetItemEquipRegionMask(newindex) > 0)
                {
                    
TF2_RemoveWearable (clientwearable);            
                }
            }
        }
    }

PC Gamer 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 02:43.


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