Mich@elson
09.12.2017, 02:00
Подскажите пожалуйста.
Суть бага:
К примеру,в репорт поступает две жалобы. На сервере два админа онлайн.
Когда первый админ вводит команду /areport - ему показыват диалоговое окно с жалобой от игрока.
Когда второй админ вводит команду /areport - ему показывает ту же самую жалобу что и первому админу - это баг.
Вопрос: как сделать чтобы другим админам не показывало диалоговое окно с жалобой которую уже рассматривает кто-то из админов? Админ который уже рассматривает жалобу в диалоговом окне, а другим админам показывало другие жалобы.
Команда подачи жалобы и команда для админов.
CMD:report(playerid, params[])
{
if(isnull(params)) return SCM(playerid, -1, !"Используйте: /report [текст]");
if(GetPVarInt(playerid, "report_id")) return SCM(playerid, COLOR_GREY, !"Вы уже отправили жалобу. Ожидайте ответ.");
format(YCMDstr, sizeof(YCMDstr), "Жалоба: %s", params);
SCM(playerid, COLOR_YELLOW, YCMDstr);
format(YCMDstr,sizeof(YCMDstr), "Репорт %s[%d]: %s", Name(playerid), playerid, params);
SendAdminMessage(0x00a86bAA,YCMDstr);
for(new i = 1; i < MAX_ADMIN_REPORTS; i++)
{
if(aReportInfo[i][rPlayerID] != -1) continue;
aReportInfo[i][rIsTooked] = false;
aReportInfo[i][rID] = i;
aReportInfo[i][rPlayerID] = playerid;
format(YCMDstr, sizeof(YCMDstr), "%s", params);
strmid(aReportInfo[i][rText], YCMDstr, 0, MAX_REPORT_TEXT, MAX_REPORT_TEXT);
aReportInfo[i][rWhenWroted_Time] = gettime();
SetPVarInt(playerid, "report_id", i);
break;
}
return 1;
}
CMD:areport(playerid, params[])// Просмотр репорта администрацией
{
if(PI[playerid][pAdmin] < 1 || GetPVarInt(playerid,"ALogin") == 0) return true;
ShowPlayer_Admin_Report_List(playerid);
return 1;
}
Вызов ShowPlayer_Admin_Report_List
stock ShowPlayer_Admin_Report_List(playerid)
{
new string[256], total_admin_reports = 0;
for(new i = 1; i < MAX_ADMIN_REPORTS; i++)
{
if(aReportInfo[i][rPlayerID] == -1) continue;
SetPVarInt(playerid, "report_id_to_answer", i);
aReportInfo[i][rIsTooked] = true;
format(string, sizeof(string), "Репорт от: %s\n\n%s", Name(aReportInfo[i][rPlayerID]), aReportInfo[i][rText]);
total_admin_reports++;
}
if(total_admin_reports == 0) return ShowPlayerDialogEx(playerid, 823, 0, "Репорт", "Жалобы/Вопросы отсутствуют", "Назад", "");
ShowPlayerDialogEx(playerid, 6133, DIALOG_STYLE_INPUT, "Репорт", string, "Ответить", "Отмена");
return 1;
}
case 6133
case 6133:
{
if(!response)
{
aReportInfo[GetPVarInt(playerid, "report_id_to_answer")][rIsTooked] = false;
DeletePVar(playerid, "report_id_to_answer");
}
else
{
new report_id = GetPVarInt(playerid, "report_id_to_answer"), target_id = aReportInfo[report_id][rPlayerID];
if(target_id == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREEN, !"Игрок вышел с сервера!");
static const target_msg[] = "Ответ от %s[%d]: %s", admins_msg[] = "%s[%d] к %s[%d]: %s";
new strings[sizeof(admins_msg) + (-2+MAX_PLAYER_NAME)*2 + (-2+90)];
format(strings, sizeof(strings), admins_msg, Name(playerid), playerid, Name(target_id), target_id, inputtext);
SendAdminMessage(COLOR_GREEN, strings);
format(strings, sizeof(strings), target_msg, Name(playerid), playerid, inputtext);
SCM(target_id, COLOR_YELLOW, strings);
DeletePVar(target_id, "report_id");
aReportInfo[report_id][rIsTooked] = false;
aReportInfo[report_id][rID] = report_id;
aReportInfo[report_id][rPlayerID] = -1;
aReportInfo[report_id][rText][0] = EOS;
aReportInfo[report_id][rWhenWroted_Time] = -1;
}
}
Суть бага:
К примеру,в репорт поступает две жалобы. На сервере два админа онлайн.
Когда первый админ вводит команду /areport - ему показыват диалоговое окно с жалобой от игрока.
Когда второй админ вводит команду /areport - ему показывает ту же самую жалобу что и первому админу - это баг.
Вопрос: как сделать чтобы другим админам не показывало диалоговое окно с жалобой которую уже рассматривает кто-то из админов? Админ который уже рассматривает жалобу в диалоговом окне, а другим админам показывало другие жалобы.
Команда подачи жалобы и команда для админов.
CMD:report(playerid, params[])
{
if(isnull(params)) return SCM(playerid, -1, !"Используйте: /report [текст]");
if(GetPVarInt(playerid, "report_id")) return SCM(playerid, COLOR_GREY, !"Вы уже отправили жалобу. Ожидайте ответ.");
format(YCMDstr, sizeof(YCMDstr), "Жалоба: %s", params);
SCM(playerid, COLOR_YELLOW, YCMDstr);
format(YCMDstr,sizeof(YCMDstr), "Репорт %s[%d]: %s", Name(playerid), playerid, params);
SendAdminMessage(0x00a86bAA,YCMDstr);
for(new i = 1; i < MAX_ADMIN_REPORTS; i++)
{
if(aReportInfo[i][rPlayerID] != -1) continue;
aReportInfo[i][rIsTooked] = false;
aReportInfo[i][rID] = i;
aReportInfo[i][rPlayerID] = playerid;
format(YCMDstr, sizeof(YCMDstr), "%s", params);
strmid(aReportInfo[i][rText], YCMDstr, 0, MAX_REPORT_TEXT, MAX_REPORT_TEXT);
aReportInfo[i][rWhenWroted_Time] = gettime();
SetPVarInt(playerid, "report_id", i);
break;
}
return 1;
}
CMD:areport(playerid, params[])// Просмотр репорта администрацией
{
if(PI[playerid][pAdmin] < 1 || GetPVarInt(playerid,"ALogin") == 0) return true;
ShowPlayer_Admin_Report_List(playerid);
return 1;
}
Вызов ShowPlayer_Admin_Report_List
stock ShowPlayer_Admin_Report_List(playerid)
{
new string[256], total_admin_reports = 0;
for(new i = 1; i < MAX_ADMIN_REPORTS; i++)
{
if(aReportInfo[i][rPlayerID] == -1) continue;
SetPVarInt(playerid, "report_id_to_answer", i);
aReportInfo[i][rIsTooked] = true;
format(string, sizeof(string), "Репорт от: %s\n\n%s", Name(aReportInfo[i][rPlayerID]), aReportInfo[i][rText]);
total_admin_reports++;
}
if(total_admin_reports == 0) return ShowPlayerDialogEx(playerid, 823, 0, "Репорт", "Жалобы/Вопросы отсутствуют", "Назад", "");
ShowPlayerDialogEx(playerid, 6133, DIALOG_STYLE_INPUT, "Репорт", string, "Ответить", "Отмена");
return 1;
}
case 6133
case 6133:
{
if(!response)
{
aReportInfo[GetPVarInt(playerid, "report_id_to_answer")][rIsTooked] = false;
DeletePVar(playerid, "report_id_to_answer");
}
else
{
new report_id = GetPVarInt(playerid, "report_id_to_answer"), target_id = aReportInfo[report_id][rPlayerID];
if(target_id == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREEN, !"Игрок вышел с сервера!");
static const target_msg[] = "Ответ от %s[%d]: %s", admins_msg[] = "%s[%d] к %s[%d]: %s";
new strings[sizeof(admins_msg) + (-2+MAX_PLAYER_NAME)*2 + (-2+90)];
format(strings, sizeof(strings), admins_msg, Name(playerid), playerid, Name(target_id), target_id, inputtext);
SendAdminMessage(COLOR_GREEN, strings);
format(strings, sizeof(strings), target_msg, Name(playerid), playerid, inputtext);
SCM(target_id, COLOR_YELLOW, strings);
DeletePVar(target_id, "report_id");
aReportInfo[report_id][rIsTooked] = false;
aReportInfo[report_id][rID] = report_id;
aReportInfo[report_id][rPlayerID] = -1;
aReportInfo[report_id][rText][0] = EOS;
aReportInfo[report_id][rWhenWroted_Time] = -1;
}
}