[Y_INI] File not saving.
#1

Greetings,

I have started a script from scratch and I came to an unexpected error. The script works fine. I can register in-game, but when I log out, my account, that should be saved in "Accounts" directory, doesn't exists there. I tried every solution, loaded the correct plugins, but still same error.

The tutorial i used was Kush's Y_INI Register/Login system. If you could help me in any way, it would be appreciated.

Please comment below if you need any type of code from the script.
Reply
#2

Make sure you have the correct permissions to write to a file and creating new files etc. I assume you're doing this on Filezilla and not your local host.
Reply
#3

Quote:
Originally Posted by PrivatioBoni
Посмотреть сообщение
Make sure you have the correct permissions to write to a file etc. I assume you're doing this on Filezilla and not your local host.
Home Host....
Reply
#4

Okay, you could have specified that in the original post.
But anyway, it could still be a problem of writing permissions.
Reply
#5

post your loading/saving snippets
Reply
#6

Quote:
Originally Posted by itsCody
Посмотреть сообщение
post your loading/saving snippets
Here ya go!

Код:
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4

#define PATH "/Accounts/%s.ini"

enum pStats
{
    pPass,
    pCash,
    pAdmin,
    pTutorial,
    pKills,
    pLevel,
    Float:Health,
    Float:Armour,
	Float:pPos_x,
	Float:pPos_y,
	Float:pPos_z,
	pSex,
	pSkin,
	pAge,
    pDeaths
}
new pInfo[MAX_PLAYERS][pStats];

stock SaveAccountStats(playerid)
{

	new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Player Data:");

    pInfo[playerid][pSkin] = GetPlayerSkin(playerid);
    pInfo[playerid][pCash] = GetPlayerMoney(playerid);
    pInfo[playerid][pLevel] = GetPlayerScore(playerid);

    new
        Float:x,
        Float:y,
        Float:z
	;

	GetPlayerPos(playerid, x, y, z);
	pInfo[playerid][pPos_x] = x;
	pInfo[playerid][pPos_y] = y;
	pInfo[playerid][pPos_z] = z;
	
	INI_WriteInt(File, "Tutorial", pInfo[playerid][pTutorial]);
	INI_WriteInt(File, "Cash", pInfo[playerid][pCash]);
    INI_WriteInt(File, "Admin", pInfo[playerid][pAdmin]);
    INI_WriteInt(File, "Kills", pInfo[playerid][pKills]);
    INI_WriteInt(File, "Level", pInfo[playerid][pLevel]);
	INI_WriteFloat(File, "Health", pInfo[playerid][Health]);
	INI_WriteFloat(File, "Armour", pInfo[playerid][Armour]);
	INI_WriteFloat(File, "Pos_x", pInfo[playerid][pPos_x]);
	INI_WriteFloat(File, "Pos_y", pInfo[playerid][pPos_y]);
	INI_WriteFloat(File, "Pos_z", pInfo[playerid][pPos_z]);
	INI_WriteInt(File, "Sex", pInfo[playerid][pSex]);
	INI_WriteInt(File, "Skin", pInfo[playerid][pSkin]);
	INI_WriteInt(File, "Age", pInfo[playerid][pAge]);
	INI_WriteInt(File, "Deaths", pInfo[playerid][pDeaths]);
	INI_Close(File);
}

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",pInfo[playerid][pPass]);
    INI_Int("Cash",pInfo[playerid][pCash]);
    INI_Int("Admin",pInfo[playerid][pAdmin]);
    INI_Int("Kills",pInfo[playerid][pKills]);
    INI_Int("Level", pInfo[playerid][pLevel]);
    INI_Float("Health", pInfo[playerid][Health]);
    INI_Float("Armour", pInfo[playerid][Armour]);
    INI_Float("Pos_x", pInfo[playerid][pPos_x]);
    INI_Float("Pos_y", pInfo[playerid][pPos_y]);
    INI_Float("Pos_z", pInfo[playerid][pPos_z]);
    INI_Int("Sex", pInfo[playerid][pSex]);
    INI_Int("Skin", pInfo[playerid][pSkin]);
    INI_Int("Age", pInfo[playerid][pAge]);
    INI_Int("Deaths", pInfo[playerid][pDeaths]);
    INI_Int("Tutorial", pInfo[playerid][pTutorial]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}


