Jump to content
McKay Development

Recommended Posts

Posted

Hi McKay, idk why my offer was declined everytime i sent a correct offer

 

Here is my code

manager.on("newOffer", function(offer) {
    var metal = 0
    var key = 0    
    
    var BuyKey = (offer.itemsToReceive.forEach(function(item) {
        if (item.name == "Mann Co. Supply Crate Key")
        return key++
    }));
    var FromRef1 = (offer.itemsToGive.forEach(function(item) {
        if (item.name == "Refined Metal")
        return metal += 9
        if (item.name == "Reclaimed Metal")
        return metal += 3
        if (item.name == "Scrap Metal")
        return metal++
    }));
  if (BuyKey && FromRef1) {
		
        if (metal == key) {
        offer.accept(function(err) {
        if (err)
            console.log(err);
        else
            console.log("They are selling " + key + " keys for " + buykeyprice * key + " refined metal.");
            console.log(colors.red("Accepting the trade offer."));
            console.log(colors.green("Trade offer accepted."));
        });
    }}        
    else {
        console.log("Trade offer not validated. Declining");
        console.log("They offered " + key + " keys and " + metal + " refined metals. ")
        offer.decline(function(err) {
            if (err) console.log(err);
        });
    }
    });
Guest
This topic is now closed to further replies.
×
×
  • Create New...