First you need to define a new dialog ID for the "name change" dialog, put this at your defines.
pawn Код:
#define DIALOG_CHANGENAME 30680
You can put any ID that you're not using really.
Then you need to declare a variabel for the amount of failed logins, I suggest putting it near your other global variables.
pawn Код:
new FailedLogins[MAX_PLAYERS];
Then you need to reset it when the player logs on.
pawn Код:
//Under OnPlayerConnect
FailedLogins[playerid] = 0;
Then you need to increase the value each time the player fails to log in, and also check if the player has below or three failed logins.
Put this where the player fails to log in
pawn Код:
if(FailedLogins[playerid] >= 0 && FailedLogins[playerid] <= 2)
{
FailedLogins[playerid] ++;
}
This is to increase the amount of the failed logins variable every time the player fails to log in, you'd also need to add a check to see if the player has three failed logins, and if they do show them a dialog for changing their name.
pawn Код:
else if(FailedLogins[playerid] == 3)
{
ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, "Change name", "This name is already registered, and you have 3/3 failed login attempts.\nPlease enter a new name for your account below.", "Submit", "Quit");
}
Then you need to handle this dialog under OnDialogResponse, put something equal to this under there.
pawn Код:
//OnDialogResponseif(dialogid == DIALOG_CHANGENAME)
{
switch(SetPlayerName(playerid, inputtext))
{
case -1: ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, "Change name", "Your name must be 3-24 characters long and only contain valid characters (0-9, a-z, A-Z, [], (), $ @ . _ and = only)\nPlease enter a new name for your account below.", "Submit", "Quit"); //Could not change the name
case 0: ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, "Change name", "You're already known as this name.\nPlease enter a new name for your account below.", "Submit", "Quit"); //Player already has this name
case 1: OnPlayerConnect(playerid); //The name was changed, call OnPlayerConnect again to register the new player.
}
Yeah something like that, you'd have to tweak everything for yourself for it to work with your script though.