PDA

Просмотр полной версии : [Вопрос] Быдлокод + easyDialog + PVar



Kovshevoy
30.10.2018, 00:42
Вечер добрый, джентльмены. У меня возникли некие трудности при написании одной из систем. Собственно вот код:
enum qInfo
{
Question[355],
Answer1[355],
Answer2[355],
Answer3[355],
Answer4[355],
RightAnswer
};

stock GenerateQuestion(playerid, bool:next)
{
new question;
if(next == true)
{
SetPVarInt(playerid, "QuestionNumber", GetPVarInt(playerid, "QuestionNumber") + 1);
SetPVarInt(playerid, "Question", random(4));
}
question = (GetPVarInt(playerid, "QuestionNumber") - 1) * 4 + GetPVarInt(playerid, "Question");

Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
"{"DPrefix"}Вопрос %i из 12",
"{"DWhite"}%s\n\n\
{"DPrefix"}1. {"DWhite"}%s\n\
{"DPrefix"}2. {"DWhite"}%s\n\
{"DPrefix"}3. {"DWhite"}%s\n\
{"DPrefix"}4. {"DWhite"}%s",
"Далее",
"Назад",
GetPVarInt(playerid, "QuestionNumber"),
Questions[question][Question],
Questions[question][Answer1],
Questions[question][Answer2],
Questions[question][Answer3],
Questions[question][Answer4]);

if(next == false)
return Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
"{"DPrefix"}Вопрос %i из 12",
"{"DWhite"}%s\n\n\
{"DPrefix"}1. {"DWhite"}%s\n\
{"DPrefix"}2. {"DWhite"}%s\n\
{"DPrefix"}3. {"DWhite"}%s\n\
{"DPrefix"}4. {"DWhite"}%s\n\n\
{"DPrefix"}Вариант ответа должен быть от 1 до 4.",
"Далее",
"Назад",
GetPVarInt(playerid, "QuestionNumber"),
Questions[question][Question],
Questions[question][Answer1],
Questions[question][Answer2],
Questions[question][Answer3],
Questions[question][Answer4]);
return 1;
}
Dialog:d_rp_test(playerid, response, listitem, inputtext[])
{
if(strval(inputtext) > 4 || strval(inputtext) < 1) return GenerateQuestion(playerid, false);

if(strval(inputtext) != Questions[(GetPVarInt(playerid, "QuestionNumber") - 1) * 4 + GetPVarInt(playerid, "Question")][RightAnswer])
{
SetPVarInt(playerid, "QuestionErrors", GetPVarInt(playerid, "QuestionErrors") + 1);
}
if(strval(inputtext) == Questions[(GetPVarInt(playerid, "QuestionNumber") - 1) * 4 + GetPVarInt(playerid, "Question")][RightAnswer])
{
SetPVarInt(playerid, "QuestionRight", GetPVarInt(playerid, "QuestionRight") + 1);
}


if(GetPVarInt(playerid, "QuestionNumber") == 12)
{
if(GetPVarInt(playerid, "QuestionErrors") >= 3)
{
Dialog_Show(playerid, d_none, DIALOG_STYLE_MSGBOX,
"{"DPrefix"}Тестирование провалено",
"{"DYellow"}Тестирование провалено!\n\n\
{"DGreen"}Правильно: {"DPrefix"}%i\n\
{"DRed"}Неправильно: {"DPrefix"}%i\n\n\
Вы не справились с тестированием. Пересдача возможна через полчаса.",
"Далее",
"",
GetPVarInt(playerid, "QuestionRight"),
GetPVarInt(playerid, "QuestionErrors"));

MySQL_SaveInt(playerid, "accounts", "player_rp_test", player[playerid][pRPTest]);
MySQL_SaveInt(playerid, "accounts", "player_rp_time", player[playerid][pRPTime]);
}
else
{

Dialog_Show(playerid, d_none, DIALOG_STYLE_MSGBOX,
"{"DPrefix"}Тестирование завершено",
"{"DYellow"}Тестирование завершено!\n\n\
{"DGreen"}Правильно: {"DPrefix"}%i\n\
{"DRed"}Неправильно: {"DPrefix"}%i\n\n\
Вы справились с тестированием и теперь можете вступить в организацию.",
"Далее",
"",
GetPVarInt(playerid, "QuestionRight"),
GetPVarInt(playerid, "QuestionErrors"));
}
DeletePVar(playerid, "QuestionNumber");
DeletePVar(playerid, "Question");
DeletePVar(playerid, "QuestionRight");
DeletePVar(playerid, "QuestionErrors");
}
else GenerateQuestion(playerid, true);
return true;
}

