Jump to content


Photo
Question

Client to Select an Option from the list

node.js node-steam-user

  • Please log in to reply
1 reply to this topic

#1 Debug

Debug

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 17 March 2019 - 12:41 AM

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 by Debug, 17 March 2019 - 12:42 AM.


#2 PonyExpress

PonyExpress

    Member

  • Member
  • PipPip
  • 22 posts

Posted 21 March 2019 - 04:21 PM

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];
    }

});






Also tagged with one or more of these keywords: Question, node.js, node-steam-user

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users