SII Problem
#1

Hello, I got a little problem using the file system: SII

pawn Код:
public OnPlayerConnect(playerid)
{
    new file[200],
        name[24];
   
    format(file,sizeof(file),"LuxKnack/TeamStats/%s.ini",name);
    INI_Open(file);
    pKMs[playerid] = INI_ReadInt("KMDriven");
    INI_Close();
pawn Код:
public CountDistance(vehicleid)
{
    new string[69];
    for(new i = 0;i < MAX_PLAYERS;i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            if(GetVehicleSpeed(GetPlayerVehicleID(i)) > 5)
            {
                pKMs[i] += floatround(floatdiv(GetVehicleSpeed(vehicleid), 236.0));
                format(string,sizeof(string),"~g~KMs: ~r~%d",pKMs[i]);
                pInfo[i][pTotalDist] = pKMs[i];
            }
        }
    }
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[200],
        name[MAX_PLAYER_NAME];
   
    format(file,sizeof(file),"LuxKnack/TeamStats/%s.ini",name);//Formating the var to the selected house directory.
    INI_Open(file);//Opening the file with SII.
    INI_WriteInt("KMDriven", pKMs[playerid]);
    INI_Save();//Saving file with SII.
    INI_Close();
but this just doesn't work...
in the directory there are 3 files created:
%s
'empty name'
and
'Playername' (wich is correct)
when I open that file it says kilometers driven: 0,
while I already drove 4 kms, and I checked it with a selfmade command to check the pKMs variable...
any help??
Reply
#2

Looks like you forgot to get player's name?

pawn Код:
public OnPlayerConnect(playerid)
{
    new file[200],
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"LuxKnack/TeamStats/%s.ini",name);
    INI_Open(file);
    pKMs[playerid] = INI_ReadInt("KMDriven");
    INI_Close();
Same for OnPlayerDisconnect..
Reply
#3

Thanks it works!
and is there a little stock that I can make so I do not have to do the path thing over and over?
so I can just do this:
INI_open(TeamFile)?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)