View Single Post
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-15-2012 , 06:12   Re: [DEV] TF2 Item Info v1.2 (15.04.12)
Reply With Quote #2

Getting item information
PHP Code:
// example: Baseball Bat
new iItemDefID 44;

TF2II_IsValidItemIDiItemDefID );
// result: true (item exists in items_game.txt)

decl String:strName[32];
TF2II_GetItemNameiItemDefIDstrNamesizeof(strName) );
// result: "The Sandman"
// note: name from items_game.txt and in-game name may be different

decl String:strClassname[64];
TF2II_GetItemClassiItemDefIDstrClassnamesizeof(strClassname) );
// result: "tf_weapon_bat_wood"

decl String:strSlot[16];
TF2II_GetItemSlotNameiItemDefIDstrSlotsizeof(strSlot) );
// result: "melee"

TF2II_IsItemUsedByClassiItemDefIDTFClass_Scout );
// result: true
TF2II_IsItemUsedByClassiItemDefIDTFClass_Spy );
// result: false

// correct method to get item level
new iMinLeveliMaxLeveliLevel;
iMinLevel TF2II_GetItemMinLeveliItemDefID );
// result: 15
iMaxLevel TF2II_GetItemMaxLeveliItemDefID );
// result: 15
iLevel GetRandomIntiMinLeveliMaxLevel );
// result: 15

decl String:strQuality[16];
TF2II_GetItemSlotNameiItemDefIDstrQualitysizeof(strQuality) );
// result: "unique"
new iQuality TF2II_GetQualityByNamestrQuality );
// result: TF2ItemQuality_Unique (6)

// getting attributes
new iNumAttributesiAIndexes[16], Float:flAValues[16];
iNumAttributes TF2II_GetItemNumAttributesiItemDefID );
if( 
iNumAttributes )
{
    for( new 
0< ( iNumAttributes 16 16 iNumAttributes ); a++ )
    {
        
iAIndexes[a] = TF2II_GetItemAttributeIDiItemDefID);
        
flAValues[a] = TF2II_GetItemAttributeValueiItemDefID);
    }
}
// result:
// 38: 1.0 -- mod bat launches balls
// 125: -15.0 -- max health additive penalty 
Qualities
PHP Code:
decl String:strQualityName[16];
TF2II_GetQualityName11strQualityNamesizeof(strQualityName) );
// result: "strange"

new iQualityNum TF2II_GetQualityByNamestrQualityName );
// result: 11 
Attributes
PHP Code:
new iAttributeIndex TF2II_GetAttributeIDByName"damage penalty" );
// result: 1

decl String:strAttributeName[32];
TF2II_GetAttributeNameByID2strAttributeNamesizeof(strAttributeName) );
// result: "damage bonus" 
Holiday restriction
PHP Code:
// Mildly Disturbing Halloween Mask
new iItemDefID 115;

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_Birthday );
// result: false

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_Christmas );
// result: false

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_Halloween );
// result: true

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_FullMoon );
// result: true

TF2II_ItemHolidayRestrictioniItemDefIDTFHoliday_HalloweenOrFullMoon );
// result: true 
Equip regions
PHP Code:
// Spine-Chilling Skull
new iItemDefID 287;

decl String:strItemEquipRegion[16];
new 
Handle:hEquipReqions TF2II_GetItemEquipRegionsiItemDefID );

GetArrayStringhItemEquipRegions0strItemEquipRegionsizeofstrItemEquipRegion ) );
PrintToServer"Item %d - region 1 - '%s'"iItemDefIDstrItemEquipRegionstrItemEquipRegion );
// result: Item 287 - reqgion 1 - 'hat'

GetArrayStringhItemEquipRegions1strItemEquipRegionsizeofstrItemEquipRegion ) );
PrintToServer"Item %d - region 2 - '%s'"iItemDefIDstrItemEquipRegionstrItemEquipRegion );
// 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 

Last edited by Leonardo; 11-08-2012 at 12:33. Reason: typo fix
Leonardo is offline