Extraside
Новичок
Дома бизы и т.д загружаются не в нужном порядке как они есть в базе допустим 0 - автосалон 1 - казино. Они загружаются сначало те которые куплены потом остальные. По братски помогите фиксануть мои родные
Это код который загружает дома
PHP:
public: LoadHouses()
{
new idx;
new query[85], buffer[2];
new Cache: result, rows;
result = mysql_query(mysql, "SELECT h.*, IFNULL(a.name, 'None') owner_name FROM houses h LEFT JOIN accounts a ON a.id=h.owner_id", true);
rows = cache_num_rows();
if(rows > MAX_HOUSES)
{
rows = MAX_HOUSES;
print("[Houses]: DB rows > MAX_HOUSES");
}
for(idx = 0; idx < rows; idx ++)
{
SetHouseData(idx, H_SQL_ID, cache_get_field_content_int(idx, "id"));
SetHouseData(idx, H_OWNER_ID, cache_get_field_content_int(idx, "owner_id"));
cache_get_field_content(idx, "name", g_house[idx][H_NAME], mysql, 20);
SetHouseData(idx, H_CITY, cache_get_field_content_int(idx, "city"));
SetHouseData(idx, H_ZONE, cache_get_field_content_int(idx, "zone"));
SetHouseData(idx, H_IMPROVEMENTS, cache_get_field_content_int(idx, "improvements"));
SetHouseData(idx, H_RENT_DATE, cache_get_field_content_int(idx, "rent_time"));
SetHouseData(idx, H_PRICE, cache_get_field_content_int(idx, "price"));
SetHouseData(idx, H_RENT_PRICE, cache_get_field_content_int(idx, "rent_price"));
SetHouseData(idx, H_TYPE, cache_get_field_content_int(idx, "type"));
SetHouseData(idx, H_ENTRACE, cache_get_field_content_int(idx, "entrance"));
SetHouseData(idx, H_LOCK_STATUS, bool: cache_get_field_content_int(idx, "lock"));
SetHouseData(idx, H_POS_X, cache_get_field_content_float(idx, "x"));
SetHouseData(idx, H_POS_Y, cache_get_field_content_float(idx, "y"));
SetHouseData(idx, H_POS_Z, cache_get_field_content_float(idx, "z"));
SetHouseData(idx, H_EXIT_POS_X, cache_get_field_content_float(idx, "exit_x"));
SetHouseData(idx, H_EXIT_POS_Y, cache_get_field_content_float(idx, "exit_y"));
SetHouseData(idx, H_EXIT_POS_Z, cache_get_field_content_float(idx, "exit_z"));
SetHouseData(idx, H_EXIT_ANGLE, cache_get_field_content_float(idx, "exit_angle"));
SetHouseData(idx, H_CAR_POS_X, cache_get_field_content_float(idx, "car_x"));
SetHouseData(idx, H_CAR_POS_Y, cache_get_field_content_float(idx, "car_y"));
SetHouseData(idx, H_CAR_POS_Z, cache_get_field_content_float(idx, "car_z"));
SetHouseData(idx, H_CAR_ANGLE, cache_get_field_content_float(idx, "car_angle"));
SetHouseData(idx, H_STORE_X, cache_get_field_content_float(idx, "store_x"));
SetHouseData(idx, H_STORE_Y, cache_get_field_content_float(idx, "store_y"));
SetHouseData(idx, H_STORE_Z, cache_get_field_content_float(idx, "store_z"));
SetHouseData(idx, H_EVICTION, cache_get_field_content_int(idx, "eviction"));
SetHouseData(idx, H_STORE_METALL, cache_get_field_content_int(idx, "store_metall"));
SetHouseData(idx, H_STORE_DRUGS, cache_get_field_content_int(idx, "store_drugs"));
SetHouseData(idx, H_STORE_WEAPON, cache_get_field_content_int(idx, "store_weapon"));
SetHouseData(idx, H_STORE_AMMO, cache_get_field_content_int(idx, "store_ammo"));
SetHouseData(idx, H_STORE_SKIN, cache_get_field_content_int(idx, "store_skin"));
cache_get_field_content(idx, "owner_name", g_house[idx][H_OWNER_NAME], mysql, 21);
// -------------------------
SetHouseData(idx, H_STORE_LABEL, Text3D:-1);
buffer[0] = GetHouseData(idx, H_TYPE);
if(!strlen(GetHouseData(idx, H_NAME)))
format(g_house[idx][H_NAME], 20, GetHouseTypeInfo(buffer[0], HT_NAME), 0);
if(GetHouseData(idx, H_ENTRACE) == -1)
{
if(GetHouseData(idx, H_CITY) == -1 || GetHouseData(idx, H_ZONE) == -1)
{
buffer[0] = Get2DCity(GetHouseData(idx, H_POS_X), GetHouseData(idx, H_POS_Y));
buffer[1] = Get2DZone(GetHouseData(idx, H_POS_X), GetHouseData(idx, H_POS_Y));
SetHouseData(idx, H_CITY, buffer[0]);
SetHouseData(idx, H_ZONE, buffer[1]);
mysql_format(mysql, query, sizeof query, "UPDATE houses SET city=%d,zone=%d WHERE id=%d", buffer[0], buffer[1], GetHouseData(idx, H_SQL_ID));
mysql_query(mysql, query, false);
}
}
if(IsHouseOwned(idx) && !strcmp(GetHouseData(idx, H_OWNER_NAME), "None", true))
{
SetHouseData(idx, H_OWNER_ID, 0);
mysql_format(mysql, query, sizeof query, "UPDATE houses SET owner_id=0,improvements=0 WHERE id=%d", GetHouseData(idx, H_SQL_ID));
mysql_query(mysql, query, false);
}
if(!IsHouseOwned(idx))
{
SetHouseData(idx, H_IMPROVEMENTS, 0);
SetHouseData(idx, H_LOCK_STATUS, false);
}
UpdateHouse(idx);
HouseHealthInit(idx);
HouseStoreInit(idx);
buffer[0] = GetHouseData(idx, H_ENTRACE);
if(buffer[0] != -1)
{
buffer[1] = g_entrance_flats_loaded[buffer[0]];
g_entrance_flats_loaded[buffer[0]] ++;
g_entrance_flat[buffer[0]][buffer[1] / 4][buffer[1] % 4] = idx;
SetHouseData(idx, H_FLAT_ID, buffer[1]);
}
}
g_house_loaded = rows;
cache_delete(result);
printf("[Houses]: Домов загружено: %d", g_house_loaded);
}
