[TF2] TF2 Item DB (replaces tf2itemsinfo)
5 Attachment(s)
Want to help test out a new beta version of the plugin with more features? Click Here and please let us know if it works!
This is a library that will allow you to query items or search for them with a specified criteria. For example you can check which slot an item uses or get all items in the melee slot for snipers. This plugin is meant to replace tf2itemsinfo which has memory leaks and other problems that cannot be fixed and will eventually become permanently broken due to how long it takes to run and that it uses almost the maximum number of handles. Data is stored in sqlite. A python script is used to update the database. I decided to do it this way because it is a bad idea to put a 10+ second loading time into your server especially when there is time limit for plugins now and is much faster in python. It is recommended to run this after every update. If you do not have python on your server, you can always run it on your computer and upload it to your server. We need people to start porting plugins to use tf2idb. I have tried to make the functions close to tf2itemsinfo but unfortunately I could not make them all the same because they were too inefficient, especially for SQLite. With the TF2IDB_FindItemCustom function, you can create arbitrary SQL queries which should be much faster and much more flexible than the finditem function in tf2itemsinfo. How to Install - Lazy Method You can use the pre-made database here but it is not recommended because I will not be updating it. You should follow the additional instructions below so you can make the database yourself after each update.
How to Install - Additional steps to updating your own database
You need to first edit tf2idb.py and point it to your TF2 server folder. It will look like this. Code:
TF_FOLDER = r'C:/tf2server/tf/' Then run tf2idb.py to create the database. If you need to update the database, run tf2idb.py again. Code:
// If a native returns bool and it is not obvious from the name what it is, then the bool represents whether the native succeeded. Code:
// If you are creating items, you will want to filter out items with string attributes like this. Code:
('CREATE TABLE "tf2idb_class" ("id" INTEGER NOT NULL , "class" TEXT NOT NULL , PRIMARY KEY ("id", "class"))') 10/21/2017 - Updated tf2idb.py to handle blank item_types. 3/1/2016 - Updated tf2idb.sp and tf2idb.smx - fixed GetItemEquipRegions. Thank you Dagothur. 12/18/2015 - Updated tf2idb.py to handle the typo in today's schema change. Now all attributes are stored in lowercase. 11/12/2015 - Updated tf2idb.py for python 3.5 and added item_name column. Thanks to fakuivan. 10/07/2015 - Updated tf2idb.py to support new schema changes, and not to change the database if parsing failed. Added the table "tf2idb_capabilities" with the columns ("id" INTEGER NOT NULL , "capability" TEXT NOT NULL ) |
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
No more crashes and memory leaks like in tf2itemsinfo?Good.
|
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
PHP Code:
|
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
Quote:
|
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
Glad to see someone finally redid TF2ItemsInfo using SQLite.
I vaguely remember suggesting this a while ago, but I was too Edit: On a side note, shouldn't MAX_ATTRIBUTES currently be 15? m_AttributeList has items 000 through 014 according to a netprops dump. As far as I'm aware, CUtlVector netprop tables have the names of their children listed correctly even if their offsets are fake1. 1You're going to have to trust me on this one, I've done experiments on it. The items in a CUtlVector netprops are just a wrapper around an object2 that stores the position in the CUtlVector that can be used to retrieve its values. I have no idea how this works with items that themselves contain datatables. 2CSendPropExtra_UtlVector specifically. |
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
I don't mind changing it to 15, I just copied the number straight from tf2itemsinfo. I also don't know if I did the equip regions correctly.
|
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
A lot of places still have Python2 installed. For instance, most Linux distributions use it.
On a totally unrelated note, turns out that CUtlVector netprops don't store pointers after all. So... maybe it is possible to get the offsets to the actual values from a CUtlVector netprop... time to take another crack at my cutlvector-netprops branch of SourceMod. |
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
I did not write the vdf.py library which has Python2 print statements. The code I wrote, tf2idb.py is fully Python3 compatible.
And yes I realize that calling SQLite for each function call can be slow, but this is the way it should be. - I did a huge amount of ground work up to this point already. I do not want to spend any more time than I have to with premature optimizations. - To prevent the explosion of handle usage that has doomed tf2itemsinfo to become completely unfixable. - Small files are cached in RAM in every modern OS so even if SQLite functions uses disk functions, it will not cause IO. I may add a cache for very frequently used natives such as IsValidID. But for everything I will leave it up to someone else here to implement, provided it does not use too many handles. Bailopan has already stated he is not interested in continually increasing the handles limit. The handle limit will never be able to go above 32k because it needs to fit in 32bits and 16 of those are used to save the handle type. |
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
Quote:
The handle system is not going anyway any time soon. As Bailopan said, it is a "long bet", and it'll probably be years before a GC is put into sourcepawn. Massive handle usage is not the only issue it has. It also has memory leaks, and it is already taking so long to load that it gets killed by the new sourcemod watchdog timer. Also if you have already done the work of cleaning up vdf.py, then why don't you post it? |
Re: [TF2] TF2 Item DB (replaces tf2itemsinfo)
How will this interact with other plugins that utilize tf2itemsinfo for a dependency?
Will the removal of tf2itemsinfo and addition of this be seamless? |
All times are GMT -4. The time now is 06:03. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.