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

[CS:GO] item_found event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kinsi
Senior Member
Join Date: Apr 2013
Old 12-20-2014 , 11:37   [CS:GO] item_found event
Reply With Quote #1

Just thought about a project i'd like to do and found out item_found is on the event list of CS:GO(https://wiki.alliedmods.net/Counter-...nts#item_found). So i wrote a very simple plugin to just test the function and it doesnt seem to do anything

Code:
public OnPluginStart()
{
    HookEvent("item_found", Event_ItemFound);
}

public Event_ItemFound(Handle:event, const String:name[], bool:dontBroadcast) {
    new client = GetEventInt(event, "player");
    new quality = GetEventInt(event, "quality");
    new method = GetEventInt(event, "method");
    new defindex = GetEventInt(event, "itemdef");
    
    PrintToChatAll("%N %i %i %i", client, quality, method, defindex);
}
Am i doing something wrong here or is it just not implemented for CS:GO? If its not, is there any alternative route i could go?

Thanks a lot!
Kinsi is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 12-20-2014 , 13:39   Re: [CS:GO] item_found event
Reply With Quote #2

Just dug around in the usermessages and tried hooking every event available, and apparently theres the usermessage "SendPlayerItemFound", aka 63. I dont know anything more yet, just giving info if anyone should be in the same boat as me
Kinsi is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 12-29-2014 , 22:53   Re: [CS:GO] item_found event
Reply With Quote #3

Im back, reporting in for the people in search of a solution i was missing.

The usermessage 63 refers to trades, 61 refers to case openings.

When in the usermessage, the protobuf looks like this
https://github.com/alliedmodders/hl2...ges.proto#L341

entindex is thie clientid, you need to read the iteminfo protbuf though
https://github.com/alliedmodders/hl2...ges.proto#L307

which then contains all infos you need. If you want to get the basic informations its as follows

"quality" refers to stattrak or not. 4 means normal, 9 means stattrak

"defindex" is the index you can read from the kv file "scripts/items/items_game.txt" when navigating into "items"

"paintindex" refers to the index you can read from the same kv file when navigating into "paint_kits", which contains the tag of the camo name, which you then again can find in the language file.

Now comes the tricky part, if you want to get the wear of the skin from the usermessage, you need to check the field "paintwear". This is a integer which, probably, reaches from 1000000000 to 2000000000. I traded a lot of skins back and forth with friends and estimated the boundaries as follows:

Code:
    new String:wearString[64];
    if(camowear<1035000001){
        wearString = "Factory New";
    }else if(camowear<1042000001){
        wearString = "Minimal Wear";
    }else if(camowear<1052900001){
        wearString = "Field-Tested";
    }else if(camowear<1055000001){
        wearString = "Well-Worn";
    }else{
        wearString = "Battle-Scarred";
    }
The pool of data i used for estimation: http://i.imgur.com/WmnJsNC.png

I hope i never have to do such stuff ever again. All of this because good old gabe never actually finishes his shit.

Also, if you want "Pretty" weapon names, which you also need when trying to request the market price of an item, here's the edited list which you can use instead of the items_game kv file

Code:
public String:Weapons[64][64] = {"PH",    "Desert Eagle", "Dual Berettas", "Five-SeveN", "Glock-18",         "",
                                                    "",                 "AK-47",            "AUG",           "AWP",             "Famas",
                                                    "G3SG1",            "",                    "Galil AR",      "M249",            "",
                                                    "M4A4",             "MAC-10",           "",              "P90",               "",
                                                    "",                 "",                    "",              "UMP-45",            "XM1014",
                                                    "PP-Bizon",         "MAG-7",              "Negev",            "Sawed-Off",        "Tec-9",
                                                    "Taser",             "P2000",            "MP7",          "MP9",                "Nova",
                                                    "P250",             "",                    "SCAR-20",      "SG556",            "SSG 08",
                                                    "",                 "Knife",            "Flashbang",  "HE-Grenade",    "Smoke-Grenade",
                                                    "Molotov",         "Decoy",            "Incindiary", "C4",                "",
                                                    "",                 "",                    "",              "",                    "",
                                                    "",                 "",                    "",              "",                    "M4A1-S",
                                                    "USP-S",             "",                    "CZ75-Auto"};
Edit1:

About the pretty weapon names, it goes further, forgot the knives.

Code:
if(defindex == 500) {
    weaponName = "★ Bayonet";
}else if(defindex == 505) {
    weaponName = "★ Flip Knife";
}else if(defindex == 506) {
    weaponName = "★ Gut Knife";
}else if(defindex == 507) {
    weaponName = "★ Karambit";
}else if(defindex == 508) {
    weaponName = "★ M9 Bayonet";
}else if(defindex == 509) {
    weaponName = "★ Huntsman Knife";
}else if(defindex == 515) {
    weaponName = "★ Butterfly Knife";
}else{
    weaponName = Weapons[defindex];
}
Edit2:
Found out that quality 4,9, and 12 exist, 12 refers to souvenir

Last edited by Kinsi; 01-08-2015 at 19:47.
Kinsi is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-29-2014 , 23:56   Re: [CS:GO] item_found event
Reply With Quote #4

Very nice!
__________________
Neuro Toxin is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 12-30-2014 , 00:10   Re: [CS:GO] item_found event
Reply With Quote #5

Nice.
Darkness_ 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 04:16.


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