Save files with y_ini
#1

Hey guys,
I got a problem with saving things to my file. The variables do save in the folder, but they just dont overwrite.
Code:
Money = 0
Score = 0
Admin level = 0
Vip level = 0
RKills = 0
RDeaths = 2
RKD = 0
Kills = 0
Deaths = 3
KD = 0
Commands used = 4
Weapon 0 = 0
Weapon 1 = 9
Weapon 2 = 24
Weapon 3 = 27
Weapon 4 = 32
Weapon 5 = 31
Weapon 6 = 34
Weapon 7 = 0
Weapon 8 = 0
Weapon 9 = 0
Weapon 10 = 0
Weapon 11 = 0
Weapon 0 ammo = 0
Weapon 1 ammo = 1
Weapon 2 ammo = 50
Weapon 3 ammo = 50
Weapon 4 ammo = 200
Weapon 5 ammo = 200
Weapon 6 ammo = 200
Weapon 7 ammo = 0
Weapon 8 ammo = 0
Weapon 9 ammo = 0
Weapon 10 ammo = 0
Weapon 11 ammo = 0
Admin level = 0
Vip level = 0
Commands used = 5
Weapon 0 = 0
Weapon 1 = 9
Weapon 2 = 24
Weapon 3 = 27
Weapon 4 = 32
Weapon 5 = 31
Weapon 6 = 34
Weapon 7 = 0
Weapon 8 = 0
Weapon 9 = 0
Weapon 10 = 0
Weapon 11 = 0
Weapon 0 ammo = 0
Weapon 1 ammo = 1
Weapon 2 ammo = 50
Weapon 3 ammo = 50
Weapon 4 ammo = 200
Weapon 5 ammo = 200
Weapon 6 ammo = 200
Weapon 7 ammo = 0
Weapon 8 ammo = 0
Weapon 9 ammo = 0
Weapon 10 ammo = 0
Weapon 11 ammo = 0
[Data]
Name = Lemmy_Lusion[NL]
Player ip = 83.81.114.223
Password = 246831CF3AF7BBCC90DF6EB37CF791AD3018F6DADD6F8C10B1462632A81A904A08D71865FBCA16D2F672D631F2EE1505121F3D42FE80DE28F07415AFDA961ED
Money = 500
Score = 0
Admin level = 0
Vip level = 0
Commands used = 0
[Kills]
Total kills = 0
Total deaths = 0
Total K/D = 0.000000
LR kills = 0
LR deaths = 0
LR K/D = 0.000000
[Weapons]
Weapon 0 = -1
Weapon 1 = -1
Weapon 2 = -1
Weapon 3 = -1
Weapon 4 = -1
Weapon 5 = -1
Weapon 6 = -1
Weapon 7 = -1
Weapon 8 = -1
Weapon 9 = -1
Weapon 10 = -1
Weapon 11 = -1
Weapon 0 ammo = -1
Weapon 1 ammo = -1
Weapon 2 ammo = -1
Weapon 3 ammo = -1
Weapon 4 ammo = -1
Weapon 5 ammo = -1
Weapon 6 ammo = -1
Weapon 7 ammo = -1
Weapon 8 ammo = -1
Weapon 9 ammo = -1
Weapon 10 ammo = -1
Weapon 11 ammo = -1
As you can see it just saves above the existing lines which will be created when you register.
pawn Code:
forward SaveStats(playerid);
public SaveStats(playerid)
{
    new INI:file = INI_Open(UserPath(playerid));
    INI_WriteInt(file, "Money", PlayerInfo[playerid][pMoney]); printf("Saved money %s", GetName(playerid));
    INI_WriteInt(file, "Score", PlayerInfo[playerid][pScore]); printf("Saved score %s", GetName(playerid));
    INI_WriteInt(file, "Admin level", PlayerInfo[playerid][pAdmin]); printf("Saved admin level %s", GetName(playerid));
    INI_WriteInt(file, "Vip level", PlayerInfo[playerid][pVip]); printf("Saved vip level %s", GetName(playerid));
    INI_WriteInt(file, "RKills", PlayerInfo[playerid][pRKills]); printf("Saved last round kills %s", GetName(playerid));
    INI_WriteInt(file, "RDeaths", PlayerInfo[playerid][pRDeaths]); printf("Saved last round deaths %s", GetName(playerid));
    INI_WriteInt(file, "RKD", PlayerInfo[playerid][pRKd]); printf("Saved last round kd %s", GetName(playerid));
    INI_WriteInt(file, "Kills", PlayerInfo[playerid][pKills]); printf("Saved total kills %s", GetName(playerid));
    INI_WriteInt(file, "Deaths", PlayerInfo[playerid][pDeaths]); printf("Saved total deaths %s", GetName(playerid));
    INI_WriteInt(file, "KD", PlayerInfo[playerid][pKd]); printf("Saved total kd %s", GetName(playerid));
    INI_WriteInt(file, "Commands used", PlayerInfo[playerid][pCMD]); printf("Saved commands used %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 0", WeaponInfo[playerid][pWeapon0]); printf("Saved Weaponinfo0 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 1", WeaponInfo[playerid][pWeapon1]); printf("Saved Weaponinfo1 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 2", WeaponInfo[playerid][pWeapon2]); printf("Saved Weaponinfo2 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 3", WeaponInfo[playerid][pWeapon3]); printf("Saved Weaponinfo3 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 4", WeaponInfo[playerid][pWeapon4]); printf("Saved Weaponinfo4 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 5", WeaponInfo[playerid][pWeapon5]); printf("Saved Weaponinfo5 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 6", WeaponInfo[playerid][pWeapon6]); printf("Saved Weaponinfo6 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 7", WeaponInfo[playerid][pWeapon7]); printf("Saved Weaponinfo7 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 8", WeaponInfo[playerid][pWeapon8]); printf("Saved Weaponinfo8 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 9", WeaponInfo[playerid][pWeapon9]); printf("Saved Weaponinfo9 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 10", WeaponInfo[playerid][pWeapon10]); printf("Saved Weaponinfo10 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 11", WeaponInfo[playerid][pWeapon11]); printf("Saved Weaponinfo11 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 0 ammo", WeaponInfo[playerid][pAmmo0]); printf("Saved Weaponammo0 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 1 ammo", WeaponInfo[playerid][pAmmo1]); printf("Saved Weaponammo1 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 2 ammo", WeaponInfo[playerid][pAmmo2]); printf("Saved Weaponammo2 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 3 ammo", WeaponInfo[playerid][pAmmo3]); printf("Saved Weaponammo3 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 4 ammo", WeaponInfo[playerid][pAmmo4]); printf("Saved Weaponammo4 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 5 ammo", WeaponInfo[playerid][pAmmo5]); printf("Saved Weaponammo5 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 6 ammo", WeaponInfo[playerid][pAmmo6]); printf("Saved Weaponammo6 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 7 ammo", WeaponInfo[playerid][pAmmo7]); printf("Saved Weaponammo7 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 8 ammo", WeaponInfo[playerid][pAmmo8]); printf("Saved Weaponammo8 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 9 ammo", WeaponInfo[playerid][pAmmo9]); printf("Saved Weaponammo9 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 10 ammo", WeaponInfo[playerid][pAmmo10]); printf("Saved Weaponammo10 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 11 ammo", WeaponInfo[playerid][pAmmo11]); printf("Saved Weaponammo11 %s", GetName(playerid));
    INI_Close(file);
    return 1;
}
This will be called when a player disconnects. Anyone know how to make it just overwrite, and not just add new lines above the file?
~Wesley
Reply
#2

Ah didnt know that, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)