Server crash on Register
#1

Hello.
i have problem with Register system, it makes server to crash, when I type my password.
My code:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Please Register", "Register", "Leave");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Enter you password to login", "Login", "Leave");
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response)
        {
            SendClientMessage(playerid, COLOR_RED, "You need to login, to play here.");
            Kick(playerid);
        }
        else
        {
                new name[MAX_PLAYER_NAME];
            new file[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
                new string[64];
        new File:password = fopen(file, io_read);
        while(fread(password, string))
        {
                 if(strcmp(string, inputtext, true) == 0)
                {
                Login(playerid);
                }
                else{
                SendClientMessage(playerid, COLOR_WHITE, "Wrong password!");
                Kick(playerid);
                }
            }
            fclose(password);
        }
        return 1;
    }
    else if(dialogid == DIALOG_REGISTER)
    {
        if(!response)
        {
            SendClientMessage(playerid, COLOR_RED, "You need to login to play here.");
            SendClientMessage(playerid, COLOR_WHITE, "You don't have account jet, so make one first!");
            Kick(playerid);
        }
        else
        {
            new name[MAX_PLAYER_NAME];
            new file[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
            new File:password = fopen(file, io_write);
            if(password)
            {
                fwrite(password, inputtext);
                fclose(password);
            }
            Register(playerid);
        }
        return 1;
    }
    return 0;
}
For me this code should take the dialog input and insert the text into /scriptfiles/kasutajad/parool/PlayerNameHere.ini file, but pressing the Register in dialog, crashes the server, Please help
Kasutajad/parool means users/password
Sorry for my bad English
Reply
#2

Try change

pawn Код:
return 0;
to

pawn Код:
return 1;
Reply
#3

Still, Crashes
Reply
#4

It depends. Use at the end of the callback
pawn Код:
return 0;
// if it's filterscript
pawn Код:
return 1;
// if it's gamemode
Comment this line
pawn Код:
Login(playerid);
// Like this, down
// Login(playerid);
and debug it.
pawn Код:
print( "I logged in" );
Reply
#5

Код:
Login(playerid);
Sends the player to Login step, so player can get the money and score, and return 1 still won't work
Reply
#6

When I said "debug it", I meant to use print & printf functions to see what it causes the crash.
Reply
#7

Aam, my bad
Reply
#8

It closes the server Window, and if I press Leave, then it crashes too
Reply
#9

Closing server window = crash.
Replace the callback with this one, change your samp name and register a new account. Then come here and post the server_log.txt (last part of the loaded file).
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response)
        {
            SendClientMessage(playerid, COLOR_RED, "You need to login, to play here.");
            Kick(playerid);
        }
        else
        {
            new name[MAX_PLAYER_NAME];
            new file[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
            new string[64];
            new File:password = fopen(file, io_read);
            while(fread(password, string))
            {
                if(strcmp(string, inputtext, true) == 0)
                {
                    Login(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Wrong password!");
                    Kick(playerid);
                }
            }
            fclose(password);
        }
        return 1;
    }
    else if(dialogid == DIALOG_REGISTER)
    {
        if(!response)
        {
            SendClientMessage(playerid, COLOR_RED, "You need to login to play here.");
            SendClientMessage(playerid, COLOR_WHITE, "You don't have account jet, so make one first!");
            //Kick(playerid);
            print( "DEBUG: Register - Kick(playerid);" );
        }
        else
        {
            new name[MAX_PLAYER_NAME];
            new file[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
            new File:password = fopen(file, io_write);
            if(password)
            {
                fwrite(password, inputtext);
                fclose(password);
            }
            //Register(playerid);
            print( "DEBUG: Register(playerid);" );
        }
        return 1;
    }
    return 0;
}
Reply
#10

Try running the server.exe as Admin, see if that helps more than likely a permissions error.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)