Jump to content
McKay Development

Meshi8

Member
  • Posts

    13
  • Joined

  • Last visited

Posts posted by Meshi8

  1. Yes, that's returning a promise. You should put your code inside of the callback function and call resolve() once you're done.

    async function abc(){ // test function
    	
    	let Items = ["AK-47 | Elite Build (Minimal Wear)","AK-47 | Redline (Field-Tested)","AK-47 | Frontside Misty (Field-Tested)"];
    	
    		
    		let prices = await Market_Price(Items);
    		console.log(prices); // this will print an empty array
    	
    	
    }
    
    

    This is what happens:

     

    https://gyazo.com/80c78f9ea22da25b0fa774045e31c27d

     

    It will not wait for the function to finish.

    They're both async, it returns a promise but im not sure about the resolve() posittion

     

    Edit: Figuered it out. Just wrapped the entire function with return promise like you suggested, thx for the help :)

  2. Hey,

     

    so Im trying to get the market price of an item I receive on a trade. It works, but for some reason  the script won't wait for my async function to finish and returns an empty result

     

    First I have this function which is triggered when I receive an offer for their items

    async function ProccessTradeOffer(offer){
    
    let TheirItems = offer.itemsToReceive;
    const Deposited_Items = await ConvertToKeys2(TheirItems);
    
    console.log(Deposited_Items); // this will print null and won't wait for the async to finish
    }
    

    This is the other function im calling

    async function ConvertToKeys2(Items){
    
    let ValueInKeys = []; // array of objects containing info about the items
                        
                        return new Promise(resolve => {
                            setTimeout(() => {
                                   if(Market_Value > -1){
                                       obj = {
                                          name: item_name,
                                          value: Market_Value  
                                       }
                                        ValueInKeys.push(obj);
                                    }
                             }, 2000);
                        });   
    
           }
    
        }
           
         return ValueInKeys; 
    }
    

    The problem is that in the main async function it'll not wait for my ConvertToKeys2 function to calculate & add it to array and simply print an empty array.

    It's an async function so I don't understand why thisis happening..

     

    Thx for your help  :) 

  3. Hi,

     

    My bot has been working just fine up until yesterday - When it started going offline a few minutes after launch.

     

    I checked the console, and it's not an error on my part, but it says on the console "Killed"

     

    My guess is, the connection is either Killed by Valve (maybe because I send too many requests to their API?) or someone is ddosing/attacking my bot

     

    Here's a screenshot 

     

    https://gyazo.com/9a73153c59359b6befddd9ce9d3a63e8

     

    It takes more than a minute for it to shut down.

     

    Important Notes:

    I'm hosting my bot on DigitalOcean, and using an SSH connection using putty.

  4. You have to use getGemValue first because turnItemIntoGems needs the expected value.

    That's what I figured.

     However, I'm not sure I'm doing this right.

     

    Here's my attempt:

    // I'm going through my steam inv with a for loop
    
    let MyItem = MySteamInventory[i];
    
    community.getGemValue(MyItem.appid,MyItem.assetid, (res) => {
    console.log("This Item is worth: "+res.gemValue);
    });
    

    Am I supposed to use community.getGemValue since getGemValue belongs to node-SteamCommunity? 

     

    The Error: This Item is worth: undefined

  5. Thanks! I wasn't aware these existed!

     

    However, I'm pretty new to this and really not sure how to use these methods..

     

    Say I have an array called "Selected_Items" with items I filtered myself

     

    I go through it with a for loop and try to convert each item to gems.

     

     I'm supposed to get gemValue first so that I can pass that variable to turnItemIntoGems() method right? I'm not sure how to use getGemValue() method.  Could you give me a simple example by any chance?  :) 

×
×
  • Create New...