Raised This Month: $51 Target: $400
 12% 

[TF2] Items Schema Cache/API


Post New Thread Reply   
 
Thread Tools Display Modes
Author
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Plugin ID:
3659
Plugin Version:
1.0.6
Plugin Category:
Technical/Development
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
    62 
    Plugin Description:
    Fetches the item schema from the Steam WEB API and provides natives to retrieve item information
    Old 05-22-2013 , 17:28   [TF2] Items Schema Cache/API
    Reply With Quote #1

    I can no longer support this plugin or the requests I get regarding it.

    Please use this isntead:
    https://forums.alliedmods.net/showth...t=tf2itemsinfo
    __________________
    Profile - Plugins
    Add me on steam if you are seeking sp/map/model commissions.

    Last edited by friagram; 03-09-2015 at 13:39. Reason: Doesn't work
    friagram is offline
    Leonardo
    Veteran Member
    Join Date: Feb 2010
    Location: 90's
    Old 05-23-2013 , 01:06   Re: [TF2] Items Schema Cache/API
    Reply With Quote #2

    Obtaining data from ItemSchema, but not local one? What's the point?
    __________________

    Last edited by Leonardo; 05-23-2013 at 01:06.
    Leonardo is offline
    friagram
    Veteran Member
    Join Date: Sep 2012
    Location: Silicon Valley
    Old 05-23-2013 , 02:12   Re: [TF2] Items Schema Cache/API
    Reply With Quote #3

    Quote:
    Originally Posted by Leonardo View Post
    Obtaining data from ItemSchema, but not local one? What's the point?
    The layout of items_game makes it hard to make some decisions (what is a hat, misc, etc). The web api provides a better organized version. items_game also tends to change it's layout in unpredictable ways as valve adds new classifications/sections to it. This does not. Anyways, there is different info/more info available here. I didn't use most of it. I just created some quick/general stuff that would suit some general/my own purposes.

    I could see someone using this info to say.. popup a HTML MOTD panel with item info/stats if they type the name for instance:
    PHP Code:
            "1507"
            
    {
                
    "name"    "The Electric Badge-aloo"
                "defindex"    "30000"
                "item_class"    "tf_wearable"
                "item_type_name"    "#TF_Wearable_Badge"
                "item_name"    "#TF_robo_all_bomb_badge"
                "item_description"    "#TF_robo_all_bomb_badge_Desc"
                "proper_name"    "1"
                "item_slot"    "misc"
                "model_player"    "models/workshop/player/items/all_class/robo_all_bomb_badge/robo_all_bomb_badge_scout.mdl"
                "item_quality"    "6"
                "image_inventory"    "backpack/workshop/player/items/all_class/robo_all_bomb_badge/robo_all_bomb_badge"
                "min_ilevel"    "1"
                "max_ilevel"    "100"
                "image_url"    "http://media.steampowered.com/apps/440/icons/robo_all_bomb_badge.07fad97737bda21abe7b7d748bb985e4692075f7.png"
                "image_url_large"    "http://media.steampowered.com/apps/440/icons/robo_all_bomb_badge_large.b5c502ebfd1de29a5f0fae5100976e3a145a6726.png"
                "drop_type"    "none"
                "craft_class"    ""
                "craft_material_type"    "hat"
                "capabilities"
                
    {
                    
    "nameable"    "1"
                    "can_craft_if_purchased"    "1"
                    "can_gift_wrap"    "1"
                    "can_craft_mark"    "1"
                    "can_be_restored"    "1"
                    "strange_parts"    "1"
                    "can_card_upgrade"    "1"
                    "can_strangify"    "1"
                
    }
            } 
    I suppose if you are worried about having out of date ItemSchema, the file date of items_game could be compared against, and then force an update so they are in synch.
    __________________
    Profile - Plugins
    Add me on steam if you are seeking sp/map/model commissions.

    Last edited by friagram; 05-23-2013 at 02:39.
    friagram is offline
    friagram
    Veteran Member
    Join Date: Sep 2012
    Location: Silicon Valley
    Old 05-23-2013 , 21:45   Re: [TF2] Items Schema Cache/API
    Reply With Quote #4

    I messed with this a bit more, it seems to work good. Anyways, I don't know if this will be of use to anyone, but I added attribute names/values:

    PHP Code:
    /**
     * Returns the actual number of attributes an item has, 0 on failure or no attributes.
     *
     * @param num1    An Item Definition Index
    **/
    native ItemsApi_GetNumAttributes(defindex);

    /**
     * Returns the value of the requested attribute, and writes its name to the buffer, 0.0 on failure.
     *
     * @param num1    An Item Definition Index
     * @param num2    An attribute id 0 +
     * @param num3    buffer to write item name of size MAX_ATTRIBUTE_NAME_LEN
    **/
    native Float:ItemsApi_GetAttribute(defindexattribidString:attribname[]);


    PrintToServer("35 testitem: %d"ItemsApi_GetNumAttributes(35));

    decl String:attribute0name[32];
    new 
    Float:attribute0val ItemsApi_GetAttribute(350attribute0name);
    PrintToServer("%s %f"attribute0nameattribute0val);

    35 testitem4

    medigun charge is crit boost 1.000



                    
    "0"
                    
    {
                        
    "name"    "medigun charge is crit boost"
                        "class"    "set_charge_type"
                        "value"    "1.000000"
                    
    }
                    
    "1"
                    
    {
                        
    "name"    "ubercharge rate bonus"
                        "class"    "mult_medigun_uberchargerate"
                        "value"    "1.250000"
                    
    }
                    
    "2"
                    
    {
                        
    "name"    "kill eater score type"
                        "class"    "kill_eater_score_type"
                        "value"    "2.000000"
                    
    }
                    
    "3"
                    
    {
                        
    "name"    "kill eater score type 2"
                        "class"    "kill_eater_score_type_2"
                        "value"    "1.000000"
                    

    The only thing is the attributes for each item are stored as a delimited string. I think it works ok, i'll post it in a bit. Bit tired, so i'll look it over more later.
    Attached Files
    File Type: sp Get Plugin or Get Source (itemsapi.sp - 410 views - 18.0 KB)
    File Type: inc itemsapi.inc (3.1 KB, 557 views)
    __________________
    Profile - Plugins
    Add me on steam if you are seeking sp/map/model commissions.

    Last edited by friagram; 05-23-2013 at 22:20.
    friagram is offline
    Leonardo
    Veteran Member
    Join Date: Feb 2010
    Location: 90's
    Old 05-24-2013 , 00:42   Re: [TF2] Items Schema Cache/API
    Reply With Quote #5

    I just want to make sure you know about TF2ItemsInfo plugin.
    Leonardo is offline
    friagram
    Veteran Member
    Join Date: Sep 2012
    Location: Silicon Valley
    Old 05-24-2013 , 02:09   Re: [TF2] Items Schema Cache/API
    Reply With Quote #6

    Quote:
    Originally Posted by Leonardo View Post
    I just want to make sure you know about TF2ItemsInfo plugin.
    I know about it, and used it for some projects in the past.
    I have also parsed items_game myself for a bunch of info.
    I still prefer this approach, because it gives me the type of info that would be useful for simple applications.

    If i want to say, add rate of fire to all weapons, I can just make a simple switch statement, and filter out all tf2 wearables using 1 return. I could also apply particle effects, entity rendermodes/colors/alpahs, etc, without having to worry about weird things like razorbacks, buff banners, demotarges, and other stuff getting the effects.

    You could always do workarounds, or make other functions to get what you need. Most of the same data is there, it's just a different way of getting at it
    __________________
    Profile - Plugins
    Add me on steam if you are seeking sp/map/model commissions.
    friagram is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 05-24-2013 , 14:30   Re: [TF2] Items Schema Cache/API
    Reply With Quote #7

    A few things of note:

    1. The UPGRADEABLE one aren't strictly Strange weapons... renamed weapons also get this item number.

    2. The ItemSchema's slot names are not necessarily the same across classes for weapon slots. For instance:

    Scout, Soldier, Pyro, DemoMan, Heavy, Medic, and Sniper have these slots:
    0 - primary
    1 - secondary
    2 - melee

    Engineer has:
    0 - primary
    1 - secondary
    2 - melee
    3 - pda
    4 - pda2 (always item 26)
    5 - building (always item 28)

    Spy has
    0 - secondary
    1 - building
    2 - melee
    3 - pda (always item 27)
    4 - pda2

    3. The slot may be in a prefab instead of in an item's definition
    __________________
    Not currently working on SourceMod plugin development.

    Last edited by Powerlord; 05-24-2013 at 14:32.
    Powerlord is offline
    friagram
    Veteran Member
    Join Date: Sep 2012
    Location: Silicon Valley
    Old 05-24-2013 , 18:15   Re: [TF2] Items Schema Cache/API
    Reply With Quote #8

    3. The slot may be in a prefab instead of in an item's definition

    Can you explain this? Dont think there are any prefabs here.

    And yeah, spies return revolver as secondary, and watch as pda2
    I didnt think it would be wise to reclassify these, but i could..
    Say make revolvers return as primary, but I think it's better to just handle this on a case-by case basis.

    Perhaps a flag to get true weapon slot.

    Also with the upgradable tag, ill probably just remove the word from those weapons when/if they get cleaned up.

    I noticed strange shotgun has showed up as primary, when it is secondary for most classes as well. I usually just check against them being an engineer when they receive it.

    edit: this should work then, added an option to recategorize weapons.. since that function already needed class types, like wearables, it can check tf_weapon_revolver (perhaps a tid bit hacky, but i don't see it changing anytime soon), and it will return it as a primary weapon instead of secondary. Also added ability to return item class, and toggle on/off the altered names.
    PHP Code:
    /**
     * Returns the item equip slot of an item, unknown on failure
     * Use this to filter out "tf_wearable" items which may be returned as weapons otherwise (items like the razorback or buff banner)
     *
     * @param num1    An Item Definition Index
     * @param num2    A TFiaSlotType to override the return slot index if it is a "tf_werable" but not a TFia_Slot_head or TFia_Slot_misc type (usually a weapon wearable)
     * @param num3    If true, will attempt to re-categorize weapons into logical slots (spy revolvers returned as TFia_Slot_primary instead of TFia_Slot_secondary)
    **/
    native TFiaSlotType:ItemsApi_GetSlotEx(defindexTFiaSlotType:weapon_wearable TFia_Slot_wearablebool:recategorize false);


    /**
     * Returns length of string written to buffer, 0 on failure.
     *
     * @param num1    An Item Definition Index
     * @param num2    buffer to write item name of size ITEM_NAME_LEN
     * @param num3    if true, default item names will be processed to make them more readable
    **/
    native ItemsApi_GetName(defindexString:name[], bool:rename false); 
    I could still add something to get he attribute #'s from a name. I'll do that later
    also looks like i forgot to mark another native as optional
    __________________
    Profile - Plugins
    Add me on steam if you are seeking sp/map/model commissions.

    Last edited by friagram; 05-24-2013 at 22:04.
    friagram is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 05-24-2013 , 22:54   Re: [TF2] Items Schema Cache/API
    Reply With Quote #9

    Quote:
    Originally Posted by friagram View Post
    Can you explain this? Dont think there are any prefabs here.
    They've... apparently removed prefabs from the schema since I last checked. It used to be TF_WEAPON_BAT and UPGRADEABLE_WEAPON_BAT both referred back to the "bat" prefab.

    Unless the prefabs are only in the client version of the schema...

    Quote:
    Originally Posted by friagram View Post
    I noticed strange shotgun has showed up as primary, when it is secondary for most classes as well. I usually just check against them being an engineer when they receive it.
    I'm not sure where you're looking, as the strange shotgun has this block in the schema:
    Code:
                    "per_class_loadout_slots": {
                        "Soldier": "secondary",
                        "Heavy": "secondary",
                        "Pyro": "secondary",
                        "Engineer": "primary"
                    }
    __________________
    Not currently working on SourceMod plugin development.
    Powerlord is offline
    friagram
    Veteran Member
    Join Date: Sep 2012
    Location: Silicon Valley
    Old 05-25-2013 , 11:17   Re: [TF2] Items Schema Cache/API
    Reply With Quote #10

    yeah it does, it's the only weapon that does that though, dunno how one would go about or bother with such a minor exception

    Edit: updated/attached a newer version in the zip file. Sorry if anyone is using/trying to use this. I've been a bit busy lately. If anyone is trying to use this/is having problems, feel free to send me a pm on here, or bug me on steam.
    __________________
    Profile - Plugins
    Add me on steam if you are seeking sp/map/model commissions.

    Last edited by friagram; 05-27-2013 at 15:51.
    friagram is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 12:14.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode