My problems with Y_INI
#1

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
Reply
#2

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

Yes it has a value in the file
Reply
#4

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).
Reply
#5

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.
Reply
#6

Any other ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)