06.12.2010, 13:35
Something like this, try not to get into a habbit of using strlen for simple things like this !
pawn Код:
if(dialogid == 2)
{
new
name[MAX_PLAYER_NAME], file[50], tmp[50];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
// Your previous example used strlen, which loops around every character in the string until it finds the '\0' escape character
// To check if there's no input, simply check if the first character is not a valid character, thus it must be '\0'.
// This is much quicker than checking all characters, when you only want to check if there is a character, if there is text, the first character will not be '\0'.
if(!inputtext) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
format(tmp, sizeof(tmp), "%s", dini_Get(file, "Password"));
format(PlayerInfo[playerid][Password], 50, "%s", tmp);
if(udb_hash(inputtext) != PlayerInfo[playerid][Password])
{
SendClientMessage(playerid,RED,"Sorry Wrong Password!");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
return 1;
}
OnLogin(playerid, inputtext);
return 1;
}
// Other dialogs
return 0;
}