Loading vehicle (INI_ParseFile)
#1

pawn Код:
stock LoadPVehicles()
{
    for(new i = 0; i < MAX_BUYABLE_VEH; i++)
    {
        INI_ParseFile(VehicleFile(i), "LoadPlayerVehicle", .bExtra = false);
    }
    return true;
}

forward LoadPlayerVehicle(playerid, name[], value[]);
public LoadPlayerVehicle(playerid, name[], value[])
{
    for(new i = 0; i < MAX_BUYABLE_VEH; i++)
    {
        if(!strcmp(name, "Model"))      vInfo[i][vModel]    = strval(value);
        if(!strcmp(name, "Color1"))     vInfo[i][vColor1]   = strval(value);
        if(!strcmp(name, "Color2"))     vInfo[i][vColor2]   = strval(value);
        if(!strcmp(name, "Price"))      vInfo[i][vPrice]    = strval(value);
        if(!strcmp(name, "Owner"))      SetName(vInfo[i][vOwner], value);
        if(!strcmp(name, "vPosX"))      vInfo[i][vPosX]     = floatstr(value);
        if(!strcmp(name, "vPosY"))      vInfo[i][vPosY]     = floatstr(value);
        if(!strcmp(name, "vPosZ"))      vInfo[i][vPosZ]     = floatstr(value);
        if(!strcmp(name, "vPosA"))      vInfo[i][vPosA]     = floatstr(value);
        if(!strcmp(name, "Plate"))      SetName(vInfo[i][vPlate], value);
        if(!strcmp(name, "PaintJ"))     vInfo[i][vPaintJ]   = strval(value);
        if(!strcmp(name, "Locked"))     vInfo[i][vLocked]   = strval(value);

        // Components loading.
        for(new iMod = 0; iMod < MAX_VEH_MODS; iMod++)
        {
            new string[32];
            format(string, sizeof(string), "vMod%d", iMod);
            if(!strcmp(name, string))SetPVarString(playerid, string, vMods[i][iMod]);
        }

        new vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
        SetVehicleNumberPlate(vCarID, vInfo[i][vPlate]);
        ChangeVehiclePaintjob(vCarID, vInfo[i][vPaintJ]);

        // Components adding.
        for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
        {
            if(vMods[vCarID][iMod] > 0)
            {
                AddVehicleComponent(vCarID, vMods[vCarID][iMod]);
            }
        }

        OwnedVeh(vCarID) = i;
        Total_Veh_Created++;
        printf("[VehSystem] A total of: \"%d\" vehicle(s) were loaded!", Total_Veh_Created);
    }
    return true;
}
Not creating, vehicle.. obviously.. not reading INI_ParseFile, not obviously where's an error for me. I don't know i've a problem with loading files like that using Y_Ini, but i prefer this saving/loading type.

Thank you, guys!
Reply
#2

INI_ParseFile(VehicleFile(i), "LoadPlayerVehicle", .bExtra = true, .extra = playerid);

stock LoadPVehicles()
{
for(new i = 0; i < MAX_BUYABLE_VEH; i++)
{
INI_ParseFile(VehicleFile(i), "LoadPlayerVehicle", .bExtra = false);
}
return true;
}

You load player vehicles.. but you dont pass the id of the player.. so

change INI_ParseFile like i've do above and add "playerid" arg to stock function
Reply
#3

I've removed it specially, because i need to declare playerid.. and don't know how and FOR what..?

Make an loop for playerid?..

edit://
I mean.. i using this function in Init callback.. that's a problem.
Reply
#4

Sorry, for double post but my work just stopped and won't move right now.. please, anyone?
Reply
#5

Try this:

pawn Код:
stock LoadPVehicles()
{
    for(new i = 0; i < MAX_BUYABLE_VEH; i++)
    {
        INI_ParseFile(VehicleFile(i), "LoadPlayerVehicle", .bExtra = true, .extra = i);
    }
    return true;
}

