Please dini help
#1

Hello guys i really need your help i followed Lorenc's tutorial on the old dini file system (yes i know it is old) and i created everything now everything works fine when i join the dialog appears and i type my password and register successfully when i get out i see the file is saved and the password is hashed when i login to the game it says to me that you have to register (again) not login yes register and when i do all my stats gets rewrittenhere is my code
pawn Код:
public OnPlayerConnect(playerid)
{
    // - - Register System - - //
    gPlayerLogged[playerid] = 0;
    new pName[MAX_PLAYER_NAME];
    new file[256];
    format(file, sizeof(file), SERVER_DATABASE, pName);
    if(!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new pName[MAX_PLAYER_NAME];
    new file[256];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), SERVER_DATABASE, pName);
    if(gPlayerLogged[playerid] == 1)
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "VIP", PlayerInfo[playerid][pVIP]);
        dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin]);
    }
    gPlayerLogged[playerid] = 0;
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    // - - Register System - - //
    if(dialogid == 1)
    {
        new pName[MAX_PLAYER_NAME];
        new file[256];
        new string[128];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(file, sizeof(file), SERVER_DATABASE, pName);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "NOTE: You Didn't Enter Anything\n\nWelcome To Advena Freeroam Please Write A Password\nBelow To Register A New Account","Register","Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin] = 0);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash] = 50);
        dini_IntSet(file, "VIP", PlayerInfo[playerid][pVIP]);
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore] = 0);
        format(string, 128, "[SYSTEM] You Have Successfully Registered The Name (%s) With Password (%s)", pName, inputtext);
        SendClientMessage(playerid, SERVER_RED, string);
        gPlayerLogged[playerid] = 1;
    }
    else
    {
        new pName[MAX_PLAYER_NAME];
        new file[256];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(file, sizeof(file), SERVER_DATABASE, pName);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "NOTE: You Didn't Enter Anything\n\nWelcome Back To Advena Freeroam Please Type Your\nPassword Below To Login","Login","Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) !=tmp)
        {
            SendClientMessage(playerid, SERVER_RED, "Wrong Password Entered Please Try Again");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "NOTE: You Have Entered An Incorrect Password\n\nPlease Retype Your Password Below","Login","Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdmin] = dini_Int(file, "Admin");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SendClientMessage(playerid, SERVER_RED, "[SYSTEM] You Have Successfully Logged In");
        }
    }
    return 1;
}
Reply
#2

Change

pawn Код:
if(!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
    }
to

pawn Код:
if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
    }
    else if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
    }
Reply
#3

Quote:
Originally Posted by Romel
Посмотреть сообщение
Change

pawn Код:
if(!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
    }
to

pawn Код:
if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
    }
    else if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
    }
not working
Reply
#4

anyone pls help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)