[HELP] How to use Y_INI
#1

Hey guys, ive googeled a lot on this already, and also used SA-MP forums to search for it, but i have no idea how to read data out of a file putting it in to a string.

All i find are very weird functions like
Код:
INI:myini[](name[], value[])
{
    INI_String("a", gA);
    INI_String("b", gB);
    INI_String("c", gC);
    return 0; // This is now required.
}
INI_Load("myini.ini");
But what to do i need to do with that ?, where do i need to place it ? is it even a function ?,what if i put the file in a subfolder, is it then still INI:filename ?, and why can dini do it with 1 line of text and y_ini not ?
I hope someone can be a bit more clear to me how to actually get data from a file, because writing data seems to be very easy in Y_INI, but reading it is very weird/unclear.

I have the following function that i would like to have converted, so please give me an example how to do this with Y_INI:

Example with DINI:
pawn Код:
stock LoadVehicles()
{
    new file[96];
    for(new i = 0;i<MAX_LOADED_VEHICLES;i++)
    {
        format(file,sizeof file,"/PrivateVehicles/Vehicles/%i.ini",i);
        if(dini_Exists(file) )
        {
            VehicleInfo[i][Model] = dini_Int(file,"Model");
            VehicleInfo[i][X] = dini_Float(file,"X");
            VehicleInfo[i][Y] = dini_Float(file,"Y");
            VehicleInfo[i][Z] = dini_Float(file,"Z");
            VehicleInfo[i][Rot] = dini_Float(file,"Rot");
            VehicleInfo[i][Color1] = dini_Int(file,"Color1");
            VehicleInfo[i][Color2] = dini_Int(file,"Color2");
            format(VehicleInfo[i][Plate],32,"%s",dini_Get(file,"Plate"));
            format(VehicleInfo[i][Owner],MAX_PLAYER_NAME,"%s",dini_Get(file,"Owner"));
            VehicleInfo[i][Lender] = -1;

            VehicleInfo[i][Id] = AddStaticVehicle(VehicleInfo[i][Model],VehicleInfo[i][X],VehicleInfo[i][Y],VehicleInfo[i][Z],VehicleInfo[i][Rot],VehicleInfo[i][Color1],VehicleInfo[i][Color2]);
            SetVehicleNumberPlate(VehicleInfo[i][Id],VehicleInfo[i][Plate]);
            SetVehicleToRespawn(VehicleInfo[i][Id]);
            loaded_vehicles++;

        }
    }
    return 1;
}
Reply


Messages In This Thread
[HELP] How to use Y_INI - by gamer931215 - 06.03.2011, 03:43
Re: [HELP] How to use Y_INI - by gamer931215 - 06.03.2011, 09:53
Re: [HELP] How to use Y_INI - by gamer931215 - 06.03.2011, 11:14

Forum Jump:


Users browsing this thread: 3 Guest(s)