Jump to content
McKay Development

adma

Member
  • Posts

    23
  • Joined

  • Last visited

Reputation Activity

  1. Like
    adma got a reaction from TextDynasty in cannot declined the wrong offer   
    Next time, please present properly formatted code with curly braces... its very disorientating to follow if .. else statements that do not use curly brackets...
  2. Like
    adma got a reaction from Dr. McKay in cannot declined the wrong offer   
    I don't know what you are trying to do with the comma operator, but by the looks of it you want to use the and operator (&&) in your if (onlyKeys, onlyRef) checks...
     
    if (onlyKeys2, onlyRef2) âž¡ if (onlyKeys2 && onlyRef2)
     
    In regards to your declining offer thing... its probably to do with your lack of curly braces surrounding if and else e.g
    if (x && y) { // code } else { // code } Not ...
    if (x && y) // code else // code What do these lines do/mean?
    'refAmount = offer.itemsToGive.length == keyAmount * buyprice'
    'refAmount = offer.itemsToReceive.length == keyAmount * sellprice'
     
    Also, unless you want the refAmount and keyAmount to be global, you should really declare them with var ... keyAmount = offer.itemsToGive.length âž¡ var keyAmount =  offer.itemsToGive.length
     
    Even though I am new to coding/scripting and I can see your code is very untidy/messy...
     
    PS: What is offers.on('newOffer') ? and why is trade offer manager newOffer listener nested inside this???
  3. Like
    adma got a reaction from TextDynasty in Trade Offer Bot   
    manager.on("newOffer", function(offer) {
    var onlyKeys = (offer.itemsToReceive.every(function(item) {
    return item.name == "Mann Co. Supply Crate Key";
    }));

    if (onlyKeys) {
    keyAmount = offer.itemsToReceive.length
    console.log("Received trade offer containing " + keyAmount + " keys, accepting");
    offer.accept(function(err) {
    if (err) console.log(err);
    });
    } else {
    console.log("Trade offer contains non key items. Declining");
    offer.decline(function(err) {
    if (err) console.log(err);
    });
    }

  4. Like
    adma got a reaction from Melonos in itemsToGive with multiple items   
    If you want to get the market hash names of each item you're giving, you would probably use forEach or a for loop to cycle through the itemsToGive array ...
    e.g
    manager.on('newOffer', function(offer) { offer.itemsToGive.forEach(function(item) { console.log("Item to give : " + item.market_hash_name); // Items to give: Chroma 2 Case }); }); a for ... of loop (edited from for..in loop)
    manager.on('newOffer', function(offer) { for (var item of offer.itemsToGive) { console.log("Items to give : " + item.market_hash_name); // Items to give: Chroma 2 Case } }); a regular for loop
    manager.on('newOffer', function(offer) { for (var i = 0; i < offer.itemsToGive.length; i++) { console.log("Items to give #" + i + " : " + offer.itemsToGive[i].market_hash_name); // Items to give #1 : Chroma 2 Case } });Same deal will apply for itemsToReceive ... or any other array you wanted to cycle through
     
    read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration
  5. Like
    adma reacted to Dr. McKay in newOffer triggered on real trade   
    Check fromRealTimeTrade and abort if it's true in newOffer.
  6. Like
    adma reacted to Dr. McKay in Listening for accepted trade offer from real trade   
    https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/Real-Time-Trades
  7. Like
    adma got a reaction from Dr. McKay in Listening for accepted trade offer from real trade   
    I honestly can't believe how prompt you were with implementing this. Thanks very much McKay!
×
×
  • Create New...