dawe Posted January 17 Report Posted January 17 sendDepositTrade(partner, assetIds, callback) { const offer = this.manager.createOffer(partner); this.manager.getUserInventoryContents(partner, 730, 2, true, (err, inv) => { if (err) { console.log('Error fetching user inventory:', err); callback(err, false); // Invoke the callback with the error } else { const itemsToAdd = inv.filter((item) => { const itemAssetId = String(item.assetid); return assetIds && assetIds.includes(itemAssetId); }); if (itemsToAdd.length > 0) { console.log('Items found in inventory matching assetIds:', itemsToAdd); itemsToAdd.forEach((item) => { offer.addTheirItem(item); console.log("Added item to trade offer:", item); }); offer.setMessage('test'); offer.send((err, status) => { if (err) { console.log("Error sending trade offer:", err); } else if (status === 'pending') { this.community.acceptConfirmationForObject('secret', offer.id, (err) => { if (err) { console.log("Error accepting confirmation:", err); } else { console.log("[INFO] TradeOffer confirmed with TradeOfferID: #" + offer.id); } }); } else if (status === "accepted") { console.log("[INFO] TradeOffer accepted"); } else { console.log("[INFO] TradeOffer #" + offer.id + " sent successfully"); } }); } } }); } } If not like this, then how? Please help. Quote
dawe Posted January 17 Author Report Posted January 17 Also, how do I guarantee that the trade has not been changed? Quote
Dr. McKay Posted January 18 Report Posted January 18 Listen for the sentOfferChanged event to see if an offer was accepted. Trade offers cannot be modified so you don't need to worry about checking if it was changed. Quote
dawe Posted January 18 Author Report Posted January 18 (edited) Thank you for the response! I'm still struggling. I can't get it working. When I cancel the trade from my non bot account the code doesn't run. EDIT: I've enabled polling (pollInterval: 30) but still the event never triggers. console.log(TradeOfferManager.ETradeOfferState[offer.state]); console.log(oldState) Here is a snippet of more code io.on('connection', (socket) => { const clientAddress = socket.handshake.headers['x-forwarded-for'] || socket.handshake.address; // Check if the client address is localhost or from a permitted IP range if (allowedAddresses.includes(clientAddress)) { // Connection allowed console.log('Client connected from localhost:', clientAddress); socket.on('startTradeDeposit', (data) => { const { assetIDs, steamID } = data; console.log('Received startTradeDeposit event with NameIDs:', assetIDs); bot.sendDepositTrade(steamID, assetIDs, (err, success, tradeOffer) => { // Log whether the callback is executed if (err && !success) { console.error('Error occurred while sending deposit trade:', err); socket.emit('failure', { message: 'We could not process your request at this time.' }); } else { console.log('Trade offer sent successfully!'); } }); bot.manager.on('sentOfferChanged', (offer, oldState) => { console.log(TradeOfferManager.ETradeOfferState[offer.state]); console.log(oldState) }); }); } }); Edited January 18 by dawe 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.