I don't think we've gotta loop for this.
pawn Код:
new itext = 0; //Create a variable inorder to get the input text and use it for other case. Starting it as zero as we want to store other text on dialog.
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //When a dialog gets a response from one of the player.
{
if(dialogid == 1) //If the response if for dialogid 1.
{
//As your post is talking about DIALOG_STYLE_INPUT, the dialog where we input text so lets take Dialog_style_input dialog.
if(!response) //When player clicks 2nd button or while pressing ESC on keyboard. '!' refers to negative/wrong response.
{ //Open brackets to execute functions for negative response.
//Your functions here.
}
else //If it isn't a negative response, which means 'if(response)' and when '!' gets switched by else statement, you don't need to add 'if(response)'
{ //Open brackets to execute function for positive response or while clicking 1st button.
itext = inputtext; //Here we made our itext variable as the text player entered on that dialog.
//Other functions.
}
} //Closing the bracket which we've opened on 'if(dialogid)'.
return 1; //Returns the functions.
}
return 0; //Like 'OnPlayerCommandText' we need to return 0 here too as returning the callback.
}
Now the variable 'itext' is contains the input text, and if you're using it in the case of players, change the variable 'new itext = 0;' to 'new itext[MAX_PLAYERS] = 0;' and while using it, use it as 'itext[playerid] = inputtext;' on dialog.
And now, the player's itext is the input text.
And you can use it, here's an example.
pawn Код:
CMD:enteredtextindialog(playerid,params[])
{
new str[128];
format(str, sizeof(str), "%s", itext[playerid]);
SendClientMessage(playerid, 0xFF0000FF, str);
return 1;
}
Hope this will give you an idea.