25.09.2012, 03:35
pawn Код:
new doorpass = 1234; //Creating a password variable for the door.
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_LOGIN)
{
if(!response) // If they clicked 'Cancel' or pressed esc
{
SendClientMessage(playerid, COLOR_RED, "You MUST login to play here. Please change your name.");
Kick(playerid);
}
else // Pressed ENTER or clicked 'Login' button
{
if(inputtext == doorpass) //Detecting whether the entered text is the password of door or not.
{ //If yes, ...
SendClientMessage(playerid, COLOR_RED, "You are now logged in!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "LOGIN FAILED.");
// Re-show the login dialog
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}