27.05.2013, 21:19
I always get confused when working with inputtext.
How would I check if the inputtext of a dialog is a valid name or ID?
How would I check if the inputtext of a dialog is a valid name or ID?
new player; if(!sscanf(inputtext, "u", player)) { // Input text is valid player name / ID }
if(!strlen(inputtext))
{
// what do you want to do now, when there is nothing written in it
}
if(!response) {
//do what u need to for a blank string here
return 1;
}
//do what you want here if the string is not blank
return 1;
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(response && strlen(inputtext)) { new player; if(!sscanf(inputtext, "u", player)) { // Input text is valid player name / ID } else { // Input text is NOT valid player name / ID } } }
if(!sscanf(inputtext, "u", player))
{
if(player != INVALID_PLAYER_ID)
{
// code here
}
}