Help with load info from ini file that FS created
#1

Hello i am using AVS system and i want to load from the GM the vehicle owner name for exmaple
everytime i try another thing and it doesnt help that what i wrote




LoadAVSVehicles()
{
new File:handle, count;
new filename[64], line[256];
for(new i=1; i < MAX_VEHICLES; i++)
{
format(filename, sizeof(filename), VEHICLE_FILE_PATH "v%d.ini", i);
if(!fexist(filename)) continue;
handle = fopen(filename, io_read);
while(fread(handle, line))
{
StripNL(line);
if(!line[0]) continue;
if(strcmp(line, "Created=", false, == 0) VehicleCreated[i] = strval(line[8]);
else if(strcmp(line, "Model=", false, 6) == 0) VehicleModel[i] = strval(line[6]);
else if(strcmp(line, "Pos=", false, 4) == 0) sscanf(line[4], "p,ffff", VehiclePos[i][0], VehiclePos[i][1],
VehiclePos[i][2], VehiclePos[i][3]);
else if(strcmp(line, "Colors=", false, 7) == 0) sscanf(line[7], "p,dd", VehicleColor[i][0], VehicleColor[i][1]);
else if(strcmp(line, "Interior=", false, 9) == 0) VehicleInterior[i] = strval(line[9]);
else if(strcmp(line, "VirtualWorld=", false, 13) == 0) VehicleWorld[i] = strval(line[13]);
else if(strcmp(line, "Owner=", false, 6) == 0) strmid(VehicleOwner[i], line, 6, sizeof(line));
else if(strcmp(line, "NumberPlate=", false, 12) == 0) strmid(VehicleNumberPlate[i], line, 12, sizeof(line));
else if(strcmp(line, "Value=", false, 6) == 0) VehicleValue[i] = strval(line[6]);//
else if(strcmp(line, "Trunk1=", false, 7) == 0) sscanf(line[7], "p,dd", VehicleTrunk[i][0][0], VehicleTrunk[i][0][1]);
else if(strcmp(line, "Trunk2=", false, 7) == 0) sscanf(line[7], "p,dd", VehicleTrunk[i][1][0], VehicleTrunk[i][1][1]);
else if(strcmp(line, "Trunk3=", false, 7) == 0) sscanf(line[7], "p,dd", VehicleTrunk[i][2][0], VehicleTrunk[i][2][1]);
else if(strcmp(line, "Trunk4=", false, 7) == 0) sscanf(line[7], "p,dd", VehicleTrunk[i][3][0], VehicleTrunk[i][3][1]);
else if(strcmp(line, "Trunk5=", false, 7) == 0) sscanf(line[7], "p,dd", VehicleTrunk[i][4][0], VehicleTrunk[i][4][1]);
else if(strcmp(line, "Mod0=", false, 5) == 0) VehicleMods[i][0] = strval(line[5]);
else if(strcmp(line, "Mod1=", false, 5) == 0) VehicleMods[i][1] = strval(line[5]);
else if(strcmp(line, "Mod2=", false, 5) == 0) VehicleMods[i][2] = strval(line[5]);
else if(strcmp(line, "Mod3=", false, 5) == 0) VehicleMods[i][3] = strval(line[5]);
else if(strcmp(line, "Mod4=", false, 5) == 0) VehicleMods[i][4] = strval(line[5]);
else if(strcmp(line, "Mod5=", false, 5) == 0) VehicleMods[i][5] = strval(line[5]);
else if(strcmp(line, "Mod6=", false, 5) == 0) VehicleMods[i][6] = strval(line[5]);
else if(strcmp(line, "Mod7=", false, 5) == 0) VehicleMods[i][7] = strval(line[5]);
else if(strcmp(line, "Mod8=", false, 5) == 0) VehicleMods[i][8] = strval(line[5]);
else if(strcmp(line, "Mod9=", false, 5) == 0) VehicleMods[i][9] = strval(line[5]);
else if(strcmp(line, "Mod10=", false, 6) == 0) VehicleMods[i][10] = strval(line[6]);
else if(strcmp(line, "Mod11=", false, 6) == 0) VehicleMods[i][11] = strval(line[6]);
else if(strcmp(line, "Mod12=", false, 6) == 0) VehicleMods[i][12] = strval(line[6]);
else if(strcmp(line, "Mod13=", false, 6) == 0) VehicleMods[i][13] = strval(line[6]);
else if(strcmp(line, "Paintjob=", false, 9) == 0) VehiclePaintjob[i] = strval(line[9]);
//
else if(strcmp(line, "Insurance=", false, 10) == 0) VehInsurance[i] = strval(line[10]);
//VehDestroy
else if(strcmp(line, "VehDestroy=", false, 10) == 0) VehDestroy[i] = strval(line[11]);
}
fclose(handle);
if(VehicleCreated[i]) count++;
}
printf(" Loaded %d vehicles", count);
}





and the info here doesnt load ..
Reply
#2

Quote:
Originally Posted by king4you
Посмотреть сообщение
Hello i am using AVS system and i want to load from the GM the vehicle owner name for
pawn Код:
format(filename, sizeof(filename), VEHICLE_FILE_PATH "v%d.ini", i);
        if(!fexist(filename)) continue;
        handle = fopen(filename, io_read);
        while(fread(handle, line))
You're checking if filename does NOT exist, and if it doesn't exist you continue;.
Wouldn't it be smarter if you only continue when the file you want to load exists?
Reply
#3

format(filename, sizeof(filename), VEHICLE_FILE_PATH "v%d.ini", i);
continue;
handle = fopen(filename, io_read);
while(fread(handle, line))

Thats what i did now and still doesnt work it doesnt load info from ini
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)