sqlite weird problem on readin from a database.
#1

Hey guys. So I'm finally getting the hang of this SQLite dohicky after much frustration and have a wee bit of a weird problem. Heres my load process I'm using for vehicles...

pawn Код:
stock LoadVehicles()
{
    new string[TSYS_MAX_STRING_SIZE],DBResult: Result,vehicleid;
    if(VSYS_Init == 1) {
        for(new varID = 0;varID<TSYS_V_LIMIT;varID++) {
            format(string,sizeof(string),"SELECT * FROM `VEHICLES` WHERE `ID` = '%d' COLLATE NOCASE",varID);
            Result = db_query(TSYS_Database, string);
            db_get_field_assoc(Result, "VALID", string, sizeof(string));
            if(strval(string) == 1) {
                db_get_field_assoc(Result, "VINFO", string, sizeof(string));
                db_free_result(Result);
                if(sscanf(string,"p<,>iffffiiiiiiiiiiiiiiiiiiiiiiiis[56]s[56]ii",
                VehicleSetupInfo[varID][model],
                VehicleSetupInfo[varID][x_spawn],
                VehicleSetupInfo[varID][y_spawn],
                VehicleSetupInfo[varID][z_spawn],
                VehicleSetupInfo[varID][za_spawn],
                VehicleSetupInfo[varID][color_1],
                VehicleSetupInfo[varID][color_2],
                VehicleSetupInfo[varID][vehiclecost],
                VehicleSetupInfo[varID][bought],
                VehicleSetupInfo[varID][secure],
                VehicleSetupInfo[varID][asecure],
                VehicleSetupInfo[varID][buybar],
                VehicleSetupInfo[varID][mod1],
                VehicleSetupInfo[varID][mod2],
                VehicleSetupInfo[varID][mod3],
                VehicleSetupInfo[varID][mod4],
                VehicleSetupInfo[varID][mod5],
                VehicleSetupInfo[varID][mod6],
                VehicleSetupInfo[varID][mod7],
                VehicleSetupInfo[varID][mod8],
                VehicleSetupInfo[varID][mod9],
                VehicleSetupInfo[varID][mod10],
                VehicleSetupInfo[varID][mod11],
                VehicleSetupInfo[varID][mod12],
                VehicleSetupInfo[varID][mod13],
                VehicleSetupInfo[varID][mod14],
                VehicleSetupInfo[varID][mod15],
                VehicleSetupInfo[varID][mod16],
                VehicleSetupInfo[varID][mod17],
                VehicleSetupInfo[varID][owner],
                VehicleSetupInfo[varID][name],
                VehicleSetupInfo[varID][paintjob],
                VehicleSetupInfo[varID][faction])) {
                    print(" ");
                    print("=================================================");
                    format(string,sizeof(string),"Vehicle slot %d has no data (SSCANF FAIL) - skipping...",varID);
                    printf(string);
                    print("=================================================");
                    print(" ");
                }
                else {
                    vehcount++;
                    vehicleid = CreateVehicle(VehicleSetupInfo[varID][model], VehicleSetupInfo[varID][x_spawn], VehicleSetupInfo[varID][y_spawn], VehicleSetupInfo[varID][z_spawn], VehicleSetupInfo[varID][za_spawn], VehicleSetupInfo[varID][color_1], VehicleSetupInfo[varID][color_2],20000);
                    SetVehicleInfo(vehicleid, varID);
                    format(string,sizeof(string),"Vehicle %d (%s) successfully spawned - owner: %s",vehicleid,TSYSVehicleInfo[vehicleid][name],TSYSVehicleInfo[vehicleid][owner]);
                    printf(string);
                    format(string,sizeof(string),"Fuelling Up Vehicle ID: %d / Type: %s", vehicleid, TSYSVehicleInfo[vehicleid][name]);
                    printf(string);
                    ModVehicle(vehicleid);
                    format(string,sizeof(string),"Modding Vehicle ID: %d / Type: %s", vehicleid, TSYSVehicleInfo[vehicleid][name]);
                    printf(string);
                    print("----");
                }
            }
            else {
                print(" ");
                print("=================================================");
                format(string,sizeof(string),"Vehicle slot %d has no data (INVALID) - skipping...",varID);
                printf(string);
                print("=================================================");
                print(" ");
            }
        }
        print(" ");
        print("=================================================");
        printf("End of Vehicle Data");
        format(string,sizeof(string),"%d Vehicles Were Tuned On Server Load!",tuned);
        printf(string);
        format(string,sizeof(string),"%d Vehicles Were Fuelled up On Server Load!",vehcount);
        printf(string);
        print("tAxI's TSYS System Status - 100% - System Ready...");
        print("=================================================");
        print(" ");
    }
    else SetupVehiclesFile();
}
works fine apart from one small thing and for the life of my i cant quite work it out lol.

when it reaches ID 850 or 849, invariably it will give the following readout on the server log...

Код:
[20:37:05] ----
[20:37:05] Vehicle 849 (Sultan) successfully spawned - owner: [null]
[20:37:05] Fuelling Up Vehicle ID: 849 / Type: Sultan
[20:37:05] Modding Vehicle ID: 849 / Type: Sultan
[20:37:05] ----
[20:37:05]  
[20:37:05] =================================================
[20:37:05] Vehicle slot 849 has no data (INVALID) - skipping...
[20:37:05] =================================================
[20:37:05]  
[20:37:05] Vehicle 850 (Primo) successfully spawned - owner: [null]
[20:37:05] Fuelling Up Vehicle ID: 850 / Type: Primo
[20:37:05] Modding Vehicle ID: 850 / Type: Primo
now I'm starting to think I'm not accounting for memory usage or something in my code but I'm freeing the result etc as I thought I should be - can anyone point me in the right direction?

thanks in advance for the help lol

Add: I know the data is in the DB correctly as I can use the browser lite program and simply goto the vehicle info for that line - so no worries there...only problem seems to be on reading the info :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)