new DBResult: Result;
Result = db_query(Database, "SELECT last_insert_rowid()");
LoadVehicle(Result);
db_free_result(Result);
Result = db_query(Database, "SELECT last_insert_rowid()");
LoadVehicle(Result);
stock LoadVehicle(id)
{
new
DBResult: Result,
Query[256],
temp[256];
format(Query, sizeof Query, "SELECT * FROM `vehicles` WHERE `id` = %i", id);
db_query(Database, Query);
if(db_num_rows(Result))
{
db_get_field_assoc(Result, "id", temp, sizeof temp);
Vehicle[id][vSQLID] = strval(temp);
db_get_field_assoc(Result, "modelid", temp, sizeof temp);
Vehicle[id][vModel] = strval(temp);
db_get_field_assoc(Result, "pos_x", temp, sizeof temp);
Vehicle[id][vPos][0] = floatstr(temp);
db_get_field_assoc(Result, "pos_y", temp, sizeof temp);
Vehicle[id][vPos][1] = floatstr(temp);
db_get_field_assoc(Result, "pos_z", temp, sizeof temp);
Vehicle[id][vPos][2] = floatstr(temp);
db_get_field_assoc(Result, "pos_r", temp, sizeof temp);
Vehicle[id][vPos][3] = floatstr(temp);
db_get_field_assoc(Result, "colour1", temp, sizeof temp);
Vehicle[id][vColour][0] = strval(temp);
db_get_field_assoc(Result, "colour2", temp, sizeof temp);
Vehicle[id][vColour][1] = strval(temp);
db_get_field_assoc(Result, "mod_slot_0", temp, sizeof temp);
Vehicle[id][vMods][0] = strval(temp);
db_get_field_assoc(Result, "mod_slot_1", temp, sizeof temp);
Vehicle[id][vMods][1] = strval(temp);
db_get_field_assoc(Result, "mod_slot_2", temp, sizeof temp);
Vehicle[id][vMods][2] = strval(temp);
db_get_field_assoc(Result, "mod_slot_3", temp, sizeof temp);
Vehicle[id][vMods][3] = strval(temp);
db_get_field_assoc(Result, "mod_slot_4", temp, sizeof temp);
Vehicle[id][vMods][4] = strval(temp);
db_get_field_assoc(Result, "mod_slot_5", temp, sizeof temp);
Vehicle[id][vMods][5] = strval(temp);
db_get_field_assoc(Result, "mod_slot_6", temp, sizeof temp);
Vehicle[id][vMods][6] = strval(temp);
db_get_field_assoc(Result, "mod_slot_7", temp, sizeof temp);
Vehicle[id][vMods][7] = strval(temp);
db_get_field_assoc(Result, "mod_slot_8", temp, sizeof temp);
Vehicle[id][vMods][8] = strval(temp);
db_get_field_assoc(Result, "mod_slot_9", temp, sizeof temp);
Vehicle[id][vMods][9] = strval(temp);
db_get_field_assoc(Result, "mod_slot_10", temp, sizeof temp);
Vehicle[id][vMods][10] = strval(temp);
db_get_field_assoc(Result, "mod_slot_11", temp, sizeof temp);
Vehicle[id][vMods][11] = strval(temp);
db_get_field_assoc(Result, "mod_slot_12", temp, sizeof temp);
Vehicle[id][vMods][12] = strval(temp);
db_get_field_assoc(Result, "mod_slot_13", temp, sizeof temp);
Vehicle[id][vMods][13] = strval(temp);
db_get_field_assoc(Result, "fuel", temp, sizeof temp);
Vehicle[id][vFuel] = strval(temp);
Vehicle[id][vVID] = CreateVehicle(Vehicle[id][vModel], Vehicle[id][vPos][0], Vehicle[id][vPos][1], Vehicle[id][vPos][2], Vehicle[id][vPos][3], Vehicle[id][vColour][0], Vehicle[id][vColour][1], -1);
}
db_free_result(Result);
return 1;
}
can u do something like LoadVehicle(_:Result);
i dont know how sqlite works |