这里是我的一段代码蒸汽Tf2的贸易BOT Node.js加载问题
// 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');
}
}
所以,基本上我的兄弟放了这个项目(节日黑匣子),它应该把一个废料,但它不,而是说“酷!” (所以我知道它的工作原理),并没有插入废料的机器人,我等了很长时间,似乎没有工作,也只有一个废金属在我的库存!
这里有一些我的代码片段;
// 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
}
});
});
});
你有没有登录'item.name'? – 2015-04-02 17:21:55
不,我不知道它到底是什么,也许'Scrap Metal'item.name? – EEVV 2015-04-02 17:29:50
@TomA请举例? – EEVV 2015-04-02 17:31:20