MrKirby Posted February 23, 2017 Report Posted February 23, 2017 I am having issues with calling this function. I think it has something to do with the function waiting a little while. I have searched for callback etc. on the internet and I found a lot but I have no clue how to use them on the code... QuestionHow do I use sync callback on the function: "getUserInventoryContents" This is what I have now: manager.getUserInventoryContents(config.accounts.steamid64[i],753, 6, true, (err, inventory) => { if (err) { console.log(err); return; } else if (err == null) { //The rest of the code I thought that this would work... I am not the best in node, basically just started... but hope you could help me Quote
Dr. McKay Posted February 23, 2017 Report Posted February 23, 2017 Synchronous I/O functions are contrary to Node's paradigm and so aren't supported. Or is that not what you're asking? Quote
MrKirby Posted February 23, 2017 Author Report Posted February 23, 2017 (edited) Synchronous I/O functions are contrary to Node's paradigm and so aren't supported. Or is that not what you're asking?Thanks for the quick response, but it is not what I am looking for, I think.Whenever it is busy 'getting' a user's inventory, it should freeze a code block (like a normal callback function could do).But I have no clue on how to run a callback on the "getUserInventoryContents" functoin. EDIT: var j = 10; for(var i=0;i<j;i++) { console.log("testing... " + i) manager.getUserInventoryContents(config.accounts.steamid64[i],753, 6, true, (err, inventory) => { if (err) { console.log(err); return; } else if (err == null ) { console.log("Inventory length bot " +inventory.length+" | steamID "+ config.accounts.steamid64[i]); //etc. etc. This will output: testing... 0 testing... 1 testing... 2 etc. testing... 9 Inventory length bot 100 | steamID 12345678901234567890 //random ID Inventory length bot 100 | steamID 12345678901234567890 //random ID Inventory length bot 100 | steamID 12345678901234567890 //random ID etc. Inventory length bot 100 | steamID 12345678901234567890 //random ID Inventory length bot 100 | steamID 12345678901234567890 //random IDNow, how can I make it output this: testing... 0 Inventory length bot 100 | steamID 12345678901234567890 //random ID testing... 1 Inventory length bot 100 | steamID 12345678901234567890 //random ID testing... 2 Inventory length bot 100 | steamID 12345678901234567890 //random ID etc. Thanks in advance Edited February 23, 2017 by MrKirby Quote
Dr. McKay Posted February 23, 2017 Report Posted February 23, 2017 You could perhaps use the async module. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.