Jump to content
McKay Development

Recommended Posts

Posted

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]

 

Posted

As McKay said, offer.itemsToGive is an array of items you will loose after the trade and offer.itemsToReceive is an array of items you will receive after the trade.

Posted

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!'
)}
Posted
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

  • 2 weeks later...
Posted

You should consider rechecking for the appid.

// We have to use application IDs in our requests
var appid = {
  TF2:   440,
  DOTA2: 570,
  CSGO:  730,
  Steam: 753
};

var gameappid = appid.TF2;


You can try to compare your Items with this GameID

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