public LoadCars_Data()
{
new rows, id, createdVehs;
rows = cache_num_rows();
for(new i=0; i<rows; i++)
{
id = cache_get_field_content_int(i, "ID");
if(id < 0 || id >= sizeof(CarInfo)) continue;
cache_get_field_content(i, "Besitzer", CarInfo[id][Besitzer],handle,34);
CarInfo[id][modelID] = cache_get_field_content_int(i, "ModelID");
CarInfo[id][c_x] = cache_get_field_content_float(i, "PosX");
CarInfo[id][c_y] = cache_get_field_content_float(i, "PosY");
CarInfo[id][c_z] = cache_get_field_content_float(i, "PosZ");
CarInfo[id][c_a] = cache_get_field_content_float(i, "PosA");
CarInfo[id][c_color1] = cache_get_field_content_int(i, "Color1");
CarInfo[id][c_color2] = cache_get_field_content_int(i, "Color2");
CarInfo[id][c_Preis] = cache_get_field_content_int(i, "Preis");
CarInfo[id][c_Gekauft] = cache_get_field_content_int(i, "Gekauft");
CarInfo[id][c_Versicherung] = cache_get_field_content_int(i, "Versicherung");
CarInfo[id][c_Drogen] = cache_get_field_content_int(i, "Drogen");
CarInfo[id][c_Waffen] = cache_get_field_content_int(i, "Waffen");
CarInfo[id][c_Geld] = cache_get_field_content_int(i, "Geld");
CarInfo[id][tuning][0] = cache_get_field_content_int(i, "tuning0");
CarInfo[id][tuning][1] = cache_get_field_content_int(i, "tuning1");
CarInfo[id][tuning][2] = cache_get_field_content_int(i, "tuning2");
CarInfo[id][tuning][3] = cache_get_field_content_int(i, "tuning3");
CarInfo[id][tuning][4] = cache_get_field_content_int(i, "tuning4");
CarInfo[id][tuning][5] = cache_get_field_content_int(i, "tuning5");
CarInfo[id][tuning][6] = cache_get_field_content_int(i, "tuning6");
CarInfo[id][tuning][7] = cache_get_field_content_int(i, "tuning7");
CarInfo[id][tuning][8] = cache_get_field_content_int(i, "tuning8");
CarInfo[id][tuning][9] = cache_get_field_content_int(i, "tuning9");
CarInfo[id][tuning][10] = cache_get_field_content_int(i, "tuning10");
CarInfo[id][tuning][11] = cache_get_field_content_int(i, "tuning11");
CarInfo[id][tuning][12] = cache_get_field_content_int(i, "tuning12");
CarInfo[id][tuning][13] = cache_get_field_content_int(i, "tuning13");
cache_get_field_content(i, "Schild", CarInfo[id][c_Schild],handle,34);
if(CarInfo[id][modelID] >= 400 && CarInfo[id][modelID] <= 611)
{
new text[64];
CarInfo[id][c_vID] = CreateVehicle(CarInfo[id][modelID], CarInfo[id][c_x], CarInfo[id][c_y], CarInfo[id][c_z], CarInfo[id][c_a], CarInfo[id][c_color1], CarInfo[id][c_color2], -1);
format(text, sizeof(text), "Besitzer: %s\nKaufpreis: %d\nReparier Kosten: %d",CarInfo[id][Besitzer],CarInfo[id][c_Preis], CarInfo[id][c_Preis] / 10);
CarInfo[id][Carlable] = Create3DTextLabel(text,0x0FFF00FF,CarInfo[id][c_x], CarInfo[id][c_y], CarInfo[id][c_z],20.0,0,1);
Attach3DTextLabelToVehicle(CarInfo[id][Carlable],CarInfo[id][c_vID], 0.0, 0.0, 2.0);
SetVehicleNumberPlate(CarInfo[i][c_vID], CarInfo[i][c_Schild]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][0]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][1]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][2]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][3]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][4]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][5]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][6]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][7]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][8]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][9]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][10]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][11]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][12]);
AddVehicleComponent(CarInfo[id][c_vID],CarInfo[id][tuning][13]);
}
else
{
printf("[Error] Model-ID %d existiert nicht (ID: %d).", CarInfo[id][modelID], id);
}
if(GetVehicleModel(MAX_VEHICLES-1) != 0) return print("Es können keine weiteren Fahrzeuge geladen werden, Limit (MAX_VEHICLES) erreicht.");
createdVehs++;
if(createdVehs == MAX_AUTOS) return print("Es können keine weiteren Fahrzeuge geladen werden, Limit (MAX_AUTOS) erreicht.");
}
return 1;
}
forward SaveAllCars();
public SaveAllCars()
{
printf("Starte SaveAllCars");
new query[1224];
for(new i=0; i<MAX_AUTOS; i++)
{
printf("i: %d | Model: %d | Besitzer: %s", i, CarInfo[i][modelID], CarInfo[i][Besitzer]);
if(CarInfo[i][modelID] >= 400 && CarInfo[i][modelID] <= 611)
{
printf("Gekauft: %d", CarInfo[i][c_Gekauft]);
if(CarInfo[i][c_Gekauft] == 0)
{
format(query, sizeof(query), "UPDATE Cars SET Besitzer = '%s',ModelID = '%d', PosX = '%f', PosY = '%f', PosZ = '%f', PosA = '%f', Color1 = '%d', Color2 = '%d',Preis = '%d',Gekauft = '%d', Versicherung = '%d', Schild = '%s', Drogen = '%d', Waffen = '%d', Geld = '%d' WHERE ID = '%d'",
CarInfo[i][Besitzer],CarInfo[i][modelID], CarInfo[i][c_x], CarInfo[i][c_y], CarInfo[i][c_z], CarInfo[i][c_a], CarInfo[i][c_color1], CarInfo[i][c_color2],CarInfo[i][c_Preis],CarInfo[i][c_Gekauft], CarInfo[i][c_Versicherung],CarInfo[i][c_Schild],CarInfo[i][c_Drogen],CarInfo[i][c_Waffen],CarInfo[i][c_Geld], i);
mysql_tquery(handle, query);
printf("query: %s", query);
SendClientMessageToAll(info, "Nicht gekauft Autos wurden gespeichert!");
}
if(CarInfo[i][c_Gekauft] == 1)
{
new Float:VehPos[4];
GetVehiclePos(CarInfo[i][c_vID],VehPos[0],VehPos[1],VehPos[2]);
GetVehicleZAngle(CarInfo[i][c_vID], VehPos[3]);
format(query, sizeof(query), "UPDATE Cars SET Besitzer = '%s',ModelID = '%d', PosX = '%f', PosY = '%f', PosZ = '%f', PosA = '%f', Color1 = '%d', Color2 = '%d',Preis = '%d',Gekauft = '%d', Versicherung = '%d', Schild = '%s', Drogen = '%d', Waffen = '%d', Geld = '%d' WHERE ID = '%d'",
CarInfo[i][Besitzer],CarInfo[i][modelID], VehPos[0], VehPos[1], VehPos[2], VehPos[3], CarInfo[i][c_color1], CarInfo[i][c_color2],CarInfo[i][c_Preis],CarInfo[i][c_Gekauft],CarInfo[i][c_Versicherung],CarInfo[i][c_Schild],CarInfo[i][c_Drogen],CarInfo[i][c_Waffen],CarInfo[i][c_Geld], i);
mysql_tquery(handle, query);
printf("query: %s", query);
SendClientMessageToAll(info, "Gekaufte Autos wurden gespeichert!");
format(query, sizeof(query), "UPDATE Cars SET tuning0 = %d", GetVehicleComponentInSlot(CarInfo[i][c_vID], 0));
for(new j=1; j<14; j++)
{
format(query, sizeof(query), "%s, tuning%d = %d ", query, j, GetVehicleComponentInSlot(CarInfo[i][c_vID], j));
}
format(query, sizeof(query), "%sWHERE ID = %d",query, i);
mysql_tquery(handle, query);
printf("query: %s", query);
}
}
}
SendClientMessageToAll(info, "Alle Fahrzeuge wurden gespeichert!");
printf("Fertig.");
return 1;
}