PonyExpress Posted March 27, 2019 Report Posted March 27, 2019 I have several questions that I have been looking for an answer for a long time.Some of my questions are more for a node js, sorry for that. And thanks in advance for your help! 1:If I need to decline/delete incoming offers that were not accepted in 10 minutes, would this be the right?Maybe there are any cases, why can it be a bad option? manager.on("newOffer", (OFFER) => { setTimeout(function() { OFFER.decline(); }, $MINUTE * 10); 2:I have to save completed trades. If not - sometimes some of them work 2-3 times. Why? // "pollInterval": "10000", // "dataDirectory": "./pool_data", // "savePollData": true var completedTrades = []; manager.on("sentOfferChanged", (OFFER) => { if (completedTrades.indexOf(OFFER.id) >= 0) { console.log("aborted"); return; } if (OFFER.state == 3) { completedTrades.push(OFFER.id); console.log("completed"); //Log: completed aborted aborted 3:In some trading offers I add data: trade.data("somedataname", myvar.toString()); After i check it this way (Is this correct or can it be different?): manager.on("sentOfferChanged", (OFFER) => { if (!!OFFER.data("somedataname")) { console.log("trade with somedataname"); 4:If I want to make a counter offer to a user (not on the list of friends) - will it work as I am create a new offer? manager.on("newOffer", (OFFER) => { let trade = OFFER.counter(); trade.getUserDetails((ERR, BotDetails, UserDetails) => { OFFER.itemsToGive = []; OFFER.itemsToReceive = []; //... add items trade.send((ERR) => { 5:How can I use more than 1 appid / txid? manager.getUserInventoryContents(SENDER, 753, 6, true, (ERR, USERINVENTORY) => { Here I will get only Steam (753-6);What should I do to add for example TF items (440-2) Quote
Dr. McKay Posted March 28, 2019 Report Posted March 28, 2019 That might work, but I wouldn't recommend using it as you'd be calling decline on offers that might have already been accepted. I would use offerList and check the creation time of the offers. I don't understand the question. sentOfferChanged is being emitted multiple times for the same offer with state 3? That looks correct. Actually, no. That's a bug. As a workaround you can use getUserDetails on the original offer that you're countering. Also, you should never reassign itemsToGive or itemsToReceive. Use the add(My/Their)Item(s) methods instead. You can't. You need to call it once per appid/contextid. PonyExpress 1 Quote
PonyExpress Posted March 28, 2019 Author Report Posted March 28, 2019 Thanks for the answer. I use:OFFER.itemsToGive = [];OFFER.itemsToReceive = [];To remove all items added by the sender. sentOfferChanged is being emitted multiple times for the same offer with state 3?Yes. Tomorrow I will check and provide more details when this happens. Quote
Dr. McKay Posted March 28, 2019 Report Posted March 28, 2019 You should not do that. Use removeMyItem and removeTheirItem instead. Quote
PonyExpress Posted December 6, 2019 Author Report Posted December 6, 2019 I still have a problem using getUserDetails Should I use getUserDetails before OFFER.counter ? Or maybe i can use for (let trade), which i create? Could you check and tell me the best option that I should use? Thanks! manager.on("newOffer", (OFFER) => { OFFER.itemsToGive = []; // removeTheirItems(OFFER.itemsToReceive); OFFER.itemsToReceive = []; // removeMyItems(OFFER.itemsToGive); //NOTE: Should I do this? // OFFER.getUserDetails((ERR, BotDetails, USERDETAILS) => { // if (ERR) return; // }); //NOTE: Or: // OFFER.getUserDetails((ERR, BotDetails, USERDETAILS) => { // if (!ERR && USERDETAILS.escrowDays <= 3) { // let trade = OFFER.counter(); // GoTrade(OFFER.partner, "trade", {tradedata: trade}); // } // }); GoTrade(OFFER.partner, null, {offerdata: OFFER}); }); client.on("friendMessage", (SENDER, MSG) => { if (MSG == "trade") { GoTrade(SENDER, MSG, {}); } if (MSG.indexOf("https://steamcommunity.com/tradeoffer/new/?partner=") >= 0) { GoTrade(null, null, {tradelink: MSG}); } }); function GoTrade(SENDER, MSG, OPTIONS) { // SID, MSG, { OFFER, trade or tradelink } let trade; if (OPTIONS.offerdata) { trade = OPTIONS.offerdata.counter(); } else if (OPTIONS.tradelink) { //TODO: } else if (OPTIONS.tradedata) { trade = JSON.stringify(tradedata); } else { trade = manager.createOffer(SENDER); } trade.getUserDetails((ERR, BotDetails, USERDETAILS) => { if (ERR) { //NOTE: Should I do this? // if (ERR && !OPTIONS.offerdata) { if (ERR.toString().indexOf("user_inventory_hidden") >= 0) { //... } else if (ERR.toString().indexOf("user_cant_trade") >= 0) { //... } else if (ERR.toString().indexOf("USER_NOT_FRIEND") >= 0) { //... } else { //... } } else if (USERDETAILS.escrowDays > 3) { //... } else { // manager.getUserInventoryContents( ... ) => { // trade.addMyItems( ... ); // trade.addTheirItems( ... ); // trade.setMessage( ... ); // trade.send((ERR) => { } }); }; Also, I don’t understand how it works counter(). How does Steam know if I can send counter or not? Can i send more than one counteroffer usung duplicate()? Quote
Dr. McKay Posted December 6, 2019 Report Posted December 6, 2019 getUserDetails cannot be called unless an offer is active, so you need to use it before you send a counter offer. Using the counter() method will return a new, unsent trade offer object which, when sent, will be sent as a counter offer. Each offer can only be countered once, so if you try to send two counter offers (either by calling counter() twice or by calling duplicate() on a counter offer), it won't work. In essence, the ID of a trade offer sent to you can be used in place of a trade offer access token (sort of, not literally) in order to send a trade offer, but only once. Once you send one counter offer, the original offer goes into "Countered" state and it can't be countered again. PonyExpress 1 Quote
PonyExpress Posted December 6, 2019 Author Report Posted December 6, 2019 (edited) Thanks. I stopped on this option: function GoTrade(SENDER, MSG, OPTIONS) { // SID, MSG, { OFFER, trade or tradelink } let trade; if (OPTIONS.offerdata) { // trade = OPTIONS.offerdata.counter(); // old trade = OPTIONS.offerdata; // NEW } else if (OPTIONS.tradelink) { //TODO: } else { trade = manager.createOffer(SENDER); } trade.getUserDetails((ERR, BotDetails, USERDETAILS) => { if (ERR) { // ... } else { if (OPTIONS.offerdata) { // NEW trade = OPTIONS.offerdata.counter(); } //... Edited December 6, 2019 by PonyExpress 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.