Jessecar96 / SteamBot

Automated bot software for interacting with Steam Trade
http://scrap.tf
MIT License
1.34k stars 910 forks source link

Item selling and buying #253

Closed ResidentEvil91 closed 11 years ago

ResidentEvil91 commented 11 years ago

Hello all!

I have no experience in C# or C++ but i can still understand some of it. I don't know how to add custom code, but when i know how it works, i can copy and edit it :)

I am trying to figure out: How to make bot accept specific items (Ex: Haunted Rump-O'-Lantern for 1,33ref) How to make bot sell specific items (Ex: Strange Tomislav for 0,33ref) Also interact bot with chat like i have seen done, tell bot: Add "item", bot adds item and says how much it is worth.

I think easiest way would be make Sell&buy file where you could but item information and prices.

Can someone help me or push me atleast to right direction?

/offtopic I have intended to programmer engineer school as i am very interested into programming and will know at July if i get in :)

ResidentEvil91 commented 11 years ago

https://github.com/Jessecar96/SteamBotExamples/blob/master/examples/ScrapUserHandler.cs Should i try this? It seems very clear to read.

Also what code to make bot remove resent user when user says bye/thanks/ty/remove?

And where do i find what ID number item uses? IF for ex. scrap = 5000

SuperMari0s commented 11 years ago

Hello and welcome.

To check specific items you need to know their defindex. Here you can find the defindex of the items.

Now for example if you want to do something with Haunted Rump-O'-Lantern you must have something like:

                if (item.Defindex == 869 && item.Quality == "Haunted") 
                {
                    do something
                }

Note: i didn't try the code that's just what i'm thinking. Never worked with quality.

To interact with bot check the adminhandler to get some ideas and see how the commands work. you can just copy and modify from there :)

ResidentEvil91 commented 11 years ago

I set "BotControlClass": "SteamBot.AdminUserHandler", And bot only says it have add command and remove command did not work.

SuperMari0s commented 11 years ago

Add/remove works like:

add 5021 5 the bot will give you 5 keys. add metal the bot will give you all metal

you can add/remove anything if you know the defindex. or you can specify your own type like the metal.

Chener commented 11 years ago

@ResidentEvil91 did u encounter the problem that whenever u typed add cmd, the trade window will become loading and then closed?

ResidentEvil91 commented 11 years ago

@hohisonfire No, but bot refuses to trade again after canceling trade and one time i said hi to the bot at the same time opening trade, it crashed the bot :P

Chener commented 11 years ago

@ResidentEvil91 damn, why I am the only one who encounters the "loading" issue. Btw, as for your purpose, it's nothing but digging hard into the code

ResidentEvil91 commented 11 years ago

@hohisonfire Yes :) I have got very much useful info here ^^

waylaidwanderer commented 11 years ago

To check quality, you'll need to check the quality of the item the user offers, not the schema item.

In OnTradeAddItem() the variable is inventoryItem, and you can get the quality by doing inventoryItem.ItemQuality, I believe. It is returned as a string number,

A unique item will have a quality of 6, so check if inventoryItem.ItemQuality == "6", for example. You can find a list of quality indexes if you use Google.

pearhk commented 11 years ago

Just wondering, if there's any way to distinguish crates by their series number?

It's weird they all share the same defindex "5041", "5045" or "5022"

waylaidwanderer commented 11 years ago

@pearhk Yep. Here's the code snippet for doing that.

var currentItem = Trade.CurrentSchema.GetItem(item.Defindex);
if (currentItem.CraftMaterialType == "supply_crate")
{
    int crateNum = 0;
    for (int count = 0; count < item.Attributes.Length; count++)
    {
        crateNum = item.Attributes[count].FloatValue;
        // FloatValue will give you the crate's series number
    }
    Console.WriteLine("The crate's series number is #" + crateNum);
}

item is a variable of type Inventory.Item. In OnUserAddItem it would be called inventoryItem.Defindex for example.

Note that this doesn't attempt to match defindexes, but rather it checks the CraftMaterialType of the item, since all crates will share the same property of supply_crate.

pearhk commented 11 years ago

@waylaidwanderer

Did not realize steam store the crate series number inside "attributes"

Thanks for the notes :)

P.S. Just found out that "float_value" is always 0 for all the crates, the one that makes difference is from "value", which is exactly the same as the series number

waylaidwanderer commented 11 years ago

Ah, you're right. Sorry, I wrote the snippet off the top of my head and got them confused.

ghost commented 11 years ago

I found that crateNum = inventoryItem.Attributes[count].FloatValue; gave the correct series number and Value gave a really high number

pearhk commented 11 years ago

Weird for me, i can only get 3 values from crate attribute property

name:set supply crate series class:supply_crate_series value:57

Did i do fetching data from the wrong source?

pearhk commented 11 years ago

Turns out that i fetch the data from the wrong place, i am getting the list from item schema instead of the actual inventory list, which yields me the crate number of the current crate drop list :|

So yeah, waylaidwanderer & X33RO are right! The float_value is the right place to look at, Thanks again!

ghost commented 11 years ago

Anyone else notice that the add command seriously mucks up if you use it several times? try loading it with crates then going "add crates 3" wait for it to add "add crates 3" wait for it to add "add crates 3" and on the third one it adds 4 crates?

SuperMari0s commented 11 years ago

@X33RO i modified and used the code in AdminHandler without problems... I've seen the bot adding 30 items or so without glitching . I just tried to replicate what you said added 24 crates 3 by 3 and added them correctly.

ghost commented 11 years ago

hmm is this something to do with the amount of crates in storage then maybe? I have 12. How many did you try it with?

SuperMari0s commented 11 years ago

I'm not sure over 20 i think

ghost commented 11 years ago

Ok, ill try this with more crates later. Bloody internet keeps cutting out :P

waylaidwanderer commented 11 years ago

Can this issue be closed now? Seems resolved.

DogoCaraballo commented 10 years ago

can someone put an example of this? Like if your trading partner puts a key, the bot gives him 2 ref. And if the partner puts 2.33 ref, the bots gives him a key?

scholtzm commented 10 years ago

Read #427 & #527.

Soni96pl commented 10 years ago

If you want to make fast profit with this bot without any knowledge it's not a way to go. In world you get money for skills (writing bot's handler) and/or hard work (selling keys yourself). So if you don't know how to do it either learn C# or choose the hard work's way.

kobe12 commented 10 years ago

how would you find a steam gift id

scholtzm commented 10 years ago

427, #527