Сообщение от
$continue$
Накидал тут, может где то ошибки и есть:
В начало мода куда нибудь
PHP код:
enum e_GHETTO_DATA
{
Float: x_coordinate_west_side_gz,
Float: y_coordinate_south_side_gz,
Float: x_coordinate_east_side_gz,
Float: y_coordinate_north_side_gz,
fraction_id
}
PHP код:
new counter_gang_zones = 0;
new DataGhetto[120][e_GHETTO_DATA];
#define TABLE_GANG_ZONE_BAND "ghetto"
PHP код:
public OnGameModeInit()
{
// connect_id - id подключение, записывают в перееменную: connect_id = mysql_connect(ip_addreas, users, date_base, data_pase_password);
mysql_function_query(connect_id, "SELECT * FROM `"TABLE_GANG_ZONE_BAND"`", true, "CallBackLoadGangZoneBand", "");
}
PHP код:
forward CallBackLoadGangZoneBand();
public CallBackLoadGangZoneBand()
{
new rows, fields;
cache_get_data(rows, fields);
if(rows == 0)
return print("[Предупреждение][Загрузка GangZone]: В базе данных нет GangZones!");
if(rows != sizeof(DataGhetto))
return printf("[Предупреждение][Загрузка GangZone]: В базе данных больше зон[%d], чем в массиве DataGhetto[%d][e_GHETTO_DATA]!", rows, sizeof(DataGhetto));
// Судя прописывать название столцов с координатами
static const column_one_coordinates[] = !"x_coordinate_west_side_gz";
static const column_two_coordinates[] = !"y_coordinate_south_side_gz";
static const column_three_coordinates[] = !"x_coordinate_east_side_gz";
static const column_four_coordinates[] = !"y_coordinate_north_side_gz";
static const column_id_fraction[] = !"fraction_id";
for(new i = 0; i < sizeof(DataGhetto); i++)
{
DataGhetto[i][x_coordinate_west_side_gz] = cache_get_field_content_float(i, column_one_coordinates);
DataGhetto[i][y_coordinate_south_side_gz] = cache_get_field_content_float(i, column_two_coordinates);
DataGhetto[i][x_coordinate_east_side_gz] = cache_get_field_content_float(i, column_three_coordinates);
DataGhetto[i][y_coordinate_north_side_gz] = cache_get_field_content_float(i, column_four_coordinates);
DataGhetto[i][fraction_id] = cache_get_field_content_int(i, "column_id_fraction");
}
counter_gang_zones = rows;
printf("[Загрузка GangZone]: Загрузка GangZones прошла успешна! Загружено %d GangZone", counter_gang_zones);
return (rows == 0) ? 0 : 1;
}
Более оптимизированный и быстрый:
PHP код:
forward OnMySQL_Gangs();
public OnMySQL_Gangs()
{
new connects;
new rows = cache_get_row_count(connects);
new time = GetTickCount();
if(!rows) return printf("Гангзоны не загружены");
for(new i = 0; i < rows; i++)
{
GZInfo[i][X] = cache_get_field_content_float(i, "X", connects);
GZInfo[i][Y] = cache_get_field_content_float(i, "Y", connects);
GZInfo[i][XX] = cache_get_field_content_float(i, "XX", connects);
GZInfo[i][XY] = cache_get_field_content_float(i , "XY", connects);
GZInfo[i][Member] = cache_get_field_content_int(i, "Member", connects);
GZInfo[i][ID] = GangZoneCreate(GZInfo[i][X],GZInfo[i][Y],GZInfo[i][XX],GZInfo[i][XY]);
}
printf("LoadGangZone: Загружено %d | Время: %d (ms)", rows, GetTickCount()-time);
return true;
}