Coyeks Posted December 9, 2016 Report Posted December 9, 2016 Alright so the title says it all, i'm fairly new to Steam bots. I'm trying to make it so it only accepts CSGO keys i know the code below is horrible, but if someone could point me in the right direction it would help a lot. offers.on('newOffer', function (offer) { console.log("New offer #"+ offer.id +" from "+ offer.partner.getSteam3RenderedID()); // Accept any trade offer from Admin. if (offer.partner.getSteamID64() === config.admin && appid === appid.CSGO){ console.log("ADMIN offered a trade. Trying to accept offer."); offer.accept(function (err) { if (err) { console.log("Unable to accept offer "+ offer.id +": " + err.message); } else { console.log("Offer accepted because ADMIN sent the offer"); } }); } else { //Otherwise deny it and message the user console.log("User "+ offer.partner.getSteam3RenderedID() +" offered an invalid trade. Declining offer."); offer.decline(function (err) { if (err) { console.log("Unable to decline offer "+ offer.id +": " + err.message); } else { console.log("Offer declined"); // Message the user client.chatMessage(offer.partner.getSteamID64(), "Invalid offer."); } }); } }); I know it also only accepts if its the admin, that's just for testing. Quote
Dr. McKay Posted December 9, 2016 Report Posted December 9, 2016 Set a language in your constructor if you haven't already, and then the item should have a name property you can check. Quote
Coyeks Posted December 10, 2016 Author Report Posted December 10, 2016 Set a language in your constructor if you haven't already, and then the item should have a name property you can check. Hey, thanks fro the reply, i have a language set and could you possibly give an example of how to check the name in the code i provided above? thanks Quote
Dr. McKay Posted December 10, 2016 Report Posted December 10, 2016 offer.itemsToReceive contains an array of the items you'd receive if you accepted this offer. For each item in this array, check appid to make sure it's CS:GO and name to make sure it's a key. For example: var allItemsAreGood = offer.itemsToReceive.every(function(item) { return item.appid == 730 && item.name == "CS:GO Case Key"; }); Coyeks 1 Quote
Coyeks Posted December 10, 2016 Author Report Posted December 10, 2016 offer.itemsToReceive contains an array of the items you'd receive if you accepted this offer. For each item in this array, check appid to make sure it's CS:GO and name to make sure it's a key. For example: var allItemsAreGood = offer.itemsToReceive.every(function(item) { return item.appid == 730 && item.name == "CS:GO Case Key"; }); Thank you, appreciate it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.