String is not saving.
#1

Good evening, I followed a tutorial to create register/login system.

But now I want to store 3 names into the .ini file. But it doesn't save the names.

This is what happens when people register:
Код:
            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_WriteString(File, "Name", "Empty");
                INI_WriteString(File, "Name2", "Empty");
                INI_WriteString(File, "Name3", "Empty");
                INI_Close(File);
				SaveAccount(playerid);
                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
			}
It saves the password perfectly, but the names do not get saved.

Код:
enum mInfo
{
    mPass,
    mName[32],
    mName2[32],
    mName3[32]
}
new MasterInfo[MAX_PLAYERS][mInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password",MasterInfo[playerid][mPass]);
	INI_String("Name",MasterInfo[playerid][mName], 32);
	INI_String("Name2",MasterInfo[playerid][mName2], 32);
	INI_String("Name3",MasterInfo[playerid][mName3], 32);
 	return 1;
}

stock SaveAccount(playerid)
{
	new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File,"data");
 	INI_WriteString(File, "Name", MasterInfo[playerid][mName]);
 	INI_WriteString(File, "Name2", MasterInfo[playerid][mName2]);
 	INI_WriteString(File, "Name3", MasterInfo[playerid][mName3]);
	INI_Close(File);
}
Reply
#2

EDIT: Nevermind, turns out I was wrong.
Reply
#3

Quote:
Originally Posted by DTV
Посмотреть сообщение
EDIT: Nevermind, turns out I was wrong.
I can't find any solution.
Reply
#4

Maybe you have to assign the "Empty" string to a variable and use that in place of "Empty"

pawn Код:
new name[MAX_PLAYER_NAME] = "Empty";
INI_WriteString(File, "Name", name);
INI_WriteString(File, "Name2", name);
INI_WriteString(File, "Name3", name);
Reply
#5

If I create a file like this it does work.
Код:
CMD:test(playerid, params[])
{
	new INI:File = INI_Open("Fabio.ini");
	INI_SetTag(File,"data");
 	INI_WriteString(File, "Name", "Empty");
 	INI_WriteString(File, "Name2", "Empty");
 	INI_WriteString(File, "Name3", "Empty");
	INI_Close(File);
	SendClientMessage(playerid, COLOR_LIGHTGREEN, "BETA: File created.");
	return 1;
}
Reply
#6

Now, if I register and I check player files, it's correct.
But once the callback 'SaveAccount' gets called it's gone.
Reply
#7

And what exactly are 'MasterInfo[playerid][mName]', 'MasterInfo[playerid][mName2]' and 'MasterInfo[playerid][mName3]'?

Have you even checked the value of those?

And when you say they aren't saved, are you looking in the database or are you checking in-game after you've loaded them?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)