Announcement!
Since I have no free time, also due to lack of interest, I cannot support this plugin anymore. I hope someone would make a mem-hacking version.
* 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/includes/
/**
* @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 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 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 );
Changelogs:
Spoiler
Code:
14.11.13:
* Version: 1.8.17.6:
* Fixed AttribData array size thing. Stupid me.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
13.11.13:
* Version: 1.8.17.5:
* Added sm_tf2ii_fix01 convar to skip 'string' attributs that currently cannot be handled by TF2Items
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
29.07.13:
* Version: 1.8.17.4:
* Fixed throwing an error when item schema is not precached.
* Files updated:
* tf2itemsinfo.txt
* tf2itemsinfo.smx
* tf2itemsinfo.sp
15.07.13:
* Version: 1.8.17.3:
* Added extra info for sm_fi/pi command:
* Added optional second argument
* Added TF2II_PROP_PROPER_NAME flag
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
29.06.13:
* Version: 1.8.17.2:
* Fixed sm_fic/sm_sic printing items' class names instead of display names.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
15.06.13:
* Version: 1.8.17:
* Minor bug fixes.
* Version: 1.8.17.1:
* Minor bug fixes.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
14.06.13:
* Version: 1.8.16.4:
* Now attributes are stores to DB.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
14.06.13:
* Version: 1.8.16.3:
* Fixed TF2_FindItems is working too slow.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
12.06.13:
* Version: 1.8.16.1:
* Attempt to fix memory leaks.
* Version: 1.8.16.2:
* Attempt to fix memory leaks;
* Added ability to store item data to DB:
* Added sm_tf2ii_db console variable;
* Leave sm_tf2ii_db empty to disable this feature.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
25.05.13:
* Version: 1.8.16:
* Updated missing MarkAsOptional functions;
* Fixed ItemData_KeyValues isn't saving data from prefabs (FlaminSarge's fix).
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
07.12.12:
* Version: 1.8.15:
* Added TF2II_Get(Item/Attrib)KeyValues function.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
30.11.12:
* Version: 1.8.14:
* Added TF2II_GetItemAttributes function.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
29.10.12:
* Version: 1.8.13:
* Added TF2II_Get(Item/Attrib)Key(/Float/String) function.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
16.10.12:
* Version: 1.8.12:
* Minor bug fixes.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
11.10.12:
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.txt
* tf2itemsinfo.sp
* tf2itemsinfo.inc
08.10.12:
* Version: 1.8.11:
* Some backwards compatibility (again).
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
02.10.12:
* Version: 1.8.10:
* Some backwards compatibility.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
29.09.12:
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
28.09.12:
* Version: 1.8.9:
* Fixed bundles are parsed as melee;
* Fixed equipment region name cutting;
* Added TF2II_GetListedItemSlot and TF2II_GetListedItemSlotName;
* Added sm_tf2ii_updater console variable so you can disable autoupdate.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.txt
* tf2itemsinfo.sp
* tf2itemsinfo.inc
16.09.12:
* Version: 1.8.8:
* Fixed TF2II_FindItemsIDsByCond not working.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
12.09.12:
* Version: 1.8.7:
* Fixed data overwride order.
* Fixed pagination
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
12.09.12:
* Version: 1.8.6:
* Changed data overwride order;
* Fixed used_by_classes checker worked incorrect.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
11.09.12:
* Version: 1.8.5:
* Added alot of functions to work with attributes.
* Removed Herobrine
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
01.09.12:
* Version: 1.8.4:
* Fixed TF2II_FindItems searching by tool type incorrectly.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
30.08.12:
* Version: 1.8.3:
* Some functions are came back; Again;
* Some functions are marked as deprecated; Again;
* Fixed unused parameters are required for TF2II_GetItemQuality().
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
28.08.12:
* Version: 1.8.2:
* Some functions are came back;
* Some functions are marked as deprecated.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
27.08.12:
* Version: 1.8.1:
* sm_ii/sm_pi now says about holiday restrictions.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.txt
25.08.12:
* Version: 1.8.0:
* Added many defines;
* Marked TF2II_GetItemName as an optional;
* Removed many functions (such as TF2II_FindItemsIDsByCond);
* Added TF2II_FindItems;
* Added TF2II_ItemHasProperty;
* Renamed TF2II_ListAttachableEffects to TF2II_ListEffects;
* Renamed TF2II_OnSearchItems to TF2II_OnSearchCommand;
* Added TF2II_OnFindItems;
* Fixed pagination (total number of pages);
* Optimized memory usage (I hope so);
* No longer uses TF2Items extension;
* No longer uses TF2Items Randomizer gamedata.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
10.08.12:
* Version: 1.7.14:
* Added sm_pi command (same as sm_ii);
* Updated pagination so page numbers starts with 1 (instead of 0).
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
04.08.12:
* Version: 1.7.13:
* Added pagination for items/attributes search;
* Lowered items-per-page from 50 to 20;
* Lowered minimal characters limit from 4 to 2;
* The Flying Guillotine marked as medieval weapon;
* Added TF2WeaponSlot_Sapper in include file.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
* tf2itemsinfo.txt
03.08.12:
* Version: 1.7.12:
* Fixed sapper using wrong slot number.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.txt
15.07.12:
* Version: 1.7.11:
* sm_sa/sm_fi/sm_fic now uses string of arguments instead of just first word.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.txt
26.06.12:
* Version: 1.7.10:
* Added command sm_ii (print item data).
* Updated gamedata
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.txt
26.06.12:
* Version: 1.7.9:
* Removed commands: sm_tf2ii_search, sm_tf2ii_find, sm_searchitems, sm_finditems, sm_searchattrs, sm_findattrs;
* Added commands: sm_sic, sm_fic (find items by classname);
* Added TF2II_OnSearchItems forward.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
24.06.12:
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
18.06.12:
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
17.06.12:
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
12.06.12:
* Version: 1.7.8:
* Added TF2ItemQuality_ToborA;
* Added quality parser;
* Added TF2II_GetQualityName, TF2II_GetQualityByName.
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
06.06.12:
* Version: 1.7.7:
* Fixed wrong SDKCall name (EquipWearables instead of CTFPlayer::EquipWearables);
* Removed sm_tf2ii_search, sm_tf2ii_find, sm_tf2ii_s, sm_tf2ii_f commands;
* Added sm_searchattrs, sm_findattrs, sm_sa, sm_fa - search for attributes;
* Added sm_fi command (same as sm_si);
* Now you can find items by their ID (if you forgot item name);
* Updated enums (code only; no actual changes).
* Files updated:
* tf2itemsinfo.smx
* tf2itemsinfo.sp
* tf2itemsinfo.inc
1.7.6:
* Compatibility with future TF2Items Randomizer update.
1.7.5:
* Fixed MEMORY LEAK errors.
1.7.4:
* Added sm_tf2ii_search command so if you forgot item id, you can find it by name!
1.7.3:
* Updated bUsedByClasses array size/type in TF2II_FindItemsIDsByCond.
1.7.2:
* Added TF2II_ItemCanBeStrange native;
* Added TF2II_GetQualityColor stock;
* Updated data file.
1.7.1:
* Fixed handle passing in TF2II_GetItemEquipRegions.
1.7:
* Added TF2II_GetItemEquipRegions and TF2II_IsConflictRegions functions.
1.6.1:
* Renamed functions:
* TF2II_GetItemClassByID to TF2II_GetItemClass;
* TF2II_GetItemSlotByID to TF2II_GetItemSlot;
* TF2II_GetItemSlotNameByID to TF2II_GetItemSlotName;
* TF2II_GetItemQualityNameByID to TF2II_GetItemQualityName.
1.6:
* Added TF2II_ItemHolidayRestriction stock (checkin if item restricted by selected holiday);
* Updated data-file;
* Now supports GoD-Tony's Updater plugin.
1.5:
* Stocks is now a natives;
* Added data-file (contains extra data about items);
* Updated TF2II_GetNamedItem so it returns handle (also, removed second param);
* Updated TF2II_GiveNamedItem so it returns entity id;
* (26.04.12) hidden update:
* Renamed TF2II_GetItemToolType to TF2II_GetToolType;
* Added TF2II_OnItemSchemaUpdated forward (no params).
1.4:
* Changed TF2II_FindItemsIDsByCond so now it returns an array (also, removed first param);
* Fixed memory leaks (I hope so);
* Added some stocks;
* Added TF2II_ListAttachableEffects native.
1.3:
* Added TF2II_GetItemMinLevel, TF2II_GetItemMaxLevel, TF2II_GetItemQuality natives;
* Fixed giving Saxxy.
1.2:
* Added TF2II_GetNamedItem and TF2II_GiveNamedItem natives.
1.1:
* Added TF2II_FindItemsIDsByCond native.
1.0: (15.04.12)
* Initial release.
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
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
Will be implemented in Randomizer/GiveWeapon soon! Awesome job! Better than ItemsGame manager.
__________________
Bread EOTL GunMettle Invasion Jungle Inferno 64-bit will break everything. Don't even ask.
All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions. Steam is for playing games.
You will be fed to javalia otherwise. Psyduck likes replays.
Hello, I've been getting a problem with the Bot Weapon Randomizer Mod. I noticed someone in the thread (which you asked to discuss it here instead) had the same problem were in the bots had only stock weapons and my console was spammed with this message:
Code:
L 04/22/2012 - 20:42:38: [SM] Native "TF2Items_SetQuality" reported: Quality out
of bounds: 13 [-1 ... 11]
L 04/22/2012 - 20:42:38: [SM] Displaying call stack trace for plugin "tf2ibwr.sm
x":
L 04/22/2012 - 20:42:38: [SM] [0] Line 386, E:\_DedicatedServers\TF2\orangebo
x\tf\addons\sourcemod\scripting\tf2ibwr.sp::Timer_HookedEvent()
and once in awhile I'd get this:
Code:
L 04/22/2012 - 20:45:35: [SM] Native "TF2Items_SetQuality" reported: Quality out
of bounds: 13 [-1 ... 11]
L 04/22/2012 - 20:45:35: [SM] Displaying call stack trace for plugin "tf2ibwr.sm
x":
L 04/22/2012 - 20:45:35: [SM] [0] Line 386, E:\_DedicatedServers\TF2\orangebo
x\tf\addons\sourcemod\scripting\tf2ibwr.sp::Timer_HookedEvent()
material models/player/items/all_class/all_halo has a normal map and $basealphae
nvmapmask. Must use $normalmapalphaenvmapmask to get specular.
and these:
Code:
L 04/22/2012 - 20:41:26: [SM] Native "TF2Items_SetQuality" reported: Quality out
of bounds: 13 [-1 ... 11]
L 04/22/2012 - 20:41:26: [SM] Displaying call stack trace for plugin "tf2ibwr.sm
x":
L 04/22/2012 - 20:41:26: [SM] [0] Line 386, E:\_DedicatedServers\TF2\orangebo
x\tf\addons\sourcemod\scripting\tf2ibwr.sp::Timer_HookedEvent()
DataTable warning: env_sprite: Out-of-range value (1.000000) in SendPropFloat 'm
_vecNormal', clamping.
I tried typing sm plugins info tf2itemsinfo and got this:
Code:
sm plugins info tf2itemsinfo
Filename: tf2itemsinfo.smx
Title: [DEV] TF2 Items Info (Obtaining item info)
Author: Leonardo
Version: 1.5
URL: http://xpenia.org/
Status: running
Reloads: Map Change if Updated
Timestamp: 04/22/2012 23:55:43
Any help in solving this issue would be great. I think this is a wonderful plugin and would love to enjoy it to its fullest extent.
Now, if you print the values of each, you get:
AnEnum_FirstValue = 0
AnEnum_SecondValue = 1
AnEnum_ThirdValue = 2
AnEnum_FourthValue = 3
AnEnum_FifthValue = 4
This works with arrays because the name of the enum evaluates to the next number that would be assigned to an entry in it (AnEnum = 5),
so if you do
Code:
new AnArray[AnEnum];
you get an array with 5 members
In fact, this should work regardless because even sparse enums (with skipped values) will have a large enough array to store all values if you use the enum name. I actually just learned this today...
__________________
Not currently working on SourceMod plugin development.