y_ini vehicle loading bugged
#1

Big issues when trying to load vehicles.

What works: Model, Colors, Spawn location
What doesn't work: Interior, Lock

In the following image there are 3 cars: Vehicleids 0-2.
Vehicles 0 and 1 are in the correct interior (1), but me and vehicle 2 are in interior 0.
All 3 vehicles appear locked, when only vehicle 2 is supposed to be locked.
Vehicle 0 is supposed to have a Text label for debugging, which is missing.



I am looping each file load in a for loop. Is this causing the files to not load fast enough, causing errors? Can I load the vehicles without creating infinite timers?

Some code for reference:
pawn Код:
//Veh
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(fexist(VPath(i)))
        {
            INI_ParseFile(VPath(i),"LoadVehicle", .bExtra = true, .extra = i);
            AddStaticVehicleEx(vInfo[i][vModel],vInfo[i][vLastX],vInfo[i][vLastY],vInfo[i][vLastZ],vInfo[i][vLastA],vInfo[i][vColor1],vInfo[i][vColor2],-1);
            LinkVehicleToInterior(i, vInfo[i][vInterior]);
            AddVehicleComponent(i, vInfo[i][vPart1]);
            AddVehicleComponent(i, vInfo[i][vPart2]);
            AddVehicleComponent(i, vInfo[i][vPart3]);
            AddVehicleComponent(i, vInfo[i][vPart4]);
            AddVehicleComponent(i, vInfo[i][vPart5]);

            new str[32];
            format(str, sizeof(str), "Vehicleid: %i", i);
            Create3DTextLabel(str, COLOR_WHITE, vInfo[i][vLastX], vInfo[i][vLastY], vInfo[i][vLastZ], 150, 0, 1);

            printf("Vehicleid %i Spawned at last location!", i);
        }
    }

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vInfo[vehicleid][vLocked] == true)
    {
        ClearAnimations(playerid, true);
    }
    return 1;
}

forward LoadVehicle(vehicleid, name[], value[]);
public LoadVehicle(vehicleid, name[], value[])
{
    INI_Int("Model", vInfo[vehicleid][vModel]);
    INI_Int("Color1", vInfo[vehicleid][vColor1]);
    INI_Int("Color2", vInfo[vehicleid][vColor2]);
    INI_Bool("Locked", vInfo[vehicleid][vLocked]);
    INI_Bool("Alarm", vInfo[vehicleid][vAlarm]);
    INI_Int("Paintjob", vInfo[vehicleid][vPaintjob]);
    INI_Int("Fuel", vInfo[vehicleid][vFuel]);
    INI_Float("Health", vInfo[vehicleid][vHealth]);
    INI_String("Owner", vInfo[vehicleid][vOwner], MAX_PLAYER_NAME);
    INI_String("HasKeys", vInfo[vehicleid][vHasKeys], MAX_PLAYER_NAME);
    INI_Float("SpawnX", vInfo[vehicleid][vSpawnX]);
    INI_Float("SpawnY", vInfo[vehicleid][vSpawnY]);
    INI_Float("SpawnZ", vInfo[vehicleid][vSpawnZ]);
    INI_Float("SpawnA", vInfo[vehicleid][vSpawnA]);
    INI_Float("LastX", vInfo[vehicleid][vLastX]);
    INI_Float("LastY", vInfo[vehicleid][vLastY]);
    INI_Float("LastZ", vInfo[vehicleid][vLastZ]);
    INI_Float("LastA", vInfo[vehicleid][vLastA]);
    INI_Int("StockPrice", vInfo[vehicleid][vStockPrice]);
    INI_Int("Part1", vInfo[vehicleid][vPart1]);
    INI_Int("Part2", vInfo[vehicleid][vPart2]);
    INI_Int("Part3", vInfo[vehicleid][vPart3]);
    INI_Int("Part4", vInfo[vehicleid][vPart4]);
    INI_Int("Part5", vInfo[vehicleid][vPart5]);
    INI_Bool("Dead", vInfo[vehicleid][vDead]);
    INI_Int("Interior", vInfo[vehicleid][vInterior]);
    return 1;
}
And the vehicle files:

0
Quote:

[Vehicle Data]
Model = 426
Color1 = 2
Color2 = 2
Locked = false
Alarm = false
Paintjob = 0
Fuel = 100
Health = 1000.000000
Owner = AngelPine
HasKeys = AngelPine
SpawnX = -1900.199951
SpawnY = -2228.300048
SpawnZ = 24.435630
SpawnA = 46.000000
LastX = -1900.199951
LastY = -2228.300048
LastZ = 24.435630
LastA = 46.000000
StockPrice = 20000
Part1 = 0
Part2 = 0
Part3 = 0
Part4 = 0
Part5 = 0
Dead = false
Interior = 1

1
Quote:

[Vehicle Data]
Model = 429
Color1 = 3
Color2 = 1
Locked = false
Alarm = false
Paintjob = 0
Fuel = 100
Health = 1000.000000
Owner = AngelPine
HasKeys = AngelPine
SpawnX = -1900.199951
SpawnY = -2234.600097
SpawnZ = 24.446840
SpawnA = 46.000000
LastX = -1900.199951
LastY = -2234.600097
LastZ = 24.446840
LastA = 46.000000
StockPrice = 20000
Part1 = 0
Part2 = 0
Part3 = 0
Part4 = 0
Part5 = 0
Dead = false
Interior = 1

2
Quote:

[Vehicle Data]
Model = 598
Color1 = 186
Color2 = 1
Locked = true
Alarm = false
Paintjob = 0
Fuel = 100
Health = 1000.000000
Owner = AngelPine
HasKeys = AngelPine
SpawnX = -1899.900390
SpawnY = -2241.099609
SpawnZ = 24.483629
SpawnA = 46.000000
LastX = -1899.900390
LastY = -2241.099609
LastZ = 24.483629
LastA = 46.000000
StockPrice = 20000
Part1 = 0
Part2 = 0
Part3 = 0
Part4 = 0
Part5 = 0
Dead = false
Interior = 1

Reply
#2

Try to load the 3 vehicles individually (0, 1, 2) for bug testing purposes. If they load fine, it's most likely an error somewhere in the loop.
Reply
#3

Quote:
Originally Posted by rangerxxll
Посмотреть сообщение
Try to load the 3 vehicles individually (0, 1, 2) for bug testing purposes. If they load fine, it's most likely an error somewhere in the loop.
Will do, going to test.

EDIT: After testing, I learned that the lock and interior change the vehicle before it, meaning vehicle 1 changed the stats of veh 0, veh 2 changed veh 1.

EDIT2: After removing 0 from the saving and loading loops, the vehicles appear to be working fine now. Thanks bro.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)