public OnPlayerDisconnect(playerid, reason)
{
	SaveAccountStats(playerid);
    return 1;
}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Level",0);
                INI_WriteInt(File,"Tutorial", 0);
                INI_WriteFloat(File,"Pos_x", 0);
                INI_WriteFloat(File,"Pos_y", 0);
                INI_WriteFloat(File,"Pos_z", 0);
                INI_WriteFloat(File,"Health", 100);
                INI_WriteFloat(File,"Armour", 0);
                INI_WriteInt(File,"Sex", 0);
                INI_WriteInt(File,"Skin", 299);
                INI_WriteInt(File,"Age", 0);
                INI_Close(File);
                CancelSelectTextDraw(playerid);
                SetSpawnInfo(playerid, 0, 0, 1715.5223,-1904.3020,13.5664, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                TextDrawHideForPlayer(playerid, Textdraw0);
                TextDrawHideForPlayer(playerid, Textdraw1);
                TextDrawHideForPlayer(playerid, Textdraw2);
                TextDrawHideForPlayer(playerid, Textdraw3);
                TextDrawHideForPlayer(playerid, Textdraw4);
                TextDrawHideForPlayer(playerid, Textdraw5);
                TextDrawHideForPlayer(playerid, login);
                TextDrawHideForPlayer(playerid, Textdraw7);
                TextDrawHideForPlayer(playerid, register);
                TextDrawHideForPlayer(playerid, Textdraw9);
                TextDrawHideForPlayer(playerid, Textdraw10);
                TextDrawHideForPlayer(playerid, Textdraw11);
                TextDrawHideForPlayer(playerid, Textdraw12);
                TextDrawHideForPlayer(playerid, Textdraw13);
                TextDrawHideForPlayer(playerid, Textdraw14);
                ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "Gender Selection", "What is your Sex/Gender?", "Male", "Female");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == pInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, pInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Login Authentication: CVRP",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login Authentication: CVRP",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                CancelSelectTextDraw(playerid);
                return 1;
            }
        }

//Don't worry about closing OnDialogResponse, it is already closed.

public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == register)
    {
	    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registeration Console",""COL_WHITE"Welcome to Crystal Valley Roleplay \n      Please fill your password below to continue:","Register","Quit");
    }
    else if(clickedid == login)
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Authentication Console",""COL_WHITE"Welcome back to Crystal Valley Roleplay! \n Please fill out your password to continue:","Login","Quit");
    }
    return 1;
}
I got "Accounts" folder in my scriptfiles.
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Your tag name is WAY off! It shouldn't have spaces, probably shouldn't have colons, and is different in your reading and writing code.
So, what about changing it to:
PHP код:
INI_SetTag(File,"data"); 
Or shall I just delete it xD
Reply
#8

Quote:
Originally Posted by UnownOwner
when I log out, my account, that should be saved in "Users" directory, doesn't exists there.
pawn Код:
#define PATH "/Accounts/%s.ini"
Rename the User file to Accounts or define path as Users/

Edit: Just saw that you said you have "Accounts" folder but maybe try
pawn Код:
#define PATH "Accounts/%s.ini"
Because I'm using similar tutorial and im using this method ^
Reply
#9

Quote:
Originally Posted by Affan
Посмотреть сообщение
pawn Код:
#define PATH "/Accounts/%s.ini"
Rename the User file to Accounts or define path as /Users/
Oops, maybe i mistyped xD

The folder in the scriptfile is "Accounts"
Reply
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
Don't delete it, that should work.
No luck yet ;(.

I PM'ed you the whole script so you could check it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)