Y_ini not overwriting existing values
#1

Hey guys, I'm having a strange problem with saving with Y_ini. When it writes to the file it does not update existing values in the %s file (user's file), instead of overwriting the values it creates new entries under the existing entries. I'm saving using stocks, one stock saving values on registration and another stock saving on player disconect(both saving the same values in the same order). I can provide some code but I'm posting with my Blackberry mobile. Please help me resolve this problem, I haven't done any code in some time Thanx in advance.
Reply
#2

We need code.
Reply
#3

I have noticed that when you use spaces in your entries in your file, like "Register Date" - It will not overwrite it, but append as you say.

When i used the entry "RegisterDate" It does not append to the file, and it overwrite the existing one.

If you have spaces in the saved entries, it will make new lines with the value. Don't know why though.

Good luck!
Reply
#4

Some of my script defines.
Код:
#define <YSI\Y_INI>
#define PATH "Users/%s.ini
then a enum to create the variables.
Код:
enum PlayerData
{ 
     Player_Name[MAX_PLAYER_NAME], 
     Password[129], 
     Float:PosX, 
     Float:PosY, 
     Float:PosZ, 
     Float:Pos:A, 
     Interior, 
     VirtualWorld, 
     Skin 
}
remember I'm sending with mobile so I can't indent correctly. Next the stock that saves the data.
Код:
 
stock Save_Info(playerid) 
{ 
     GetPlayerName(playerid, PlayerInfo[playerid][Player_Name], MAX_PLAYER_NAME); 
     GetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);  
     GetPlayerFacingAngle(PlayerInfo[playerid][PosA]);

     new PlayerFile[512];
     Formar(PlayerFile, sizeof playerfile, PATH, PlayerInfo[playeid][Player_Name]);

     new INI:File = INI_Open(PlayerFile);
     INI_WriteString(File,"User Name", PlayerInfo[playerid][Player_Name]);
     INI_WriteString(File,"Password", PlayerInfo[playerid][Password]);
     INI_WriteFloat(File,"Pos X", PlayerInfo[playerid][PosX]);
     INI_WriteFloat(File,"Pos Y", PlayerInfo[playerid][PosY]);
     INI_WriteFloat(File,"Pos Z", PlayerInfo[playerid][PosZ]);
     INI_WriteFloat(File,"Pos A", PlayerInfo[playerid][PosA]);
     INI_WriteInt(File,"VirtualWorld", GetPlayerVirtualWorld(playerid));
     INI_WriteInt(File,"Interior", GetPlayerInterior(playerid));
     INI_WriteInt(File,"Skin", GetPlayerSkin(playerid));
     INI_Close(File);
The stock on player register...
Код:
 
stock OnPlayerRegister(playerid, password[]) 
{ 
     PlayerInfo[playerid][PosX] = 214.2363;
     PlayerInfo[playerid][PosY] = 1878.2864;
     PlayerInfo[playerid][PosZ] = 13.1406;
     PlayerInfo[playerid][PosA] = 0.0;
     PlayerInfo[playerid][VirtualWorld] = 0;
     PlayerInfo[playerid][Interior] = 0;
     PlayerInfo[playerid][Skin] = 0;
          
     new PlayerFile[512];
     GetPlayerName(playerid, PlayerInfo[playerid][Player_Name], MAX_PLAYER_NAME);  
     Formar(PlayerFile, sizeof playerfile, PATH, PlayerInfo[playeid][Player_Name]);

     WP_Hash(PlayerInfo[playerid][Password], 129, password);

     new INI:File = INI_Open(PlayerFile);
     INI_WriteString(File,"User Name", PlayerInfo[playerid][Player_Name]);
     INI_WriteString(File,"Password", PlayerInfo[playerid][Password]);
     INI_WriteFloat(File,"Pos X", PlayerInfo[playerid][PosX]);
     INI_WriteFloat(File,"Pos Y", PlayerInfo[playerid][PosY]);
     INI_WriteFloat(File,"Pos Z", PlayerInfo[playerid][PosZ]);
     INI_WriteFloat(File,"Pos A", PlayerInfo[playerid][PosA]);
     INI_WriteInt(File,"VirtualWorld", PlayerInfo[playerid][VirtualWorld]);
     INI_WriteInt(File,"Interior", PlayerInfo[playerid][Interior]);
     INI_WriteInt(File,"Skin", PlayerInfo[playerid][Skin]);
     INI_Close(File);
That is the saving code, on the disconect function I call the save_info stock and on the ondialog response I call the onplayerregister stock SaveInfo(playerid); and OnPlayerRegister(playerid, inputtext);

If you need other code just ask what code you need
Reply
#5

All this:
pawn Код:
INI_WriteFloat(File,"Pos X", PlayerInfo[playerid][PosX]);
     INI_WriteFloat(File,"Pos Y", PlayerInfo[playerid][PosY]);
     INI_WriteFloat(File,"Pos Z", PlayerInfo[playerid][PosZ]);
     INI_WriteFloat(File,"Pos A", PlayerInfo[playerid][PosA]);
Must be made without Spaces in it. This is for all Values. No spaces in the "Pos x" or anything when writing to a file.

Then try again :P (remember to change the read too)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)