-
ГангЗоны
Не загружает ганг зоны почему не пойму переводил с
PHP код:
forward load_gz();
public load_gz()
{
new rows;
cache_get_row_count(rows);
if(rows)
{
for(new idx = 0; idx < rows; idx++)
{
cache_get_value_name_int(idx,"id", gangzone_Info[idx][gID]);
cache_get_value_name_float(idx, "zone_x", gangzone_Info[idx][gCoords][0]);
cache_get_value_name_float(idx, "zone_y", gangzone_Info[idx][gCoords][1]);
cache_get_value_name_float(idx, "zone_xM", gangzone_Info[idx][gCoords][2]);
cache_get_value_name_float(idx, "zone_yM", gangzone_Info[idx][gCoords][3]);
cache_get_value_name_int(idx, "fraction", gangzone_Info[idx][gang_terr]);
TOTALGZ++;
GangZone[idx] = GangZoneCreate(gangzone_Info[idx][gCoords][0],gangzone_Info[idx][gCoords][1],gangzone_Info[idx][gCoords][2],gangzone_Info[idx][gCoords][3]);
ZoneOnBattle[idx] = 0;
GZSafeTime[idx] = 0;
}
}
printf("[%i штук] >> загружены gangzone", TOTALGZ);
return 1;
}
На
PHP код:
publics: load_gz()
{
new rows;
cache_get_row_count(rows);
if(rows)
{
for(new idx = 0; idx < rows; idx++)
{
gangzone_Info[idx][gID] = cache_get_field_content_int(idx,"id");
gangzone_Info[idx][gCoords][0] = cache_get_field_content_float(idx, "zone_x");
gangzone_Info[idx][gCoords][1] = cache_get_field_content_float(idx, "zone_y");
gangzone_Info[idx][gCoords][2] = cache_get_field_content_float(idx, "zone_xM");
gangzone_Info[idx][gCoords][3] = cache_get_field_content_float(idx, "zone_yM");
gangzone_Info[idx][gang_terr] = cache_get_field_content_int(idx, "fraction");
TOTALGZ++;
GangZone[idx] = GangZoneCreate(gangzone_Info[idx][gCoords][0],gangzone_Info[idx][gCoords][1],gangzone_Info[idx][gCoords][2],gangzone_Info[idx][gCoords][3]);
ZoneOnBattle[idx] = 0;
GZSafeTime[idx] = 0;
}
}
printf("[%i штук] >> загружены gangzone", TOTALGZ);
return 1;
}
-
Лучше вот так
PHP код:
publics: load_gz()
{
cache_get_row_count(TOTALGZ);
if(TOTALGZ)
{
new Float:min_x,
Float:min_y,
Float:max_x,
Float:max_y;
for(new idx = 0; idx < TOTALGZ; idx++)
{
gangzone_Info[idx][gID] = cache_get_field_content_int(idx,"id");
min_x = gangzone_Info[idx][gCoords][0] = cache_get_field_content_float(idx, "zone_x");
min_y = gangzone_Info[idx][gCoords][1] = cache_get_field_content_float(idx, "zone_y");
max_x = gangzone_Info[idx][gCoords][2] = cache_get_field_content_float(idx, "zone_xM");
max_y = gangzone_Info[idx][gCoords][3] = cache_get_field_content_float(idx, "zone_yM");
gangzone_Info[idx][gang_terr] = cache_get_field_content_int(idx, "fraction");
GangZone[idx] = GangZoneCreate(min_x, min_y, max_x, max_y);
//ZoneOnBattle[idx] = GZSafeTime[idx] = 0; // Если загружаешь зоны только при старте сервера (рестарте), то эта строка не нужна
}
}
printf("[%i штук] >> загружены gangzone", TOTALGZ);
return 1;
}
Но проблемы в коде пока не видно. Покажи логи MySQL и если в них ничего нет, залогируй данные, которые передаются в TOTALGZ (сразу после cache_get_row_count) и переменные с координатами (перед созданием гангзоны)
-
PHP код:
[14:03:05] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Pohodka=0, Member=0, Leader=0, Rank=0, Mute=0 WHERE Name='Edi_Alvares'' at line 1
[14:03:06] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Pohodka=0, Member=0, Leader=0, Rank=0, Mute=0 WHERE Name='Edi_Alvares'' at line 1
[14:03:07] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Pohodka=0, Member=0, Leader=0, Rank=0, Mute=0 WHERE Name='Edi_Alvares'' at line 1
PHP код:
stock SavePlayer(playerid)
{
if(Logged[playerid] == true || IsPlayerConnected(playerid))
{
new query[500] = "UPDATE "table_account" SET ";
format(query, sizeof(query), "%s Skin=%d,", query, PlayerInfo[playerid][pSkin]);//7+3
format(query, sizeof(query), "%s Sex=%d,", query, PlayerInfo[playerid][pSex]);//6+1
format(query, sizeof(query), "%s Cash=%d,", query, PlayerInfo[playerid][pCash]);//7+11
format(query, sizeof(query), "%s Level=%d,", query, PlayerInfo[playerid][pLevel]);//8+11
format(query, sizeof(query), "%s Admin=%d,", query, PlayerInfo[playerid][pAdmin]);//8+2
format(query, sizeof(query), "%s Rasa=%d,", query, PlayerInfo[playerid][pRasa]);//7+2
format(query, sizeof(query), "%s Gorod=%d,", query, PlayerInfo[playerid][pGorod]);//7+1
format(query, sizeof(query), "%s Exp=%d,", query, PlayerInfo[playerid][pExp]);
format(query, sizeof(query), "%s AdminKey=%s,", query, PlayerInfo[playerid][pAdminKey]);
format(query, sizeof(query), "%s Pohodka=%d,", query, PlayerInfo[playerid][pPohodka]);
format(query, sizeof(query), "%s Member=%d,", query, PlayerInfo[playerid][pMember]);
format(query, sizeof(query), "%s Leader=%d,", query, PlayerInfo[playerid][pLeader]);
format(query, sizeof(query), "%s Rank=%d,", query, PlayerInfo[playerid][pRank]);
format(query, sizeof(query), "%s Mute=%d", query, PlayerInfo[playerid][pMute]);
format(query, sizeof(query), "%s WHERE Name='%s'", query, GN(playerid));//14+MAX_PLAYER_NAME
mysql_function_query(mysql_connection, query, false, "", "");
}
else printf("Îøèáêà ñîõðàí¸íèÿ.");
return true;
}
-
Спецификатор %s нужно обрамлять в апострофы, дабы запрос понимал где началась строка и где она закончилась.
И ты каждую секунду сохраняешь аккаунт что ли? О_о Да ещё и сохраняешь его для неавторизированных пользователей
-
в начале format(query, sizeof(query), "%s Skin=%d,",
Так
PHP код:
stock SavePlayer(playerid)
{
if(Logged[playerid] == true)
{
new query[500] = "UPDATE "table_account" SET ";
format(query, sizeof(query), "%s `Skin` = '%d',", query, PlayerInfo[playerid][pSkin]);//7+3
format(query, sizeof(query), "%s `Sex` = '%d',", query, PlayerInfo[playerid][pSex]);//6+1
format(query, sizeof(query), "%s `Cash` = '%d',", query, PlayerInfo[playerid][pCash]);//7+11
format(query, sizeof(query), "%s `Level` = '%d',", query, PlayerInfo[playerid][pLevel]);//8+11
format(query, sizeof(query), "%s `Admin` = '%d',", query, PlayerInfo[playerid][pAdmin]);//8+2
format(query, sizeof(query), "%s `Rasa` = '%d',", query, PlayerInfo[playerid][pRasa]);//7+2
format(query, sizeof(query), "%s `Gorod` = '%d',", query, PlayerInfo[playerid][pGorod]);//7+1
format(query, sizeof(query), "%s `Exp` = '%d',", query, PlayerInfo[playerid][pExp]);
format(query, sizeof(query), "%s `AdminKey` = '%s',", query, PlayerInfo[playerid][pAdminKey]);
format(query, sizeof(query), "%s `Pohodka` = '%d',", query, PlayerInfo[playerid][pPohodka]);
format(query, sizeof(query), "%s `Member` = '%d',", query, PlayerInfo[playerid][pMember]);
format(query, sizeof(query), "%s `Leader` = '%d',", query, PlayerInfo[playerid][pLeader]);
format(query, sizeof(query), "%s `Rank` = '%d',", query, PlayerInfo[playerid][pRank]);
format(query, sizeof(query), "%s `Mute` = '%d'", query, PlayerInfo[playerid][pMute]);
format(query, sizeof(query), "%s WHERE Name = '%s'", query, GN(playerid));//14+MAX_PLAYER_NAME
mysql_function_query(mysql_connection, query, false, "", "");
}
else printf("Ошибка сохранёния.");
return true;
}
В базе записывает всё а ошибка выдаётся в логах мускл
PHP код:
[14:03:05] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Pohodka=0, Member=0, Leader=0, Rank=0, Mute=0 WHERE Name='Edi_Alvares'' at line 1
[14:03:06] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Pohodka=0, Member=0, Leader=0, Rank=0, Mute=0 WHERE Name='Edi_Al
-
Эмм, это ошибка не с этого запроса, если вообще не старая ошибка. По форматированию посмотри
-
Всё усёк , ну с гангзонами не пойму не загружает всё же в логах не чего нету
-
Ну так логирование сделай, как сказал
-
перед cache_get_row_count(TOTALGZ); ?
printf("%i запись создания", TOTALGZ);
-
PHP код:
publics: load_gz()
{
cache_get_row_count(TOTALGZ);
printf("\n\n\nTOTALGZ = %d", TOTALGZ);
if(TOTALGZ)
{
new Float:min_x,
Float:min_y,
Float:max_x,
Float:max_y;
for(new idx = 0; idx < TOTALGZ; idx++)
{
gangzone_Info[idx][gID] = cache_get_field_content_int(idx,"id");
min_x = gangzone_Info[idx][gCoords][0] = cache_get_field_content_float(idx, "zone_x");
min_y = gangzone_Info[idx][gCoords][1] = cache_get_field_content_float(idx, "zone_y");
max_x = gangzone_Info[idx][gCoords][2] = cache_get_field_content_float(idx, "zone_xM");
max_y = gangzone_Info[idx][gCoords][3] = cache_get_field_content_float(idx, "zone_yM");
gangzone_Info[idx][gang_terr] = cache_get_field_content_int(idx, "fraction");
printf("%d) %f, %f, %f, %f", idx, min_x, min_y, max_x, max_y);
GangZone[idx] = GangZoneCreate(min_x, min_y, max_x, max_y);
//ZoneOnBattle[idx] = GZSafeTime[idx] = 0; // Если загружаешь зоны только при старте сервера (рестарте), то эта строка не нужна
}
}
printf("[%i штук] >> загружены gangzone", TOTALGZ);
return 1;
}