forward LoadPlayerVehicle(id, name[], value[]);
public LoadPlayerVehicle(id, name[], value[])
{
   
    if(!strcmp(name, "Model"))      vInfo[i][vModel]    = strval(value);
    if(!strcmp(name, "Color1"))     vInfo[i][vColor1]   = strval(value);
    if(!strcmp(name, "Color2"))     vInfo[i][vColor2]   = strval(value);
    if(!strcmp(name, "Price"))      vInfo[i][vPrice]    = strval(value);
    if(!strcmp(name, "Owner"))      SetName(vInfo[i][vOwner], value);
    if(!strcmp(name, "vPosX"))      vInfo[i][vPosX]     = floatstr(value);
    if(!strcmp(name, "vPosY"))      vInfo[i][vPosY]     = floatstr(value);
    if(!strcmp(name, "vPosZ"))      vInfo[i][vPosZ]     = floatstr(value);
    if(!strcmp(name, "vPosA"))      vInfo[i][vPosA]     = floatstr(value);
    if(!strcmp(name, "Plate"))      SetName(vInfo[i][vPlate], value);
    if(!strcmp(name, "PaintJ"))     vInfo[i][vPaintJ]   = strval(value);
    if(!strcmp(name, "Locked"))     vInfo[i][vLocked]   = strval(value);

    // Components loading.
    for(new iMod = 0; iMod < MAX_VEH_MODS; iMod++)
    {
        new string[32];
        format(string, sizeof(string), "vMod%d", iMod);
        if(!strcmp(name, string))SetPVarString(playerid, string, vMods[i][iMod]);
    }

    new vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
    SetVehicleNumberPlate(vCarID, vInfo[i][vPlate]);
    ChangeVehiclePaintjob(vCarID, vInfo[i][vPaintJ]);

    // Components adding.
    for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
    {
        if(vMods[vCarID][iMod] > 0)
        {
            AddVehicleComponent(vCarID, vMods[vCarID][iMod]);
        }
    }

    OwnedVeh(vCarID) = i;
    Total_Veh_Created++;
    printf("[VehSystem] A total of: \"%d\" vehicle(s) were loaded!", Total_Veh_Created
   
    return true;
}
You don't need to use 2 loops and also the playerid argument.
Reply
#6

You mean 'i' argument, not 'id' as i think?

Код:
[21:43:05] [VehSystem] A total of: "1" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "2" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "3" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "4" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "5" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "6" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "7" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "8" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "9" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "10" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "11" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "12" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "13" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "14" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "15" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "16" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "17" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "18" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "19" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "20" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "21" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "22" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "23" vehicle(s) were loaded!
[21:43:05] [VehSystem] A total of: "24" vehicle(s) were loaded!
Code:
pawn Код:
forward LoadPlayerVehicle(i, name[], value[]);
public LoadPlayerVehicle(i, name[], value[])
{

    if(!strcmp(name, "Model"))      vInfo[i][vModel]    = strval(value);
    if(!strcmp(name, "Color1"))     vInfo[i][vColor1]   = strval(value);
    if(!strcmp(name, "Color2"))     vInfo[i][vColor2]   = strval(value);
    if(!strcmp(name, "Price"))      vInfo[i][vPrice]    = strval(value);
    if(!strcmp(name, "Owner"))      SetName(vInfo[i][vOwner], value);
    if(!strcmp(name, "vPosX"))      vInfo[i][vPosX]     = floatstr(value);
    if(!strcmp(name, "vPosY"))      vInfo[i][vPosY]     = floatstr(value);
    if(!strcmp(name, "vPosZ"))      vInfo[i][vPosZ]     = floatstr(value);
    if(!strcmp(name, "vPosA"))      vInfo[i][vPosA]     = floatstr(value);
    if(!strcmp(name, "Plate"))      SetName(vInfo[i][vPlate], value);
    if(!strcmp(name, "PaintJ"))     vInfo[i][vPaintJ]   = strval(value);
    if(!strcmp(name, "Locked"))     vInfo[i][vLocked]   = strval(value);

    // Components loading.
    for(new iMod = 0; iMod < MAX_VEH_MODS; iMod++)
    {
        new string[32];
        format(string, sizeof(string), "vMod%d", iMod);
        //if(!strcmp(name, string))SetPVarString(playerid, string, vMods[i][iMod]);
    }

    new vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
    SetVehicleNumberPlate(vCarID, vInfo[i][vPlate]);
    ChangeVehiclePaintjob(vCarID, vInfo[i][vPaintJ]);

    // Components adding.
    for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
    {
        if(vMods[vCarID][iMod] > 0)
        {
            AddVehicleComponent(vCarID, vMods[vCarID][iMod]);
        }
    }

    OwnedVeh(vCarID) = i;
    Total_Veh_Created++;
    printf("[VehSystem] A total of: \"%d\" vehicle(s) were loaded!", Total_Veh_Created);

    return true;
}
Reply
#7

Use this code then.

pawn Код:
stock LoadPVehicles()
{
    for(new i = 0; i < MAX_BUYABLE_VEH; i++)
    {
        INI_ParseFile(VehicleFile(i), "LoadPlayerVehicle", .bExtra = true, .extra = i);
    }
    printf("[VehSystem] A total of: \"%d\" vehicle(s) were loaded!", Total_Veh_Created);

    return true;
}

forward LoadPlayerVehicle(id, name[], value[]);
public LoadPlayerVehicle(id, name[], value[])
{
   
    if(!strcmp(name, "Model"))      vInfo[i][vModel]    = strval(value);
    if(!strcmp(name, "Color1"))     vInfo[i][vColor1]   = strval(value);
    if(!strcmp(name, "Color2"))     vInfo[i][vColor2]   = strval(value);
    if(!strcmp(name, "Price"))      vInfo[i][vPrice]    = strval(value);
    if(!strcmp(name, "Owner"))      SetName(vInfo[i][vOwner], value);
    if(!strcmp(name, "vPosX"))      vInfo[i][vPosX]     = floatstr(value);
    if(!strcmp(name, "vPosY"))      vInfo[i][vPosY]     = floatstr(value);
    if(!strcmp(name, "vPosZ"))      vInfo[i][vPosZ]     = floatstr(value);
    if(!strcmp(name, "vPosA"))      vInfo[i][vPosA]     = floatstr(value);
    if(!strcmp(name, "Plate"))      SetName(vInfo[i][vPlate], value);
    if(!strcmp(name, "PaintJ"))     vInfo[i][vPaintJ]   = strval(value);
    if(!strcmp(name, "Locked"))     vInfo[i][vLocked]   = strval(value);

    // Components loading.
    for(new iMod = 0; iMod < MAX_VEH_MODS; iMod++)
    {
        new string[32];
        format(string, sizeof(string), "vMod%d", iMod);
        if(!strcmp(name, string))SetPVarString(playerid, string, vMods[i][iMod]);
    }

    new vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
    SetVehicleNumberPlate(vCarID, vInfo[i][vPlate]);
    ChangeVehiclePaintjob(vCarID, vInfo[i][vPaintJ]);

    // Components adding.
    for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
    {
        if(vMods[vCarID][iMod] > 0)
        {
            AddVehicleComponent(vCarID, vMods[vCarID][iMod]);
        }
    }

    OwnedVeh(vCarID) = i;
    Total_Veh_Created++;
   
    return 1;
}
Reply
#8

You've removed my 'playerid' argument from "LoadPlayerVehicle".. but i need it for SetPVarString. It's doesn't makes sense..

Screenshot - http://www.bankfotek.pl/image/1298995.jpeg
Reply
#9

3rd page, guys. Sorry for double, i need it..
Reply
#10

4th page.. Everyone.. anyone... please? I'm trying to do this by myself but no results.. please..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)