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
Qualities
PHP Code:
decl String:strQualityName[16];
TF2II_GetQualityName( 11, strQualityName, sizeof(strQualityName) );
// result: "strange"
new iQualityNum = TF2II_GetQualityByName( strQualityName );
// result: 11
Attributes
PHP Code:
new iAttributeIndex = TF2II_GetAttributeIDByName( "damage penalty" );
// result: 1
decl String:strAttributeName[32];
TF2II_GetAttributeNameByID( 2, strAttributeName, sizeof(strAttributeName) );
// result: "damage bonus"
Holiday restriction
PHP Code:
// Mildly Disturbing Halloween Mask
new iItemDefID = 115;
TF2II_ItemHolidayRestriction( iItemDefID, TFHoliday_Birthday );
// result: false
TF2II_ItemHolidayRestriction( iItemDefID, TFHoliday_Christmas );
// result: false
TF2II_ItemHolidayRestriction( iItemDefID, TFHoliday_Halloween );
// result: true
TF2II_ItemHolidayRestriction( iItemDefID, TFHoliday_FullMoon );
// result: true
TF2II_ItemHolidayRestriction( iItemDefID, TFHoliday_HalloweenOrFullMoon );
// result: true
Equip regions
PHP Code:
// Spine-Chilling Skull
new iItemDefID = 287;
decl String:strItemEquipRegion[16];
new Handle:hEquipReqions = TF2II_GetItemEquipRegions( iItemDefID );
GetArrayString( hItemEquipRegions, 0, strItemEquipRegion, sizeof( strItemEquipRegion ) );
PrintToServer( "Item %d - region 1 - '%s'", iItemDefID, strItemEquipRegion, strItemEquipRegion );
// result: Item 287 - reqgion 1 - 'hat'
GetArrayString( hItemEquipRegions, 1, strItemEquipRegion, sizeof( strItemEquipRegion ) );
PrintToServer( "Item %d - region 2 - '%s'", iItemDefID, strItemEquipRegion, strItemEquipRegion );
// result: Item 287 - reqgion 2 - 'face'
// also, conflicts
TF2II_IsConflictRegions( "arms", "face" );
// result: false
TF2II_IsConflictRegions( "whole_head", "face" );
// result: true
Getting items by conditions
PHP Code:
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