[HELP] How to use Y_INI
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
pawn Код:
#include <YSI\y_stringhash>
#include <YSI\y_utils>

forward VehicleLoad(vid, name[], value[]);

public VehicleLoad(vid, name[], value[])
{
    // Switch on strings (requires y_stringhash).  These are case-insensitive.
    // Note that this requires the LATEST version of y_stringhash from:
    // http://pastebin.com/xhNGu8q7
    switch (YHash(name))
    {
        case _I<model>:
        {
            // Save the model data.
            VehicleInfo[vid][Model] = strval(value);
        }
        case _I<x>:
        {
            VehicleInfo[vid][X] = floatstr(value);
        }
        case _I<y>:
        {
            VehicleInfo[vid][Y] = floatstr(value);
        }
        case _I<z>:
        {
            VehicleInfo[vid][Z] = floatstr(value);
        }
        case _I<rot>:
        {
            VehicleInfo[vid][Rot] = floatstr(value);
        }
        case _I<color1>:
        {
            VehicleInfo[vid][Color1] = strval(value);
        }
        case _I<color2>:
        {
            VehicleInfo[vid][Color2] = strval(value);
        }
        case _I<plate>:
        {
            strcpy(VehicleInfo[vid][Plate], value, 32);
        }
        case _I<owner>:
        {
            strcpy(VehicleInfo[vid][Owner], value, MAX_PLAYER_NAME);
        }
    }
    return 0; // This is now required.
}

stock LoadVehicles()
{
    new file[96];
    for (new i = 0;i<MAX_LOADED_VEHICLES;i++)
    {
        // Get the filename.
        format(file,sizeof file,"/PrivateVehicles/Vehicles/%i.ini",i);
        // Load the file, always using the "VehicleLoad" function, not one
        // based on the file's name.  Also, pass the vehicle ID.
        INI_ParseFile(file, "VehicleLoad", .bExtra = true, .extra = i);
        // The other bits.
        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;
}
Comments are in the file. And it's more complex to use than dini because it's more powerful and faster.
Now thats a good example!, thanks ******
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: 1 Guest(s)