SQLite vehicle database not saving
#1

My vehicle system saves through SQLite, the only problem is that it doesn't actually save. I can't figure out what the problem with it is, so I'm hoping that someone can help me out. I'm going to put my SaveVehicle and LoadVehicles stock down below. If you need anymore information on it then just ask.

pawn Код:
stock SaveVehicle(sqlid)
{
    new query[1500], idx = GetVIndex(sqlid);
    format(query, sizeof(query), "UPDATE vehicles SET model = '%d' , color1 = '%d' , color2 = '%d' , groupid = '%d' , jobid = '%d' , owner = '%s' , vname = '%s', respawn = '%d', x = '%f', y = '%f', z = '%f', angle = '%f'",
    Veh[idx][Model], Veh[idx][Color1], Veh[idx][Color2], Veh[idx][Group], Veh[idx][Job], Veh[idx][Owner], Veh[idx][VName] ,Veh[idx][Respawn], Veh[idx][vX], Veh[idx][vY], Veh[idx][vZ], Veh[idx][vAngle]);
   
    format(query, sizeof(query), "%s,interior = '%d', virtualworld = '%d', plate = '%s', mod0 = '%d', mod1 = '%d', mod2 = '%d', mod3 = '%d', mod4 = '%d', mod5 = '%d', mod6 = '%d', mod7 = '%d', mod8 = '%d', mod9 = '%d'",
    query ,Veh[idx][vInt], Veh[idx][vVWorld], Veh[idx][Plate], Veh[idx][Mod0], Veh[idx][Mod1], Veh[idx][Mod2], Veh[idx][Mod3], Veh[idx][Mod4], Veh[idx][Mod5], Veh[idx][Mod6], Veh[idx][Mod7], Veh[idx][Mod8], Veh[idx][Mod9]);
   
    format(query, sizeof(query), "%s, mod10 = '%d', mod11 = '%d', mod12 = '%d', mod13 = '%d', paintjob = '%d', weapon1 = '%d', weapon2 = '%d', weapon3 = '%d', vip = '%d', lockstate = '%d', health = '%f', spawnstate = '%d', fuel = '%d'",
    query, Veh[idx][Mod10], Veh[idx][Mod11], Veh[idx][Mod12], Veh[idx][Mod13], Veh[idx][PaintJob], Veh[idx][Weapons][0], Veh[idx][Weapons][1], Veh[idx][Weapons][2], Veh[idx][VIP], Veh[idx][lockState], Veh[idx][vHealth],Veh[idx][spawnState],Veh[idx][Fuel]);
   
    format(query, sizeof(query), "%s WHERE sqlid = '%d'", query ,sqlid);

    db_query(vehicle_db, query);
    return query;
}
pawn Код:
stock LoadVehicles()
{
    new DBResult:result, count, field[24];
    result = db_query(vehicle_db, "SELECT * FROM vehicles");
    count = db_num_rows(result);
    while(count != 0)
    {
        db_get_field_assoc(result,"sqlid", field , 24);
       
        Veh[vehCount][SQLID] = strval(field);

        db_get_field_assoc(result,"model",field , 24);
        Veh[vehCount][Model] = strval(field);

        db_get_field_assoc(result,"color1", field , 24);
        Veh[vehCount][Color1] = strval(field);

        db_get_field_assoc(result,"color2",field , 24);
        Veh[vehCount][Color2] = strval(field);

        db_get_field_assoc(result,"groupid",field , 24);
        Veh[vehCount][Group] = strval(field);

        db_get_field_assoc(result,"jobid",field , 24);
        Veh[vehCount][Job] = strval(field);

        db_get_field_assoc(result,"x", field , 24);
        Veh[vehCount][vX] = floatstr(field);

        db_get_field_assoc(result,"y", field , 24);
        Veh[vehCount][vY] = floatstr(field);

        db_get_field_assoc(result,"z",field , 24);
        Veh[vehCount][vZ] = floatstr(field);

        db_get_field_assoc(result,"angle",field , 24);
        Veh[vehCount][vAngle] = floatstr(field);

        db_get_field_assoc(result,"interior",field , 24);
        Veh[vehCount][vInt] = strval(field);

        db_get_field_assoc(result,"virtualworld",field , 24);
        Veh[vehCount][vVWorld] = strval(field);

        db_get_field_assoc(result,"mod0",field , 24);
        Veh[vehCount][Mod0] = strval(field);

        db_get_field_assoc(result,"mod1", field , 24);
        Veh[vehCount][Mod1] = strval(field);

        db_get_field_assoc(result,"mod2", field , 24);
        Veh[vehCount][Mod2] = strval(field);

        db_get_field_assoc(result,"mod3", field , 24);
        Veh[vehCount][Mod3] = strval(field);

        db_get_field_assoc(result,"mod4", field , 24);
        Veh[vehCount][Mod4] = strval(field);

        db_get_field_assoc(result,"mod5", field , 24);
        Veh[vehCount][Mod5] = strval(field);

        db_get_field_assoc(result,"mod6", field , 24);
        Veh[vehCount][Mod6] = strval(field);

        db_get_field_assoc(result,"mod7", field , 24);
        Veh[vehCount][Mod7] = strval(field);

        db_get_field_assoc(result,"mod8", field , 24);
        Veh[vehCount][Mod8] = strval(field);

        db_get_field_assoc(result,"mod9", field , 24);
        Veh[vehCount][Mod9] = strval(field);

        db_get_field_assoc(result,"mod10", field , 24);
        Veh[vehCount][Mod10] = strval(field);

        db_get_field_assoc(result,"mod11",field , 24);
        Veh[vehCount][Mod11] = strval(field);

        db_get_field_assoc(result,"mod12", field , 24);
        Veh[vehCount][Mod12] = strval(field);

        db_get_field_assoc(result,"mod13", field , 24);
        Veh[vehCount][Mod13] = strval(field);
       
        db_get_field_assoc(result,"respawn", field , 24);
        Veh[vehCount][Respawn] = strval(field);
       
        db_get_field_assoc(result,"owner", Veh[vehCount][Owner] , 24);
       
        db_get_field_assoc(result,"weapon1", field , 24);
        Veh[vehCount][Weapons][0] = strval(field);
       
        db_get_field_assoc(result,"weapon2", field , 24);
        Veh[vehCount][Weapons][1] = strval(field);
       
        db_get_field_assoc(result,"weapon3", field , 24);
        Veh[vehCount][Weapons][2] = strval(field);
       
        db_get_field_assoc(result,"Paintjob", field , 24);
        Veh[vehCount][PaintJob] = strval(field);
       
        db_get_field_assoc(result,"vname", Veh[vehCount][VName] , 50);

        db_get_field_assoc(result,"plate", Veh[vehCount][Plate] , 32)
       
        db_get_field_assoc(result,"fuel", field , 24);
        Veh[vehCount][Fuel] = strval(field);       
       
        db_get_field_assoc(result,"VIP", field , 24);
        Veh[vehCount][VIP] = strval(field);    
       
        db_get_field_assoc(result,"Health", field , 24);
        Veh[vehCount][vHealth] = strval(field);

        db_get_field_assoc(result,"lockstate", field , 24);
        Veh[vehCount][lockState] = strval(field);  

        db_get_field_assoc(result,"spawnstate", field , 24);
        Veh[vehCount][spawnState] = strval(field);             

        db_next_row(result);
       
        new color1 = Veh[vehCount][Color1], color2 = Veh[vehCount][Color2], Float:angle = Veh[vehCount][vAngle], respawn = Veh[vehCount][Respawn];
        if(Veh[vehCount][spawnState] == 0)
        {
            count--;
            vehCount++;
            continue;
        }

        if(!strcmp(Veh[vehCount][Owner], "Unowned", true))
        {
            Veh[vehCount][Link] = CreateVehicle(Veh[vehCount][Model], Veh[vehCount][vX], Veh[vehCount][vY], Veh[vehCount][vZ], angle, color1, color2, respawn);
            SetVehicleNumberPlate(Veh[vehCount][Link], Veh[vehCount][Plate]);
           
            if(Veh[vehCount][Mod0] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod0]);
           
            if(Veh[vehCount][Mod1] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod1]);
           
            if(Veh[vehCount][Mod2] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod2]);
               
            if(Veh[vehCount][Mod3] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod3]);
               
            if(Veh[vehCount][Mod4] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod4]);
               
            if(Veh[vehCount][Mod5] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod5]);
               
            if(Veh[vehCount][Mod6] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod6]);
               
            if(Veh[vehCount][Mod7] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod7]);
                   
            if(Veh[vehCount][Mod8] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod8]);
               
            if(Veh[vehCount][Mod9] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod9]);
               
            if(Veh[vehCount][Mod10] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod10]);
               
            if(Veh[vehCount][Mod11] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod11]);
               
            if(Veh[vehCount][Mod12] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod12]);
               
            if(Veh[vehCount][Mod13] != 0)
                AddVehicleComponent(Veh[vehCount][Link], Veh[vehCount][Mod13]);
               
            if(Veh[vehCount][vHealth] == 0)
                SetVehicleHealth(Veh[vehCount][Link], 1000);
            else
                SetVehicleHealth(Veh[vehCount][Link], Veh[vehCount][vHealth]);
               
            Veh[vehCount][lockState] = 0;
               
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(Veh[vehCount][Link] , engine, lights, alarm, doors, bonnet, boot, objective);
           
            if(Veh[vehCount][Job] == 0 && Veh[vehCount][Group] == 0)           
            {
                SetVehicleParamsEx(Veh[vehCount][Link], engine, lights, alarm, Veh[vehCount][lockState], bonnet, boot, objective);
            }
               
        }
       
        count--;
        vehCount++;
    }
    db_free_result(result);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)