dini to y_ini
#1

Hello. I'm trying to convert this code from Ryder's race FS to Y_INI:

pawn Код:
function LoadRace(playerid, rName[])
{
    new
        rFile[256],
        string[256]
    ;
    format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
    if(!dini_Exists(rFile)) return SendClientMessage(playerid, RED, "<!> Race doesn't exist!"), printf("Race \"%s\" doesn't exist!", rName);
    strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
    RaceVehicle = dini_Int(rFile, "vModel");
    RaceType = dini_Int(rFile, "rType");
    TotalCP = dini_Int(rFile, "TotalCP");

    Loop(x, 2)
    {
        format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
        format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
        format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
        format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
    }
    Loop(x, TotalCP)
    {
        format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
        format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
        format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
    }
    return 1;
}
What I have so far:

pawn Код:
function LoadRace(playerid, rName[])
{
    new
        rFile[256],
        string[256]
    ;
    format(rFile, sizeof(rFile), "/rRaceSystem/%s.INI", rName);
    if(!fexist(rFile)) return SendClientMessage(playerid, RED, "<!> Race doesn't exist!"), printf("Race \"%s\" doesn't exist!", rName);
    strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
    INI_ParseFile(rFile, "LoadingRace");
    return 1;
}

forward LoadingRace(name[], value[]);
public LoadingRace(name[], value[])
{
new string1[256], string2[256], string3[256], string4[256];
INI_Int("vModel", RaceVehicle);
INI_Int("rType", RaceType);
INI_Int("TotalCP", TotalCP);
Loop(x, 2)
{
    format(string1, sizeof(string1), "vPosX_%d", x);
    format(string2, sizeof(string2), "vPosY_%d", x);
    format(string3, sizeof(string3), "vPosZ_%d", x);
    format(string4, sizeof(string4), "vAngle_%d", x);
    INI_Float(string1, RaceVehCoords[x][0]);
    INI_Float(string2, RaceVehCoords[x][1]);
    INI_Float(string3, RaceVehCoords[x][2]);
    INI_Float(string4, RaceVehCoords[x][3]);
}
Loop(x, TotalCP)
{
    format(string1, sizeof(string1), "CP_%d_PosX", x);
    format(string2, sizeof(string2), "CP_%d_PosY", x);
    format(string3, sizeof(string3), "CP_%d_PosZ", x);
    INI_Float(string1, CPCoords[x][0]);
    INI_Float(string2, CPCoords[x][1]);
    INI_Float(string3, CPCoords[x][2]);
}
return 0; // This is now required.
}
It reads the Int and Floats fine, and it compiles too, BUT on the first command to start the race after server launch the checkpoint coords are not getting read, so there is just one at 0.0.0. After that it reads them ok. Any help will be appreciated! Here's the .INI file also:

Код:
vModel=522
rType=0
vPosX_0=2516.312255
vPosY_0=2415.553466
vPosZ_0=10.231811
vAngle_0=268.666442
vPosX_1=2516.204833
vPosY_1=2410.724121
vPosZ_1=10.242268
vAngle_1=270.715484
CP_0_PosX=2526.182128
CP_0_PosY=2410.139404
CP_0_PosZ=10.387361
CP_1_PosX=2527.036376
CP_1_PosY=2359.625732
CP_1_PosZ=10.245229
CP_2_PosX=2527.957275
CP_2_PosY=2239.052246
CP_2_PosZ=10.456007
CP_3_PosX=2446.314453
CP_3_PosY=2233.060546
CP_3_PosZ=10.236363
CP_4_PosX=2427.520507
CP_4_PosY=2282.788574
CP_4_PosZ=10.245458
CP_5_PosX=2421.649169
CP_5_PosY=2353.528320
CP_5_PosZ=10.389042
TotalCP=5
Reply
#2

I've put "TotalCP=5" in the INI before CP_x_Pos and it works fine now. Is this how it's supposed to be?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)