04.07.2014, 17:19
Its saving fine. but when I restart the server my cars are no-were to be seen...
Here is my loading code:
Here is my loading code:
Код:
Load_Vehicles()
{
new Query[512], savestr[25], rows, fields, count = 0, count2 = 0;
for(new i = 1; i < MAX_DVEHICLES; i++)
{
mysql_format(dbHandle,Query, sizeof(Query), "SELECT * FROM `Vehicles` WHERE `ID` = '%d'", i);
mysql_query(dbHandle,Query);
cache_get_data(rows, fields);
if(rows)
{
cache_get_field_content(0, "Dealer", savestr); vInfo[i][vDealer] = strval(savestr);
cache_get_field_content(0, "Owner", savestr); vInfo[i][vOwner] = savestr;
cache_get_field_content(0, "Model", savestr); vInfo[i][vModel] = strval(savestr);
cache_get_field_content(0, "Price", savestr); vInfo[i][vPrice] = strval(savestr);
cache_get_field_content(0, "PosX", savestr); vInfo[i][Pos][0] = floatstr(savestr);
cache_get_field_content(0, "PosY", savestr); vInfo[i][Pos][1] = floatstr(savestr);
cache_get_field_content(0, "PosZ", savestr); vInfo[i][Pos][2] = floatstr(savestr);
cache_get_field_content(0, "PosA", savestr); vInfo[i][Pos][3] = floatstr(savestr);
cache_get_field_content(0, "Color1", savestr); vInfo[i][vColor1] = strval(savestr);
cache_get_field_content(0, "Color2", savestr); vInfo[i][vColor2] = strval(savestr);
if(vInfo[i][vDealer] == 1)
{
VehicleID[i] = AddStaticVehicleEx(vInfo[i][vModel], vInfo[i][Pos][0], vInfo[i][Pos][1], vInfo[i][Pos][2], vInfo[i][Pos][3], vInfo[i][vColor1], vInfo[i][vColor2], 10);
count++;
}
if(vInfo[i][vDealer] == 0)
{
VehicleID[i] = AddStaticVehicleEx(vInfo[i][vModel], vInfo[i][Pos][0], vInfo[i][Pos][1], vInfo[i][Pos][2], vInfo[i][Pos][3], vInfo[i][vColor1], vInfo[i][vColor2], 60000);
count2++;
}
}
}
printf("Loaded %d Dealership vehicles", count);
printf("Loaded %d vehicles", count2);
}
Load_DealershipVehicles()
{
new labeltext[55];
for(new i = 1; i < MAX_DVEHICLES; i++)
{
if(vInfo[i][vDealer] == DEALER_VEHICLE)
{
format(labeltext, sizeof(labeltext), "Price: $%d", vInfo[i][vPrice]);
vInfo[i][Label] = Create3DTextLabel(labeltext, 0xBB7700DD, 0, 0, 0, 10.0, 0, 0);
Attach3DTextLabelToVehicle(vInfo[i][Label], VehicleID[i], 0, 0, 0);
}
}
}

