SA-MP Forums Archive
Problem with login dialog (+rep) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with login dialog (+rep) (/showthread.php?tid=342570)



Problem with login dialog (+rep) - Dripac - 14.05.2012

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?


AW: Problem with login dialog (+rep) - Drebin - 14.05.2012

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);
        }



Re: Problem with login dialog (+rep) - HDFord - 14.05.2012

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


Re: Problem with login dialog (+rep) - Face9000 - 14.05.2012

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



Re: Problem with login dialog (+rep) - Dripac - 14.05.2012

thanks