Problem with login
#1

Hello, I need your help. With help of this forum I created register and saving script, but it doesn't work properly. Register, login, saving works, everything works, but the problem is when I change money or score in player files and try to connect to the server my password is not correct, I didn't change that though. I don't know if I need to add sometging, delete something or just edit something. Here's my script:

On top of the gamemode:

Код:
    #include <a_samp>
    #include <dini>
    #include <dudb>
 
    #pragma unused ret_memcpy
 
    #define PLAYERS "Ћaidėjai/%s.ini"
 
    enum pInfo
{
    pMoney,
    pExperiencePoints,
} 
    new PlayerInfo[MAX_PLAYERS][pInfo];
    new PlayerLogged[MAX_PLAYERS];
OnPlayerConnect:

Код:
public OnPlayerConnect(playerid)
{
    PlayerLogged[playerid] = 0;

    new name[MAX_PLAYER_NAME], file[256];

    GetPlayerName(playerid, name, sizeof(name));

    format(file, sizeof(file), PLAYERS, name);

    if(!dini_Exists(file))
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{ffffff}Registracija", "{ffffff}Prisiregistruokite, įvesdami slaptaћodį.", "Registruotis", "Iљeiti");
}
    if(fexist(file))
{
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{ffffff}Prisijungimas", "{ffffff}Prisijunkite, įvesdami slaptaћodį.", "Prisijungti", "Iљeiti");
}
    return 1;
}
OnPlayerDisconnect:

Код:
public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME], file[256];

    GetPlayerName(playerid, name, sizeof(name));

    format(file, sizeof(file), PLAYERS, name);

    if(PlayerLogged[playerid] == 1)
{
    dini_IntSet(file, "Patirties taљkai", PlayerInformation[playerid][ExperiencePoints]);
    dini_IntSet(file, "Pinigai", PlayerInformation[playerid][Money]);
}
    PlayerLogged[playerid] = 0;
    return 1;
}
OnDialogResponse:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == 1)
{
    new name[MAX_PLAYER_NAME], file[256], string[128];

    GetPlayerName(playerid, name, sizeof(name));

    format(file, sizeof(file), PLAYERS, name);

    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return

    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{ffffff}Registracija", "{ffffff}Prisiregistruokite, įvesdami slaptaћodį.", "Registruotis", "Iљeiti");

    dini_Create(file);
    dini_IntSet(file, "Slaptaћodis", udb_hash(inputtext));
    dini_IntSet(file, "Pinigai", PlayerInformation[playerid][Money] = 0);
    dini_IntSet(file, "Patirties taљkai", PlayerInformation[playerid][ExperiencePoints] = 0);

    format(string, 128, "Sėkmingai uћsiregistravote. Jūsų slaptaћodis: {ffff33}%s{ffffff}.", inputtext);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    SendClientMessage(playerid, 0xFFFFFFFF, "Informaciją apie serverį rasite, paraљę {ffff33}/informacija{ffffff}.");

    PlayerLogged[playerid] = 1;
}
    if (dialogid == 2)
{
    new name[MAX_PLAYER_NAME], file[256];

    GetPlayerName(playerid, name, sizeof(name));

    format(file, sizeof(file), PLAYERS, name);

    if(!response) return Kick(playerid);
    if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{ffffff}Prisijungimas", "{ffffff}Prisijunkite, įvesdami slaptaћodį.", "Prisijungti", "Iљeiti");

    new tmp;

    tmp = dini_Int(file, "Slaptaћodis");

    if(udb_hash(inputtext) != tmp)
{
    SendClientMessage(playerid, 0xFFFFFFFF, "{ff0033}Neteisingas {ffffff}slaptaћodis.");

    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{ffffff}Prisijungimas", "{ffffff}Prisijunkite, įvesdami slaptaћodį.", "Prisijungti", "Iљeiti");
}
    else
{
    PlayerLogged[playerid] = 1;

    SetPlayerScore(playerid, PlayerInformation[playerid][ExperiencePoints]);

    GivePlayerMoney(playerid, dini_Int(file, "Pinigai") - GetPlayerMoney(playerid));

    SendClientMessage(playerid, 0xFFFFFFFF, "{99ff33}Teisingas {ffffff}slaptaћodis. Sėkmingai prisijungėte.");
}

}
    return 1;
}
Reply
#2

Maybe sometimes you changed the password from player files
Reply
#3

No, I didn't. I only changed money and score.
Reply
#4

Showw me your code which looks like this:

pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
return 1;
}

And you forgot to parse the file on player connect. Therefore it wouldnt load your pass
so it should be like:

pawn Код:
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
ShowPlayerDialog(.....);
return 1;
}
wish helped
Reply
#5

Quote:
Originally Posted by qazwsx
Посмотреть сообщение
Showw me your code which looks like this:

pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
return 1;
}

And you forgot to parse the file on player connect. Therefore it wouldnt load your pass
so it should be like:

pawn Код:
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
ShowPlayerDialog(.....);
return 1;
}
wish helped
EDIT:I recommend you to use Y_Ini instead of dini
Reply
#6

I don't have a code like that. i showed you all of the script that i'm using for register and saving system. Actually it loads my password if I don't change anything in player file, but if I do change something, then my password will always be incorrect.
Reply
#7

It might have something to do with the way linebreaks and weird symbols are handled when a file is opened and then saved again. To minimize the risk of any complications, I'd not use any weird language specific symbols (e.g. "ž") anywhere. I'd stick to plain English for the inner workings of the script.
Reply
#8

It's still not working for me. Maybe someone can give me a link or something to a properly working register system? It doesn't have to be with saving too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)