Jump to content


Photo
Question

How to random trading cards in trade

node.js node-steam-tradeoffer-manager

  • Please log in to reply
1 reply to this topic

#1 orcnaydn

orcnaydn

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 25 December 2018 - 05:43 AM


community.getUserInventoryContents(partner, 753, 6, true, (error, items) => {
if(error) {
users.removeReservation(partner, true, removeFunc);
return callback(error);
}

let count = 0;

for(let i = 0; i < items.length; i++) {
let item = items[i];

if(item.type.toLowerCase() != "Trading Card")
continue;

count += item.amount;

if(count > price) {
item.amount -= (count - price);
count -= (count - price);
}

offer.addTheirItem(item);

if(count == price)
break;
}

if(count < price) {
users.removeReservation(partner, true, removeFunc);
return callback("You do not have enough gems to purchase random games.");
}

if(count > price) {
users.removeReservation(partner, true, removeFunc);
return callback("An unexpected error occurred, please try again.");
}

offer.send((error, status) => {
if(error) {
users.removeReservation(partner, true, removeFunc);
return callback(error);
}

if(status == "pending") {
community.acceptConfirmationForObject(files.getConfig().identity, offer.id, error => {
if(error) {
users.removeReservation(partner, true, removeFunc);
return callback(error);
}

callback(null, "https://steamcommunity.com/tradeoffer/" + offer.id);
});
} else if(status == "sent")
callback(null, "https://steamcommunity.com/tradeoffer/" + offer.id);
});
});

break;
default:
users.removeReservation(partner, true, (error) => {
if(error)
return callback(error);

return callback("Invalid payment method");
});
}
});
});
}
 
Where is my fault?

Edited by orcnaydn, 25 December 2018 - 05:45 AM.


#2 orcnaydn

orcnaydn

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 25 December 2018 - 05:46 AM

How to add random trading cards in trade

 

sorry for wrong title







Also tagged with one or more of these keywords: Question, node.js, node-steam-tradeoffer-manager

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users