Jump to content
McKay Development

Client to Select an Option from the list


Debug

Recommended Posts

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
Link to comment
Share on other sites

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

});
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...