SII Help with saving data
#1

I'm having a problem with the SII system(my preferable ini system) with saving data onto the file, I found this issue whilst testing a gamemode, the script says it should save all the data as normal but it doesn't save at all,

Example:

My player has the ryder skin(ID:271) and when I disconnect and then open up the player file it says its still ID: 0(the default skin id for the player data).

After registering, and then logging in(with the correct password), then selecting the skin, it would transfer back to the mansion with the skin you selected(assigned to PlayerInfo[playerid][pSkin] with the ID also) but then when you disconnect it reads on the file:
Code:
Password=******(obviously not going to write my password here lul)
Score=0
Cash=0
Admin=0
Skin=0
SkinChanges=0
Spawned=0
Heres my disonnect code: (Ignore indentation as its copied and pasted, focus on the INI codes)

Code:
public OnPlayerDisconnect(playerid, reason)
{
    if(INI_Open(GetINI(playerid)))
	{
	    INI_WriteInt("Score",PlayerInfo[playerid][pScore]);
    	INI_WriteInt("Cash",GetPlayerMoney(playerid));
    	INI_WriteInt("Admin",PlayerInfo[playerid][pAdmin]);
    	INI_WriteInt("Skin",PlayerInfo[playerid][pSkin]);
    	INI_WriteInt("SkinChanges",PlayerInfo[playerid][pSkinChanges]);
    	INI_WriteInt("Spawned",0);
		INI_Close();
    }
    return 1;
}
Heres my dialog response codes from login and register(Ignore indentation again, focus on the INI codes):
Code:
case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext))
				{
				    SendClientMessage(playerid,COLOR_GREY,#Invalid registeration password.);
                	ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"User account registration","Type in a password combination in order \nto registrate your new account.","Register","Leave");
    			}
                if(INI_Open(GetINI(playerid)))
				{
	                INI_WriteString("Password",inputtext);
	                INI_WriteInt("Score",0);
	                INI_WriteInt("Cash",0);
	                INI_WriteInt("Admin",0);
	                INI_WriteInt("Skin",0);
	                INI_WriteInt("SkinChanges",0);
	                INI_WriteInt("Spawned",0);
	                INI_Save();
	                INI_Close();
	                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"User account log-in","Type in your password combination in order \nto log-in to your account","Login","Leave");
				}
			}
        }
        case DIALOG_LOGIN:
        {
            if(!response) return Kick (playerid);
            if(response)
            {
                if(!strlen(inputtext))
				{
				    SendClientMessage(playerid,COLOR_GREY,#Invalid password combination);
				    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"User account log-in","Type in your password combination in order \nto log-in to your account","Login","Leave");
					return 1;
				}
                if(INI_Open(GetINI(playerid)))
				{
                	INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);
				}
                if(strcmp(inputtext,PlayerInfo[playerid][pPass],false))
				{
				    SendClientMessage(playerid,COLOR_GREY,#Invalid password combination);
                	ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"User account log-in","Type in your password combination in order \nto log-in to your account","Login","Leave");
					return 1;
				}
 				SetPlayerScore(playerid,INI_ReadInt("Score"));
                ResetPlayerMoney(playerid);
                GivePlayerMoney(playerid,INI_ReadInt("Cash"));
                PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                PlayerInfo[playerid][pSkin] = INI_ReadInt("Skin");
                PlayerInfo[playerid][pSkinChanges] = INI_ReadInt("SkinChanges");
                PlayerInfo[playerid][pSpawned] = INI_ReadInt("Spawned");
                INI_Close();
                
  				SetPlayerInterior(playerid,5);
   				SendClientMessage(playerid,COLOR_WHITE,"You have been successfully logged in to your user account.");
    			TogglePlayerSpectating(playerid,false);
    			SpawnPlayer(playerid);
            }
        }
If anyone can help with this or had previous issues like this and resolved it, please help me here. I would greatly appreciate it.
Reply
#2

You're not saving it
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    if(INI_Open(GetINI(playerid)))
    {
        INI_WriteInt("Score",PlayerInfo[playerid][pScore]);
        INI_WriteInt("Cash",GetPlayerMoney(playerid));
        INI_WriteInt("Admin",PlayerInfo[playerid][pAdmin]);
        INI_WriteInt("Skin",PlayerInfo[playerid][pSkin]);
        INI_WriteInt("SkinChanges",PlayerInfo[playerid][pSkinChanges]);
        INI_WriteInt("Spawned",0);
        INI_Save();
        INI_Close();
    }
    return 1;
}
Try this
Reply
#3

Alright thank you, it worked. However, the score saves at 97 for some reason when I disconnect.

Any ideas?
Reply
#4

maybe you set the PlayerInfo[playerid][pScore] to 97 or something? make sure that u have nothing that does that
Reply
#5

try this

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    if(INI_Open(GetINI(playerid)))
    {
        INI_WriteInt("Score",GetPlayerScore(playerid));
        INI_WriteInt("Cash",GetPlayerMoney(playerid));
        INI_WriteInt("Admin",PlayerInfo[playerid][pAdmin]);
        INI_WriteInt("Skin",PlayerInfo[playerid][pSkin]);
        INI_WriteInt("SkinChanges",PlayerInfo[playerid][pSkinChanges]);
        INI_WriteInt("Spawned",0);
        INI_Save();
        INI_Close();
    }
    return 1;
}
Reply
#6

@Rudy_

Thank you bro, helped me out alot. Mad how something so small can cause such an issue, but I appreciate it.
Reply
#7

EDIT: You fixed it.. nvm
Reply
#8

Np, but i'd suggest you to not use SII , it's not useless but Bugged and outdated. use y_ini
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)