CMD:rptest(playerid, const params[])
{
if(player[playerid][pRPTest] == 1) return SCM(playerid, -1, "Вы уже сдали тест на знание Role Play.");
if(player[playerid][pRPTime] > 0)
{
new string[70];
format(string, sizeof(string), "До повторной сдачи теста осталось {"DPrefix"}%s {FFFFFF}минут.", Convert(player[playerid][pRPTime]));
SCM(playerid, -1, string);
return 1;
}
else
{
SetPVarInt(playerid, "QuestionNumber", 0);
SetPVarInt(playerid, "QuestionErrors", 0);
player_temp[playerid][rp_test_timer] = 6000;
GenerateQuestion(playerid, true);
}
return 1;
}

А вот собсна скриншот, как это сие действие выглядит на сервере:

https://i.imgur.com/gVIfuBi.png

ziggi
30.10.2018, 02:00
caption диалога нужно форматировать отдельно.

Типа так

new caption[32];
format(caption, sizeof(caption), "{"DPrefix"}Вопрос %i из 12", GetPVarInt(playerid, "QuestionNumber"));
Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
caption,
"{"DWhite"}%s\n\n\
{"DPrefix"}1. {"DWhite"}%s\n\
{"DPrefix"}2. {"DWhite"}%s\n\
{"DPrefix"}3. {"DWhite"}%s\n\
{"DPrefix"}4. {"DWhite"}%s",
"Далее",
"Назад",
Questions[question][Question],
Questions[question][Answer1],
Questions[question][Answer2],
Questions[question][Answer3],
Questions[question][Answer4]);

P.S. Разве easyDialog поддерживает форматирование текста в Dialog_Show?

Kovshevoy
30.10.2018, 09:08
caption диалога нужно форматировать отдельно.

Типа так

new caption[32];
format(caption, sizeof(caption), "{"DPrefix"}Вопрос %i из 12", GetPVarInt(playerid, "QuestionNumber"));
Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
caption,
"{"DWhite"}%s\n\n\
{"DPrefix"}1. {"DWhite"}%s\n\
{"DPrefix"}2. {"DWhite"}%s\n\
{"DPrefix"}3. {"DWhite"}%s\n\
{"DPrefix"}4. {"DWhite"}%s",
"Далее",
"Назад",
Questions[question][Question],
Questions[question][Answer1],
Questions[question][Answer2],
Questions[question][Answer3],
Questions[question][Answer4]);

P.S. Разве easyDialog поддерживает форматирование текста в Dialog_Show?

Да, поддерживает. По крайней мере в той версии, что я скачал - да. Southclaws'а версия вроде как.
Спасибо за помощь <3

Kovshevoy
01.11.2018, 22:54
Когда показывает Вопрос 8 из 12, не перекидывает на 9 вопрос после любого из вариантов ответов, в чём может быть проблема?

ziggi
02.11.2018, 00:05
Когда показывает Вопрос 8 из 12, не перекидывает на 9 вопрос после любого из вариантов ответов, в чём может быть проблема?

Выход за пределы массива? crashdetect стоит?

Kovshevoy
02.11.2018, 10:38
Выход за пределы массива? crashdetect стоит?

Не стоит, прину домой поставлю и сброшу лог.