24.05.2013, 20:26
(
Последний раз редактировалось DerickClark; 24.05.2013 в 22:35.
)
i got login problem.if the player reach 3 warns.don't get kicked? But how?
Код:
// The login dialog #define TXT_DialogLoginTitle "Test Login" // Define the title-message on top of the login-dialog #define TXT_DialogLoginMsg "Please login by entering your password:" // Define the actual message in the login-dialog #define TXT_DialogLoginButton1 "Login" // Define the text on the "login" button for the login-dialog #define TXT_LoggedIn "You logged in, welcome back to Test" #define TXT_WrongPassword "You've entered the wrong password, you've been kicked" #define TXT_LoginEnterValidPassword "Please login by entering your password:" #define TXT_PlayerMustLogin "You must login in order to play, you've been kicked out!" #define TXT_FailedLoginProperly "You failed to login properly, you're kicked"
Код:
// Process the login-dialog #define MAX_FAIL_LOGINS 3 new FailLogin[MAX_PLAYERS]; Dialog_Login(playerid, response, inputtext[]) { switch (response) // Check which button was clicked { case 1: // Player clicked "Login" { // Check if the player entered a password if (strlen(inputtext) > 0) { // Check if the entered password is the same as the password saved in the player's account if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0) { new string[128]; FailLogin[playerid]++; format(string, sizeof(string), "The password you have entered was incorrect. Attempts(%d)", FailLogin[playerid]); APlayerData[playerid][LoggedIn] = true; // The player has logged in properly BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this) SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properly } else { new string[128]; FailLogin[playerid]++; format(string, sizeof(string), "The password you have entered was incorrect. Attempts(%d)", FailLogin[playerid]); SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword); ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_INPUT, TXT_DialogLoginTitle, TXT_DialogLoginMsg, TXT_DialogLoginButton1, TXT_DialogButtonCancel); } } else { if(FailLogin[playerid] == MAX_FAIL_LOGINS) { new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname)); new string[128]; format(string, sizeof(string), "%s has been kicked (Failed Logins)",pname); SendClientMessageToAll(-1, string); Kick(playerid); } } } case 0: // Player clicked "Cancel" { // Show a message that the player must be logged in to play on this server SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin); Kick(playerid); } } return 1; }