PDA

Просмотр полной версии : [Вопрос] Проблема с gangzone



antosha22rus
27.07.2018, 12:43
Всем привет, начал писать систему гетто, появилась проблема, первой зоне присваивается 0 цвет, в чем проблема?
Загрузка зон:
new time = GetTickCount(), rows;
cache_get_row_count(rows);
if(rows)
{
for(new idx = 0; idx < rows; idx++)
{
cache_get_value_name_int(idx, "id", GZInfo[idx][gID]);
cache_get_value_name_float(idx, "ginfo1", GZInfo[idx][gCoords][0]);
cache_get_value_name_float(idx, "ginfo2", GZInfo[idx][gCoords][1]);
cache_get_value_name_float(idx, "ginfo3", GZInfo[idx][gCoords][2]);
cache_get_value_name_float(idx, "ginfo4", GZInfo[idx][gCoords][3]);
cache_get_value_name_int(idx, "fraction", GZInfo[idx][gFrak]);

TOTALGZ++;
GangZone[idx] = GangZoneCreate(GZInfo[idx][gCoords][0],GZInfo[idx][gCoords][1],GZInfo[idx][gCoords][2],GZInfo[idx][gCoords][3]);
ZoneOnBattle[idx] = 0;
GZSafeTime[idx] = 0;
}
}

DeimoS
27.07.2018, 13:52
Во-первых, как я понимаю, загрузка гангзон происходит при старте сервера. Так зачем ты повторно обнуляешь ZoneOnBattle и GZSafeTime, если они и так уже инициализированы нулями?

Во-вторых, зачем ты каждую итерацию мучаешь TOTALGZ? Почему нельзя в TOTALGZ записать значение cache_get_row_count? То бишь, использовать TOTALGZ вместо rows. Получишь тот же самый результат, только без лишней переменной и лишнего действия в цикле.

В-третьих, скинь код показа зон и функцию, через которую определяешь цвет для них. А заодно и скрин содержимого первой страницы таблицы

antosha22rus
27.07.2018, 15:00
Во-первых, как я понимаю, загрузка гангзон происходит при старте сервера. Так зачем ты повторно обнуляешь ZoneOnBattle и GZSafeTime, если они и так уже инициализированы нулями?

Во-вторых, зачем ты каждую итерацию мучаешь TOTALGZ? Почему нельзя в TOTALGZ записать значение cache_get_row_count? То бишь, использовать TOTALGZ вместо rows. Получишь тот же самый результат, только без лишней переменной и лишнего действия в цикле.

В-третьих, скинь код показа зон и функцию, через которую определяешь цвет для них. А заодно и скрин содержимого первой страницы таблицы

В OnPlayerConnect показывает зону:
for(new i = 0; i < sizeof(GZInfo); i++) GangZoneShowForPlayer(playerid, GangZone[i], GetGangZoneColor(i));
Определяет цвет:
stock GetGangZoneColor(fractionid)
return
(GZInfo[fractionid][gFrak] == 13) ? (0xCC00FFAA) :
(GZInfo[fractionid][gFrak] == 14) ? (0xffa500AA) :
(GZInfo[fractionid][gFrak] == 15) ? (0x009900AA) : (0xFFFFFF65);
Таблица:
https://imgur.com/a/L7llf6U

- - - Добавлено - - -


for(new i = 0; i < sizeof(GZInfo); i++) GangZoneShowForPlayer(playerid, GangZone[i], GetGangZoneColor(GZInfo[i][gFrak]));

Теперь все зоны 0xCC00FFAA цвета

DeimoS
27.07.2018, 15:19
Прологируй значение переменной и скинь сюда результат:
new time = GetTickCount();
cache_get_row_count(TOTALGZ);
if(TOTALGZ)
{
for(new idx = 0; idx < TOTALGZ; idx++)
{
cache_get_value_name_int(idx, "id", GZInfo[idx][gID]);
cache_get_value_name_float(idx, "ginfo1", GZInfo[idx][gCoords][0]);
cache_get_value_name_float(idx, "ginfo2", GZInfo[idx][gCoords][1]);
cache_get_value_name_float(idx, "ginfo3", GZInfo[idx][gCoords][2]);
cache_get_value_name_float(idx, "ginfo4", GZInfo[idx][gCoords][3]);
cache_get_value_name_int(idx, "fraction", GZInfo[idx][gFrak]);
if(idx == 0)
printf("\n\n\nLoad: %d\n\n\n", GZInfo[idx][gFrak]);

GangZone[idx] = GangZoneCreate(GZInfo[idx][gCoords][0],GZInfo[idx][gCoords][1],GZInfo[idx][gCoords][2],GZInfo[idx][gCoords][3]);
}
}



for(new i = 0; i < sizeof(GangZone); i++)
{
if(i == 0)
printf("\n\n\nColor: %d (%h)\n\n\n", GZInfo[i][gFrak], GetGangZoneColor(i));
GangZoneShowForPlayer(playerid, GangZone[i], GetGangZoneColor(i));
}

