SA-MP Forums Archive
My problems with Y_INI - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: My problems with Y_INI (/showthread.php?tid=430499)



My problems with Y_INI - dusk - 14.04.2013

Here is my parse file
pawn Код:
if(fexist(GetPath(playerid)))
        {
            new string[80];
            format(string,sizeof(string),"Sveiki sugrįћę %s, jūs automatiљkai buvote prijungtas",Name);
            SendClientMessage(playerid,0xFFFF00FF,string);
            INI_ParseFile(GetPath(playerid),"LoadStats_%s", .bExtra = true, .extra = playerid);
           
        }
Here is my LoadStats:
pawn Код:
forward LoadStats_data(playerid, name[], value[]);
public LoadStats_data(playerid,name[],value[])
{
    new temp[128];
    INI_String("Password",temp,128); format(PlayerInfo[playerid][pPass],sizeof(temp),temp);
    INI_Int("AdminLevel",PlayerInfo[playerid][AdminLevel]);
    INI_Int("XP",PlayerInfo[playerid][XP]);
    INI_Int("Money",PlayerInfo[playerid][Money]);
    INI_Int("Kills",PlayerInfo[playerid][Kills]);
    INI_Int("Deaths",PlayerInfo[playerid][Deaths]);
    SetPlayerScore(playerid,PlayerInfo[playerid][XP]);
    GivePlayerMoney(playerid,PlayerInfo[playerid][Money]);
    printf("Done:pinigai %d",PlayerInfo[playerid][Money]);
    return 1;
}
Well the problem is, it loads "AdminLevel" alright,it loads "XP" aswell, but with money it's different,it just doesn't load it. The printf there prints 0. Although in the file it's not 0

My other problem:
pawn Код:
stock SaveStats(playerid)
{
    new INI:file = INI_Open(GetPath(playerid));
    INI_SetTag(file,"Player's Data");
    INI_WriteInt(file,"AdminLevel",PlayerInfo[playerid][AdminLevel]);
    INI_WriteInt(file,"XP",PlayerInfo[playerid][XP]);
    INI_WriteInt(file,"Money",PlayerInfo[playerid][Money]);
    INI_WriteInt(file,"Kills",PlayerInfo[playerid][Kills]);
    INI_WriteInt(file,"Deaths",PlayerInfo[playerid][Deaths]);
    INI_Close(file);
    return 1;
}
When i use it in my command which uses that function "SaveStats" it outputs this weird warning:
pawn Код:
[10:18:03] [debug] Run time error 4: "Array index out of bounds"
[10:18:03] [debug]  Accessing element at index 14 past array upper bound 12
[10:18:03] [debug] AMX backtrace:
[10:18:03] [debug] #0 000194fc in public cmd_test () from GangWars.amx
[10:18:03] [debug] #1 native CallLocalFunction () [00471e90] from samp-server.exe
[10:18:03] [debug] #2 00000530 in public OnPlayerCommandText () from GangWars.amx
Any feedback will be appreciated


Re: My problems with Y_INI - DiGiTaL_AnGeL - 14.04.2013

In the ini file "money" has a value? And better do like that:
pawn Код:
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));



Re: My problems with Y_INI - dusk - 14.04.2013

Yes it has a value in the file


Respuesta: My problems with Y_INI - Nabeshin - 14.04.2013

The problem is when you load the file, try this:

Код:
INI_Int("Money",PlayerInfo[playerid][Money]);
SetPVarInt(playerid, "Money",PlayerInfo[playerid][Money]);
And you need to assign "Money" as the current player money (you may need GivePlayerMoney and ResetPlayerMoney).


Re: Respuesta: My problems with Y_INI - DiGiTaL_AnGeL - 14.04.2013

Quote:
Originally Posted by Nabeshin
Посмотреть сообщение
The problem is when you load the file, try this:

Код:
INI_Int("Money",PlayerInfo[playerid][Money]);
SetPVarInt(playerid, "Money",PlayerInfo[playerid][Money]);
And you need to assign "Money" as the current player money (you may need GivePlayerMoney and ResetPlayerMoney).
No, this is wrong. It's already for a certain player:
PlayerInfo[playerid][Money]
It's an array with a slot for every player. There's no reason for using pvars.


Re: My problems with Y_INI - dusk - 14.04.2013

Any other ideas?