Here is my piece of code
// Any time an item changes in the trade window
trade.on('offerChanged', function(itemAdded, item) {
if (itemAdded) {
logger.info('User added: '+item.name)
if (item.name == 'Festive Black Box') {
trade.chatMsg('Cool!');
trade.addItem('Scrap Metal');
}
}
So, basically my brother puts this item in (Festive Black Box), it should put one scrap, but it doesn't, instead saying "Cool!" (so i know it works) and no scrap inserted by the bot, i waited a long time, doesn't seem to work, also I only have one scrap metal in my inventory!
Here are some more pieces of my code;
// After we accept the trade, we deal with the trade session
client.on('sessionStart', function(steamID) {
inTrade = true;
client.setPersonaState(steam.EPersonaState.Busy);
trade.open(steamID, function() { // Pass the trade off to our steam-trade library
trade.loadInventory(appid.TF2, contextid.TF2, function(inv) {
inventory = inv;
scrap = inv.filter(function(item) { return item.name == 'Scrap Metal';});
logger.error(scrap)
if (!inv) {
logger.error('Error getting own inventory. Cancelling trade.');
client.sendMessage(steamID, 'Could not load my inventory, please contact my creator.');
trade.cancel(steamID);
} else {
logger.debug('Found '+inv.length+' items in my inventory.');
myBackpack = inv; // Now we can access it globally
// If you want to put items up in the trade window immediately,
// here is where you could do it. Instead we're calling a custom function.
onTradeStart(steamID); // Our custom function
}
});
});
});