antosha22rus
27.07.2018, 15:22
Прологируй значение переменной и скинь сюда результат:
new time = GetTickCount();
cache_get_row_count(TOTALGZ);
if(TOTALGZ)
{
for(new idx = 0; idx < TOTALGZ; idx++)
{
cache_get_value_name_int(idx, "id", GZInfo[idx][gID]);
cache_get_value_name_float(idx, "ginfo1", GZInfo[idx][gCoords][0]);
cache_get_value_name_float(idx, "ginfo2", GZInfo[idx][gCoords][1]);
cache_get_value_name_float(idx, "ginfo3", GZInfo[idx][gCoords][2]);
cache_get_value_name_float(idx, "ginfo4", GZInfo[idx][gCoords][3]);
cache_get_value_name_int(idx, "fraction", GZInfo[idx][gFrak]);
if(idx == 0)
printf("\n\n\nLoad: %d\n\n\n", GZInfo[idx][gFrak]);

GangZone[idx] = GangZoneCreate(GZInfo[idx][gCoords][0],GZInfo[idx][gCoords][1],GZInfo[idx][gCoords][2],GZInfo[idx][gCoords][3]);
}
}



for(new i = 0; i < sizeof(GangZone); i++)
{
if(i == 0)
printf("\n\n\nColor: %d (%h)\n\n\n", GZInfo[i][gFrak], GetGangZoneColor(i));
GangZoneShowForPlayer(playerid, GangZone[i], GetGangZoneColor(i));
}

Load: 13
Color: 13 (-33FF0056)

DeimoS
27.07.2018, 17:09
Хмм, покажи код выше цикла с показом зон в OnPlayerConnect.
crashdetect стоит? В логах нет ничего?

antosha22rus
27.07.2018, 17:11
Хмм, покажи код выше цикла с показом зон в OnPlayerConnect.
crashdetect стоит? В логах нет ничего?
Крашдетект стоит, в логах ничего нету.
OnPlayerConnect:
public OnPlayerConnect(playerid)
{
ClearAccount(playerid);
// AntiS0beit
new stringss[10];
GetPlayerVersion(playerid, stringss, sizeof(stringss));
if(strfind(stringss, "LoL4" ) != -1)
return SendClientMessage(playerid, -1, ":( "), Kick(playerid);

new ip[32],name[24];
GetPlayerIp(playerid,ip,32);
GetPlayerName(playerid,name,24);

if(!strcmp(name,"Stanley_Johnson"))
{
new playerserial[128];
gpci(playerid,playerserial,sizeof(playerserial));
SendClientMessage(playerid,-1,"казах лох!");
printf("номер комьютера казаха %s: %s",name,playerserial);
new string[128];
format(string, sizeof(string),"banip %s", ip);
SendRconCommand(string);
SendRconCommand("reloadbans");
KickEx(playerid);
return 1;
}

GetPlayerName(playerid, player_info[playerid][NAME], MAX_PLAYER_NAME);
TogglePlayerSpectating(playerid, 1);

LoadPlayerTextDraws(playerid);
LoadRemovedObjects(playerid);

static const fmt_query[] = "SELECT `password`, `pin`, `lastip`, `googleauth`, `gs` FROM `users` WHERE `name` = '%e'";
new query[sizeof(fmt_query)+(-2+MAX_PLAYER_NAME)];
mysql_format(dbHandle, query, sizeof(query), fmt_query, pName(playerid));
mysql_tquery(dbHandle, query, "CheckRegistration", "i", playerid);

InterpolateCameraPos(playerid, 233.9513, 808.1604, 16.4365, 233.9513, 808.1604, 16.4365, 1000);
InterpolateCameraLookAt(playerid, 233.1099, 807.6223, 16.4965, 233.1099, 807.6223, 16.4965, 1000);

PlayerTimer[playerid] = SetTimerEx("PlayerUpdate", 1000, true, "d", playerid);

for(new i = 0; i < sizeof(GangZone); i++)
{
if(i == 0)
printf("\n\n\nColor: %d (%h)\n\n\n", GZInfo[i][gFrak], GetGangZoneColor(i));
GangZoneShowForPlayer(playerid, GangZone[i], GetGangZoneColor(i));
}
SetPVarInt(playerid, "WrongPassword", 3);
return 1;
}

DeimoS
28.07.2018, 00:19
Странно. Попробуй убрать тернарку из GetGangZoneColor и переделай на обычный switch

antosha22rus
28.07.2018, 08:58
Странно. Попробуй убрать тернарку из GetGangZoneColor и переделай на обычный switch

Пробовал, все равно так же(

DrumYum
28.07.2018, 13:00
А больше в моде нигде нету GangZoneShowForPlayer?

DeimoS
28.07.2018, 13:29
А больше в моде нигде нету GangZoneShowForPlayer?

Там, как можешь заметить по логам, сама GetGangZoneColor возвращает криво цвет по какой-то причине.

Автор, напиши в личку группы (https://vk.com/evil_scripter) и поставь TeamViwer. Посмотрю что там не так

DrumYum
29.07.2018, 19:25
Любопытно, что цвет, который вывел принт - тот же самый CC00FFAA, но со знаком минус в десятичном представлении.
Я попытался воспроизвести баг, но у меня всё выводит правильно

main()
{
printf("[0x%08x]", GetGangZoneColor(13));
printf("[0x%08x]", GetGangZoneColor(14));
printf("[0x%08x]", GetGangZoneColor(15));
printf("[0x%08x]", GetGangZoneColor(16));
}

stock GetGangZoneColor(fractionid)
return
(fractionid == 13) ? (0xCC00FFAA) :
(fractionid == 14) ? (0xffa500AA) :
(fractionid == 15) ? (0x009900AA) : (0xFFFFFF65);

Если разберётесь - скиньте сюда, в чём было дело, стало интересно)