Problem with "stock SaveRaceRecords()"
#1

Hi
I'm making a racing record system for my racing system in my gm.
Now I do not create the races in a sciptfile, I add the checkpoints in the GM.
That's because the tut didn't explain how to do it via the sciptfile folder...

So now I want to add racing records I found that there's no other way than doing this via the scriptfile folder.
So I came up with this code:

pawn Код:
public OnGameModeExit()
{
//blabla
    SaveRaceRecords();
    return 1;
}
pawn Код:
stock SaveRaceRecords()
{
    for(new x; x<currentraceslot; x++) //current race slot is all the races in the system
    {
        new file[64], RaceName[100];
        format(RaceName, sizeof RaceName, "%s", RaceInfo[x][racename]); //RaceInfo[x][racename] holds the name
        format(file, sizeof file, "Races/%s.ini", RaceName); //A file for every single race name under the folder 'Races'

        if (INI_Open(file))
        {
            INI_WriteInt("Record", RaceInfo[x][record]);
            INI_Save();
            INI_Close();
        }
    }
    return 1;
}
But when I open and close my GM nothing gets written in the requested folder...
And yes I have created a folder called Races in the scriptfiles...

Any help?
Reply
#2

Are the actual file/s being created before checking if they exist? Does not seam like it...show us the rest of the code.
Reply
#3

Fixed it, added this:
pawn Код:
stock LoadRaceRecords()
{
    for(new x; x<currentraceslot; x++)
    {
        new file[64],RaceName[100];
        format(RaceName, 100, "%s", RaceInfo[x][racename]);
        format(file,sizeof file,"Races/%s.ini",RaceName);
        INI_Open(file);
        RaceInfo[x][record] = INI_ReadInt("Record");
        INI_Save();
        INI_Close();
    }
    return 1;
}
However, the files are created, but the int isn't written now...

'Inting' happens here:

pawn Код:
new country = CreateRace("Country", 160000, 600); //OnGameModeInit
pawn Код:
stock CreateRace(RaceName[], Prize, RaceTimeout, RaceVehicle = -1)
{
    format(RaceInfo[currentraceslot][racename], 100, "%s", RaceName);

    //RaceInfo[currentraceslot][prize] = Prize;
    RaceInfo[currentraceslot][record] = RaceTimeout;
    //RaceInfo[currentraceslot][racetimeout] = RaceTimeout;
    //RaceInfo[currentraceslot][racevehicle] = RaceVehicle;
    //RaceInfo[currentraceslot][racerunning] = false;
    //RaceInfo[currentraceslot][racejoinable] = false;
   
    return currentraceslot, currentraceslot ++;
}
Reply
#4

FIXED: I called LoadRaceRecords before "curentraceslot" was set
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)