Jump to content
McKay Development

How to get the traded items ?


Recommended Posts

This is my code, how can know what will i be traded ? i want it to log it in the console

manager.on('newOffer', (offer) =>{
	console.log(magenta + ('Received 1 new offer') + white);
	console.log(magenta + offer.partner.toString() + white + ' offered their ' + magenta + offer.itemsToReceive + white + ' for our ' + magenta + offer.itemsToGive + white)
});

with this code im receiving this in console

 

 

Received 1 new offer

76561198330320024 offered their [object Object] for our [object Object]

 

Link to comment
Share on other sites

ok i've got it to write down whats offered in console. This is the current code...

manager.on('newOffer', (offer) =>{
	console.log(trade + 'Received 1 new offer : #' + offer.id);
	console.log(trade + magenta + offer.partner.toString() + white + ' offered their ' + magenta + offer.itemsToReceive + white + ' for our ' + magenta + offer.itemsToGive + white);
		if(offer.itemsToGive == 0){
			console.log(trade + 'Offer #' + offer.id + ' is a gift offer, accepting');
			offer.accept(function (err){
				if(err){
					console.log(err)
				}
			})
		}else{
			console.log(trade + 'Our Items')
			console.log(offer.itemsToGive)
			
			console.log(trade + 'Their Items')
			console.log(offer.itemsToReceive)
			
			if(offer.itemsToReceive == 'Scrap Metal'){
				console.log('Scrap metal found on partner\s offer !')
			}
		}
	});

I wanna make it check if the appid/market_hash_name is match something i want sell. how to i do it ? i tried... and it dont seem to work. Again i know i suck :c

if(offer.itemsToReceive.appid == '440'){
  console.log(trade + 'It\'s a TF2 trade!'
)}
Link to comment
Share on other sites

    offer.itemsToReceive.forEach(function(item) {
        if (item.appid == "440" &&  item.market_hash_name == "Scrap Metal") {
            console.log("It's a bird! It's a plane! IT'S A SCRAP METAL!");
        }
     }
    );

Something I made you real quick. 

You can do it the same way for itemsToGive

 

You can also get some of this info out of it:

https://github.com/DoctorMcKay/node-steamcommunity/wiki/CEconItem

Link to comment
Share on other sites

In

 

    offer.itemsToReceive.forEach(function(item) {
        if (item.appid == "440" &&  item.market_hash_name == "Scrap Metal") {
            console.log("It's a bird! It's a plane! IT'S A SCRAP METAL!");
        }
     }
    );

Something I made you real quick. 

You can do it the same way for itemsToGive

 

You can also get some of this info out of it:

https://github.com/DoctorMcKay/node-steamcommunity/wiki/CEconItem

Wow thanks man :D

Link to comment
Share on other sites

manager.on('newOffer', (offer) =>{
		function getpitems(){
			offer.itemsToReceive.forEach(function(item) {
				if (item.appid == "440") {
				console.log(Status + 'All items are TF2 items');
				}else{
					console.log(Status + '1 or more of our items isn\'t TF2 items!')
				};
			})
		}
		 function getoitems(){
			 offer.itemsToGive.forEach(function(item){
				if(item.appid == "440"){
				console.log(Status + 'All items are TF2 items')
			}else{
				console.log(Status + '1 or more of our items isn\'t TF2 items!')
			}
			 })
		 }
		 
		 getpitems();
		 getoitems();
		 
		 if(getpitems.item.appid && getoitems.item.appid == '440'){
			 offer.accept((err) =>{
				 if(err){
					 console.log(err)
				 }
			 })
		 }else{
			 offer.decline((err) =>{
				 if(err){
					 console.log(err)
				 }
			 })
		 }
})

ive make them into functions so i dont mess them up

if(getpitems.item.appid && getoitems.item.appid == '440'){
             offer.accept((err) =>{
                 if(err){
                     console.log(err)
                 }
             })
         }else{
             offer.decline((err) =>{
                 if(err){
                     console.log(err)
                 }
             })

Hmm how do i make it accept the offer if the items are tf2 items ? The code up there is just something useless i tried to make

Link to comment
Share on other sites

  • 2 weeks later...

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...