Jump to content
McKay Development

Recommended Posts

Posted

Here is my code: 

function sendWithdrawTrade(partner, assetid, callback) {

var itemsLength ='';

    connection.query(`SELECT COUNT(*) AS count FROM trade WHERE tradeurl = '${partner}' `, function(err, rows){
        var itemsLength = rows[0].count;
        console.log(rows[0].count + ' items');
        setValue(rows[0].count);
    });



        function setValue(value) {
              itemsLength = value;

        }


    const offer = manager.createOffer(partner);

    manager.getInventoryContents(730, 2, true, (err, inv) => {
      if (err) {
        console.log(err);
      } else {

        console.log(itemsLength + ' - items length');


        for (var i = 0; i < itemsLength; i++){ 


        	var parten = `${partner}`;
        	var items = "";
        	var loop = [i+1];
        	console.log(loop);

			connection.query("SELECT itemid FROM trade WHERE tradeurl = '" + partner + "' AND id = '" + loop + "' ", function(err, rows){
			    if (err) throw err; 

	            for (var i = 0; i < rows.length; i++) {
	                var result = rows[i];
	                var items = result.itemid;
	                setValue2(items);
	                console.log(items);
	            }
			});

			  function setValue2(value) {
			  items = value;
			  
			}

			//offer.addMyItem({"appid": 730,"contextid": 2,"assetid": items});
		}


			offer.send((err, status) => {
                        if (err) {
                            console.log(err);
                        } else {
                            console.log(`Sent offer. Status: ${status}.`);

                        }
           
        });


        
    };
  });

}

And thats what I get in console: 

(node:7284) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.               
2 items                                                                                                                  
Got API key: *myapikey*                                                                            
2 - items length                                                                                                         
[ 1 ]                                                                                                                    
[ 2 ]                                                                                                                    
Error: Cannot send an empty trade offer                                                                                  
    at TradeOffer.send (C:\OSPanel\domains\qw.qw\node_modules\steam-tradeoffer-manager\lib\classes\TradeOffer.js:282:23) 
    at manager.getInventoryContents (C:\OSPanel\domains\qw.qw\bot.js:179:10)                                             
    at SteamCommunity.<anonymous> (C:\OSPanel\domains\qw.qw\node_modules\steamcommunity\components\users.js:442:5)       
    at Request._callback (C:\OSPanel\domains\qw.qw\node_modules\steamcommunity\components\http.js:67:15)                 
    at Request.self.callback (C:\OSPanel\domains\qw.qw\node_modules\request\request.js:186:22)                           
    at emitTwo (events.js:126:13)                                                                                        
    at Request.emit (events.js:214:7)                                                                                    
    at Request.<anonymous> (C:\OSPanel\domains\qw.qw\node_modules\request\request.js:1163:10)                            
    at emitOne (events.js:116:13)                                                                                        
    at Request.emit (events.js:211:7)                                                                                    
13335825558                                                                                                              
13346525760                                                                                                              

I dont understand two things:

1) Why trade send before the "console.log(items);" ?

2) After for loop variable items is empty. How to get this variable from that loop?

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...