I am getting logged-in typing any character I'd like
#1

Hey guys, I am trying to write a simple code that allows players register/login their/into their accounts. I have finished with register dialog, everything works fine, which can not be told about login. The problem is that while I type any character I am getting logged-in. I guess that I've made a mistake in comparing password with the inputtext. Here is the code:

PHP код:
#define DIALOG_REGISTER 0
#define DIALOG_LOGIN 1
#define DIALOG_QUIT 2
#define DIALOG_PASSLEN 3
#define DIALOG_WRONGPASS 4 
PHP код:
public OnPlayerConnect(playerid)
{
    new 
PlrFile[128];
    
format(PlrFilesizeof(PlrFile), "/Users/%s.txt"RetPlrName(playerid));
    if(!
fexist(PlrFile))
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registration""Please type your future password below:""Register""Cancel");
    }
    else
    {
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT"Logging-in""Please type your password below:""Login""Cancel");
    }
    return 
1;

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_REGISTER)
    {
        if(
response == 0)
        {
            
ShowPlayerDialog(playeridDIALOG_QUITDIALOG_STYLE_MSGBOX"Cancelled""Use /q to exit""OK""");
            
Kick(playerid);
        }
        else if(
response == 1)
        {
            new 
KeyLen strlen(inputtext);
            if(
KeyLen <= || KeyLen >= 33)
            {
                
ShowPlayerDialog(playeridDIALOG_PASSLENDIALOG_STYLE_MSGBOX"Notice""The password must be between 6 and 32 symbols""OK""");
            }
            else
            {
                new 
PlrFile[128], File:PlrFileOpen;
                
format(PlrFilesizeof(PlrFile), "/Users/%s.txt"RetPlrName(playerid));
                
PlrFileOpen fopen(PlrFileio_write);
                
fwrite(PlrFileOpeninputtext);
                
fclose(PlrFileOpen);
            }
        }
    }
    else if(
dialogid == DIALOG_LOGIN)
    {
        if(
response == 0)
        {
            
ShowPlayerDialog(playeridDIALOG_QUITDIALOG_STYLE_MSGBOX"Cancelled""Use /q to exit""OK""");
            
Kick(playerid);
        }
        else if(
response == 1)
        {
            new 
PlrFile[128], File:PlrFileOpenpass[128];
            
format(PlrFilesizeof(PlrFile), "/Users/%s.txt"RetPlrName(playerid));
            
PlrFileOpen fopen(PlrFileio_read);
            
fread(PlrFileOpenpass);
            if(
strcmp(inputtextpassfalse32))
            {
                
SendClientMessage(playerid0xFFFFFFAA"You have successfully logged-in");
            }
            else
            {
                
ShowPlayerDialog(playeridDIALOG_WRONGPASSDIALOG_STYLE_MSGBOX"Error""You have typed wrong password""OK""");
            }
            
fclose(PlrFileOpen);
        }
    }
    else if(
dialogid == DIALOG_PASSLEN)
    {
        if(
response == 1)
        {
            
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registration""Please type your future password below:""Register""Cancel");
        }
    }
    else if(
dialogid == DIALOG_WRONGPASS)
    {
        if(
response == 1)
        {
            
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT"Logging-in""Please type your password below:""Login""Cancel");
        }
    }
    return 
1;

The following callbacks are used only. Somebody, pimp my code.

And, yeah, create a folder called "Users" in the scriptfiles folder.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)