Debug Posted March 17, 2019 Report Posted March 17, 2019 (edited) How can i loop the sender message, so that i can wait for the response of the option to be selected which was printed by the for loop Kindly View the Attached Images for an clear example:Image of the example client.on("friendMessage", (SENDER, MSG) => { ... ... else{ var countList = 1; for(var i = 0; i < listOfProducts.length; ++i){ if(listOfProducts[i].is_free_license == false){ client.chatMessage(SENDER, countList +". "+listOfProducts[i].option_text) ountList++; } else{ client.chatMessage(SENDER, result[0].name + ", Unfortunately you can not buy this game as a gift.") } } console.log(countList); client.on("friendMessage", (SENDER, MSG) => { countList = countList - 1; if (MSG === 1) { client.chatMessage(" has been added to the Cart.") } }); } ... ... }); Kindly drop your suggestions... and thank you for your precious time. Edited March 17, 2019 by Debug Quote
PonyExpress Posted March 21, 2019 Report Posted March 21, 2019 if I understand your question, I would do: var waitforanswer = {}; client.on("friendMessage", (SENDER, MSG) => { if (MSG == "buy") { delete waitforanswer[SENDER]; client.chatMessage(SENDER, "Make your choice: 1, 2 or 3"); waitforanswer[SENDER] = ["1","2","3"]; } else if (waitforanswer[SENDER] && waitforanswer[SENDER].indexOf(MSG) >= 0) { client.chatMessage(SENDER, "Your choise: " + MSG); delete waitforanswer[SENDER]; } }); 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.