Since this plugin's been abandoned by Leonardo, and the fix is an easy line change, I'll try maintaining it for what I can
This is, obviously, a drop-in replacement to TF2ItemsInfo v1.8
Why the update?
Quote:
Valve recently changed location of the items_game file - however the original author is no longer maintaining the plugin, so I simply changed the code to reflect Valve's change
What is it?
Quote:
List of natives that could be useful for plugin devs.
* Download files from Links section (below)
* Put tf2itemsinfo.smx in /addons/sourcemod/plugins/
* Put tf2itemsinfo.txt in /addons/sourcemod/data/
* Put tf2itemsinfo.sp in /addons/sourcemod/scripting/
* Put tf2itemsinfo.inc in /addons/sourcemod/scripting/include/
/** * @brief Is items_game.txt file precached * * @noparam * * @return True if is it, false otherwise **/ native bool:TF2II_IsItemSchemaPrecached();
Getting item data
PHP Code:
/** * @brief Is item exists in items_game.txt * * @param iItemDefinitionIndex - * * @return True if it is, false otherwise **/ native bool:TF2II_IsValidItemID( iItemDefinitionIndex ); /** * @brief Get item name * * @param iItemDefinitionIndex - * @param strItemName String to store item name * @param iItemNameLength String length * * @return False is item doesn't exist, true otherwise **/ native TF2II_GetItemName( iItemDefinitionIndex, String:strItemName[], iItemNameLength ); /** * @brief Check if item has property(-ies) * * @param iItemDefinitionIndex - * @param iFlags Property flags * * @return False is item doesn't exist, true otherwise **/ native bool:TF2II_ItemHasProperty( iItemDefinitionIndex, iFlags ); /** * @brief Get item classname * * @param iItemDefinitionIndex - * @param strItemClass String to store item class * @param iItemClassLength String length * @param iPlayerClass Player class * * @return False is item doesn't exist, true otherwise **/ native TF2II_GetItemClass( iItemDefinitionIndex, String:strItemClass[], iItemClassLength, TFClassType:iPlayerClass = TFClass_Unknown ); /** * @brief Get item slot number * * @param iItemDefinitionIndex - * @param iPlayerClass Player class * * @return Item slot number **/ native TF2ItemSlot:TF2II_GetItemSlot( iItemDefinitionIndex, TFClassType:iPlayerClass = TFClass_Unknown ); /** * @brief Get item slot name * * @param iItemDefinitionIndex - * @param strItemSlot String to store item slot * @param iItemSlotLength String length * * @return False is item doesn't exist, true otherwise **/ native bool:TF2II_GetItemSlotName( iItemDefinitionIndex, String:strItemSlot[], iItemSlotLength ); /** * @brief Get item slot number (as in items_game.txt) * * @param iItemDefinitionIndex - * @param iPlayerClass Player class * * @return Item slot number **/ native TF2ItemSlot:TF2II_GetListedItemSlot( iItemDefinitionIndex, TFClassType:iPlayerClass = TFClass_Unknown ); /** * @brief Get item slot name (as in items_game.txt) * * @param iItemDefinitionIndex - * @param strItemSlot String to store item slot * @param iItemSlotLength String length * * @return False is item doesn't exist, true otherwise **/ native bool:TF2II_GetListedItemSlotName( iItemDefinitionIndex, String:strItemSlot[], iItemSlotLength ); /** * @brief Is item can be used by this class? * * @param iItemDefinitionIndex - * @param iClass - * * @return True if true, false otherwise. **/ native bool:TF2II_IsItemUsedByClass( iItemDefinitionIndex, TFClassType:iClass ); /** * @brief - * * @param iItemDefinitionIndex - * * @return Minimal item level **/ native _:TF2II_GetItemMinLevel( iItemDefinitionIndex ); /** * @brief - * * @param iItemDefinitionIndex - * * @return Maximal item level **/ native _:TF2II_GetItemMaxLevel( iItemDefinitionIndex ); /** * @brief Get item quality number * * @param iItemDefinitionIndex - * * @return Item quality number **/ native TF2ItemQuality:TF2II_GetItemQuality( iItemDefinitionIndex ); /** * @brief - * * @param iItemDefinitionIndex - * @param strQuality String to store item slot * @param iQualityLength String length * * @return False is item doesn't exist, true otherwise **/ native bool:TF2II_GetItemQualityName( iItemDefinitionIndex, String:strQuality[], iQualityLength ); /** * @brief Get number of attributes * * @param iItemDefinitionIndex - * * @return Number of attributes **/ native _:TF2II_GetItemNumAttributes( iItemDefinitionIndex ); /** * @brief - * * @param iItemDefinitionIndex - * @param iSlotAttribute The attribute slot index, ranges from 0 to 15 * * @return The attribute ID; -1 on failure **/ native _:TF2II_GetItemAttributeID( iItemDefinitionIndex, iSlotAttribute ); /** * @brief - * * @param iItemDefinitionIndex - * @param iSlotAttribute The attribute slot index, ranges from 0 to 15 * * @return Attribute value **/ native Float:TF2II_GetItemAttributeValue( iItemDefinitionIndex, iSlotAttribute ); /** * @brief - * * @param iItemDefinitionIndex - * * @return Array of attributes **/ native Handle:TF2II_GetItemAttributes( iItemDefinitionIndex ); /** * @brief Get tool type * * @param iItemDefinitionIndex - * @param strTool String to store data * @param iToolLength String length * * @return Attribute ID on success, -1 otherwise **/ native bool:TF2II_GetToolType( iItemDefinitionIndex, String:strTool[], iToolLength ); /** * @brief Is item restricted by selected holiday? * * @param iItemDefinitionIndex - * @param holiday - * * @return True or false **/ native bool:TF2II_ItemHolidayRestriction( iItemDefinitionIndex, TFHoliday:holiday ); /** * @brief Get item equip regions * * @param iItemDefinitionIndex - * * @return Array or INVALID_HANDLE (if no equip regions presented) **/ native Handle:TF2II_GetItemEquipRegions( iItemDefinitionIndex );
Getting attribute data
PHP Code:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /** * @brief Is attribute exists in items_game.txt * * @param iAttributeIndex - * * @return True if it is, false otherwise **/ native bool:TF2II_IsValidAttribID( iAttributeIndex ); /** * @brief Get attribute working name * * @param iAttributeIndex - * @param strAttributeName String to store name * @param iAttributeNameLength String length * * @return False is attribute doesn't exist, true otherwise **/ native bool:TF2II_GetAttribName( iAttributeIndex, String:strAttributeName[], iAttributeNameLength ); /** * @brief Get attribute class * * @param iAttributeIndex - * @param strAttributeClass String to store class * @param iAttributeClassLength String length * * @return False is attribute doesn't exist, true otherwise **/ native bool:TF2II_GetAttribClass( iAttributeIndex, String:strAttributeClass[], iAttributeClassLength ); /** * @brief Get attribute display name * * @param iAttributeIndex - * @param strAttributeName String to store name * @param iAttributeNameLength String length * * @return False is attribute doesn't exist, true otherwise **/ native bool:TF2II_GetAttribDispName( iAttributeIndex, String:strAttributeName[], iAttributeNameLength ); /** * @brief Get attribute MinValue * * @param iAttributeIndex - * * @return MinValue **/ native Float:TF2II_GetAttribMinValue( iAttributeIndex ); /** * @brief Get attribute MaxValue * * @param iAttributeIndex - * * @return MaxValue **/ native Float:TF2II_GetAttribMaxValue( iAttributeIndex ); /** * @brief Get attribute group * * @param iAttributeIndex - * @param strAttributeGroup String to store group * @param iAttributeGroupLength String length * * @return False is attribute doesn't exist, true otherwise **/ native bool:TF2II_GetAttribGroup( iAttributeIndex, String:strAttributeGroup[], iAttributeGroupLength ); /** * @brief Get attribute description string * * @param iAttributeIndex - * @param strAttribDescrString String to store string * @param iAttribDescrStringLength String length * * @return False is attribute doesn't exist, true otherwise **/ native bool:TF2II_GetAttribDescrString( iAttributeIndex, String:strAttribDescrString[], iAttribDescrStringLength ); /** * @brief Get attribute description string format * * @param iAttributeIndex - * @param strAttribDescrFormat String to store string format * @param iAttribDescrFormatLength String length * * @return False is attribute doesn't exist, true otherwise **/ native bool:TF2II_GetAttribDescrFormat( iAttributeIndex, String:strAttribDescrFormat[], iAttribDescrFormatLength ); /** * @brief Is it a hidden attribute * * @param iAttributeIndex - * * @return True/false **/ native bool:TF2II_HiddenAttrib( iAttributeIndex ); /** * @brief Get attribute effect type. 1 - positive, 0 - neutral, -1 - negative. * * @param iAttributeIndex - * * @return Number **/ native _:TF2II_GetAttribEffectType( iAttributeIndex ); /** * @brief Is attribute stored as integer * * @param iAttributeIndex - * * @return True/false **/ native bool:TF2II_AttribStoredAsInteger( iAttributeIndex ); /** * @brief Check if attribute has property(-ies) * * @param iAttributeIndex - * @param iFlags Property flags * * @return False is attribute doesn't exist, true otherwise **/ native bool:TF2II_AttribHasProperty( iAttributeIndex );
Additional functions
PHP Code:
/** * @brief Check equip regions for conflicts * * @param strEquipRegionA First equip region * @param strEquipRegionB Second equip region * * @return Attribute ID on success, -1 otherwise **/ native bool:TF2II_IsConflictRegions( const String:strEquipRegionA[], const String:strEquipRegionB[] ); /** * @brief Get quality number by name * * @param strQualityName Quality name * * @return Quality number on success, -1 otherwise **/ native TF2ItemQuality:TF2II_GetQualityByName( const String:strAttributeName[] ); /** * @brief Get quality name * * @param iQuality - * @param strQualityName String to store quality name * @param iQualityNameLength String length * * @return True on success, false otherwise **/ native bool:TF2II_GetQualityName( iAttributeID, String:strAttributeName[], iAttributeNameLength ); /** * @brief Get attribute ID by name * * @param strAttributeName Attribute name * * @return Attribute ID on success, -1 otherwise **/ native _:TF2II_GetAttributeIDByName( const String:strAttributeName[] ); /** * @brief Get attribute name by ID * * @param iAttributeID - * @param strAttributeName String to store attribute name * @param iAttributeNameLength String length * * @return True on success, false otherwise **/ native bool:TF2II_GetAttributeNameByID( iAttributeID, String:strAttributeName[], iAttributeNameLength );
Other stuff
PHP Code:
/** * @brief Check equip regions for conflicts * * @param strEquipRegionA First equip region * @param strEquipRegionB Second equip region * * @return Attribute ID on success, -1 otherwise **/ native bool:TF2II_IsConflictRegions( const String:strEquipRegionA[], const String:strEquipRegionB[] ); /** * @brief Get quality number by name * * @param strQualityName Quality name * * @return Quality number on success, -1 otherwise **/ native TF2ItemQuality:TF2II_GetQualityByName( const String:strAttributeName[] ); /** * @brief Get quality name * * @param iQuality - * @param strQualityName String to store quality name * @param iQualityNameLength String length * * @return True on success, false otherwise **/ native bool:TF2II_GetQualityName( iAttributeID, String:strAttributeName[], iAttributeNameLength ); /** * @brief Get attribute ID by name * * @param strAttributeName Attribute name * * @return Attribute ID on success, -1 otherwise **/ native _:TF2II_GetAttributeIDByName( const String:strAttributeName[] ); /** * @brief Get attribute name by ID * * @param iAttributeID - * @param strAttributeName String to store attribute name * @param iAttributeNameLength String length * * @return True on success, false otherwise **/ native bool:TF2II_GetAttributeNameByID( iAttributeID, String:strAttributeName[], iAttributeNameLength );
/** * @brief Note: all arguments are optional. Set them to detail your search query. * * @param strItemClass Item class name * @param strItemSlot Item slot name * @param iUsedByClasses Classes (bits) * @param strTool Tool type * * @return Array of item IDs **/ native Handle:TF2II_FindItems( const String:strItemClass[] = "", const String:strItemSlot[] = "", iUsedByClasses = TF2II_CLASS_NONE, const String:strTool[] = "" ); /** * @brief - * * @param bAllEffects Print valid or all effects? * * @return Array of results **/ native Handle:TF2II_ListEffects( bAllEffects = true );
Fowrards (events)
PHP Code:
/** * @brief Called when an item schema is parsed (or reloaded) **/ forward TF2II_OnItemSchemaUpdated(); /** * @brief Called when someone's trying to find items * * @param iClient Caller * @param strQuery Search query * @param hResults Array of results * @param bByClassname Is searching by classname? * * @noreturn **/ forward TF2II_OnSearchCommand( iClient, const String:strQuery[], &Handle:hResults, bool:bByClassname ); /** * @brief Called when some plugin's trying to find items * * @param strItemClass Item class name * @param strItemSlot Item slot name * @param iUsedByClasses Classes (bits) * @param strTool Tool type * @param hResults Array of results * * @noreturn **/ forward TF2II_OnFindItems( const String:strItemClass[], const String:strItemSlot[], iUsedByClasses, const String:strTool[], &Handle:hResults );
Stock functions
PHP Code:
/** * @brief Get quality color by quality number * * @param nQuality - * * @return Hex code **/ stock _:TF2II_GetQualityColor( TF2ItemQuality:nQuality = TF2ItemQuality_Normal ); /** * @brief Get slot number by name * * @param strSlot Slot name * @param iClass Player class * * @return Item slot number **/ stock TF2ItemSlot:TF2II_GetSlotByName( const String:strSlot[], TFClassType:iClass = TFClass_Unknown );
Getting item information
PHP Code:
// example: Baseball Bat new iItemDefID = 44; TF2II_IsValidItemID( iItemDefID ); // result: true (item exists in items_game.txt) decl String:strName[32]; TF2II_GetItemName( iItemDefID, strName, sizeof(strName) ); // result: "The Sandman" // note: name from items_game.txt and in-game name may be different decl String:strClassname[64]; TF2II_GetItemClass( iItemDefID, strClassname, sizeof(strClassname) ); // result: "tf_weapon_bat_wood" decl String:strSlot[16]; TF2II_GetItemSlotName( iItemDefID, strSlot, sizeof(strSlot) ); // result: "melee" TF2II_IsItemUsedByClass( iItemDefID, TFClass_Scout ); // result: true TF2II_IsItemUsedByClass( iItemDefID, TFClass_Spy ); // result: false // correct method to get item level new iMinLevel, iMaxLevel, iLevel; iMinLevel = TF2II_GetItemMinLevel( iItemDefID ); // result: 15 iMaxLevel = TF2II_GetItemMaxLevel( iItemDefID ); // result: 15 iLevel = GetRandomInt( iMinLevel, iMaxLevel ); // result: 15 decl String:strQuality[16]; TF2II_GetItemSlotName( iItemDefID, strQuality, sizeof(strQuality) ); // result: "unique" new iQuality = TF2II_GetQualityByName( strQuality ); // result: TF2ItemQuality_Unique (6) // getting attributes new iNumAttributes, iAIndexes[16], Float:flAValues[16]; iNumAttributes = TF2II_GetItemNumAttributes( iItemDefID ); if( iNumAttributes > 0 ) { for( new a = 0; a < ( iNumAttributes > 16 ? 16 : iNumAttributes ); a++ ) { iAIndexes[a] = TF2II_GetItemAttributeID( iItemDefID, a ); flAValues[a] = TF2II_GetItemAttributeValue( iItemDefID, a ); } } // result: // 38: 1.0 -- mod bat launches balls // 125: -15.0 -- max health additive penalty
new Handle:hArray = TF2II_FindItems(); // result: array with ALL items (even with keys, crates, and gifts) TF2II_FindItems( "tf_weapon_sword" ); // get items with 'tf_weapon_sword' classname only TF2II_FindItemsIDsByCond( _, "melee" ); // melee only new iUsedByClasses = TF2II_CLASS_NONE; // Used by nobody iUsedByClasses = TF2II_CLASS_ENGINEER; -- Used by engineer only iUsedByClasses = TF2II_CLASS_DEMOMAN | TF2II_CLASS_SOLDIER; -- Used by soldier and demoman only iUsedByClasses = TF2II_CLASS_ALL; -- Used by any class TF2II_FindItemsIDsByCond( _, _, iUsedByClasses ); // get items that can be used by selected classes TF2II_FindItems( _, _, _, "paint_can" ); // get paint cans only // you also can combine conditions TF2II_FindItemsIDsByCond( _, "melee", TF2II_CLASS_SOLDIER ); // get soldier's melee weapons only
There is a way to allow travis to build tf2itemsinfo with tf2items WITHOUT adding the include to the repo, FF2 does that with TF2Items for it's travis building. https://github.com/50DKP/FF2-Officia...travis.yml#L17
There is a way to allow travis to build tf2itemsinfo with tf2items WITHOUT adding the include to the repo, FF2 does that with TF2Items for it's travis building. https://github.com/50DKP/FF2-Officia...travis.yml#L17
That is completely crazy, don't do that. If you want a file from the TF2Items repo, clone it.