Problem with login dialog (+rep)
#1

Hello, i have a problem with the login dialog

Everything is fine, if a player types wrong password it tells that he did it, if he types the right password then he loggs in

but one problem is there, if player types nothing in the dialog, it automatically loggs him in by reading from the user file

pawn Код:
if(dialogid == 1)
{
    if(strlen(inputtext) == 0) {
        SendClientMessage(playerid, COLOR_WHITE, "");
        new string[185];
        format(string, sizeof(string),"{FFFFFF}Inkorrekte Password Eingabe {FFD700}%s{FFFFFF},\n\nBitte gebe dein Passwort ein um dich zu authentifizieren.",GetName(playerid));
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT,"Authentifizierung",string, "Login", "Abbrechen");
    }
    new file[128],string[128];
    format(file,sizeof(file),"/racuni/%s.txt",GetName(playerid));
    if(fexist(file))
    {
        new password[130];
        INI_ParseFile(file, "PlayerPassword", false, true, playerid, true, false );
        GetPVarString(playerid, "pPass", password, sizeof password);
        if(!strcmp(inputtext, password, true))
    {
        IsLogged[playerid] = 1;
        ClearChat(playerid);
        SendClientMessage(playerid, COLOR_GREEN, "||-Erfolg-|| Du hast dich erfolgreich eingeloggt!");
        SendClientMessage(playerid, COLOR_GREEN, "");
        format(string, sizeof(string), "[SERVER] %s hat sich erfolgreich eingeloggt!", GetName(playerid) );
        printf(string);
        LoadSpieler(playerid);
    }
How can i fix it?
Reply
#2

After checking if the dialog box is empty (if(!strlen(inputtext)) checks if box is empty), you still continue with the script. You will have to put a return when the dialog box is empty so the rest of the code doesn't get processed.

pawn Код:
if(dialogid == 1)
{
    if(!strlen(inputtext)) {
        SendClientMessage(playerid, COLOR_WHITE, "");
        new string[185];
        format(string, sizeof(string),"{FFFFFF}Inkorrekte Password Eingabe {FFD700}%s{FFFFFF},\n\nBitte gebe dein Passwort ein um dich zu authentifizieren.",GetName(playerid));
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT,"Authentifizierung",string, "Login", "Abbrechen");
        return 1;
    }
    new file[128],string[128];
    format(file,sizeof(file),"/racuni/%s.txt",GetName(playerid));
    if(fexist(file))
    {
        new password[130];
        INI_ParseFile(file, "PlayerPassword", false, true, playerid, true, false );
        GetPVarString(playerid, "pPass", password, sizeof password);
        if(!strcmp(inputtext, password, true))
        {
            IsLogged[playerid] = 1;
            ClearChat(playerid);
            SendClientMessage(playerid, COLOR_GREEN, "||-Erfolg-|| Du hast dich erfolgreich eingeloggt!");
            SendClientMessage(playerid, COLOR_GREEN, "");
            format(string, sizeof(string), "[SERVER] %s hat sich erfolgreich eingeloggt!", GetName(playerid) );
            printf(string);
            LoadSpieler(playerid);
        }
Reply
#3

Change to
pawn Код:
if(strlen(inputtext) < 1)
it might work i dont really know since i cant test it on my phone.
Reply
#4

pawn Код:
if (!response) return Kick(playerid);
Reply
#5

thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)