Добро пожаловать на Pro Pawn - Портал о PAWN-скриптинге.
Показано с 1 по 6 из 6
  1. #1
    Аватар для Kovshevoy
    Пользователь

    Статус
    Оффлайн
    Регистрация
    11.07.2015
    Сообщений
    190
    Репутация:
    25 ±

    Быдлокод + easyDialog + PVar

    Вечер добрый, джентльмены. У меня возникли некие трудности при написании одной из систем. Собственно вот код:
      Открыть/закрыть
    1. enum qInfo
    2. {
    3. Question[355],
    4. Answer1[355],
    5. Answer2[355],
    6. Answer3[355],
    7. Answer4[355],
    8. RightAnswer
    9. };
    10.  
    11. stock GenerateQuestion(playerid, bool:next)
    12. {
    13. new question;
    14. if(next == true)
    15. {
    16. SetPVarInt(playerid, "QuestionNumber", GetPVarInt(playerid, "QuestionNumber") + 1);
    17. SetPVarInt(playerid, "Question", random(4));
    18. }
    19. question = (GetPVarInt(playerid, "QuestionNumber") - 1) * 4 + GetPVarInt(playerid, "Question");
    20.  
    21. Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
    22. "{"DPrefix"}Вопрос %i из 12",
    23. "{"DWhite"}%s\n\n\
    24. {"DPrefix"}1. {"DWhite"}%s\n\
    25. {"DPrefix"}2. {"DWhite"}%s\n\
    26. {"DPrefix"}3. {"DWhite"}%s\n\
    27. {"DPrefix"}4. {"DWhite"}%s",
    28. "Далее",
    29. "Назад",
    30. GetPVarInt(playerid, "QuestionNumber"),
    31. Questions[question][Question],
    32. Questions[question][Answer1],
    33. Questions[question][Answer2],
    34. Questions[question][Answer3],
    35. Questions[question][Answer4]);
    36.  
    37. if(next == false)
    38. return Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
    39. "{"DPrefix"}Вопрос %i из 12",
    40. "{"DWhite"}%s\n\n\
    41. {"DPrefix"}1. {"DWhite"}%s\n\
    42. {"DPrefix"}2. {"DWhite"}%s\n\
    43. {"DPrefix"}3. {"DWhite"}%s\n\
    44. {"DPrefix"}4. {"DWhite"}%s\n\n\
    45. {"DPrefix"}Вариант ответа должен быть от 1 до 4.",
    46. "Далее",
    47. "Назад",
    48. GetPVarInt(playerid, "QuestionNumber"),
    49. Questions[question][Question],
    50. Questions[question][Answer1],
    51. Questions[question][Answer2],
    52. Questions[question][Answer3],
    53. Questions[question][Answer4]);
    54. return 1;
    55. }
    56. Dialog:d_rp_test(playerid, response, listitem, inputtext[])
    57. {
    58. if(strval(inputtext) > 4 || strval(inputtext) < 1) return GenerateQuestion(playerid, false);
    59.  
    60. if(strval(inputtext) != Questions[(GetPVarInt(playerid, "QuestionNumber") - 1) * 4 + GetPVarInt(playerid, "Question")][RightAnswer])
    61. {
    62. SetPVarInt(playerid, "QuestionErrors", GetPVarInt(playerid, "QuestionErrors") + 1);
    63. }
    64. if(strval(inputtext) == Questions[(GetPVarInt(playerid, "QuestionNumber") - 1) * 4 + GetPVarInt(playerid, "Question")][RightAnswer])
    65. {
    66. SetPVarInt(playerid, "QuestionRight", GetPVarInt(playerid, "QuestionRight") + 1);
    67. }
    68.  
    69.  
    70. if(GetPVarInt(playerid, "QuestionNumber") == 12)
    71. {
    72. if(GetPVarInt(playerid, "QuestionErrors") >= 3)
    73. {
    74. Dialog_Show(playerid, d_none, DIALOG_STYLE_MSGBOX,
    75. "{"DPrefix"}Тестирование провалено",
    76. "{"DYellow"}Тестирование провалено!\n\n\
    77. {"DGreen"}Правильно: {"DPrefix"}%i\n\
    78. {"DRed"}Неправильно: {"DPrefix"}%i\n\n\
    79. Вы не справились с тестированием. Пересдача возможна через полчаса.",
    80. "Далее",
    81. "",
    82. GetPVarInt(playerid, "QuestionRight"),
    83. GetPVarInt(playerid, "QuestionErrors"));
    84.  
    85. MySQL_SaveInt(playerid, "accounts", "player_rp_test", player[playerid][pRPTest]);
    86. MySQL_SaveInt(playerid, "accounts", "player_rp_time", player[playerid][pRPTime]);
    87. }
    88. else
    89. {
    90.  
    91. Dialog_Show(playerid, d_none, DIALOG_STYLE_MSGBOX,
    92. "{"DPrefix"}Тестирование завершено",
    93. "{"DYellow"}Тестирование завершено!\n\n\
    94. {"DGreen"}Правильно: {"DPrefix"}%i\n\
    95. {"DRed"}Неправильно: {"DPrefix"}%i\n\n\
    96. Вы справились с тестированием и теперь можете вступить в организацию.",
    97. "Далее",
    98. "",
    99. GetPVarInt(playerid, "QuestionRight"),
    100. GetPVarInt(playerid, "QuestionErrors"));
    101. }
    102. DeletePVar(playerid, "QuestionNumber");
    103. DeletePVar(playerid, "Question");
    104. DeletePVar(playerid, "QuestionRight");
    105. DeletePVar(playerid, "QuestionErrors");
    106. }
    107. else GenerateQuestion(playerid, true);
    108. return true;
    109. }
    110.  
    111. CMD:rptest(playerid, const params[])
    112. {
    113. if(player[playerid][pRPTest] == 1) return SCM(playerid, -1, "Вы уже сдали тест на знание Role Play.");
    114. if(player[playerid][pRPTime] > 0)
    115. {
    116. new string[70];
    117. format(string, sizeof(string), "До повторной сдачи теста осталось {"DPrefix"}%s {FFFFFF}минут.", Convert(player[playerid][pRPTime]));
    118. SCM(playerid, -1, string);
    119. return 1;
    120. }
    121. else
    122. {
    123. SetPVarInt(playerid, "QuestionNumber", 0);
    124. SetPVarInt(playerid, "QuestionErrors", 0);
    125. player_temp[playerid][rp_test_timer] = 6000;
    126. GenerateQuestion(playerid, true);
    127. }
    128. return 1;
    129. }


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

      Открыть/закрыть

  2. #2
    Аватар для ziggi
    Проверенный

    Статус
    Оффлайн
    Регистрация
    14.05.2015
    Сообщений
    1,181
    Репутация:
    790 ±
    caption диалога нужно форматировать отдельно.

    Типа так
    1. new caption[32];
    2. format(caption, sizeof(caption), "{"DPrefix"}Вопрос %i из 12", GetPVarInt(playerid, "QuestionNumber"));
    3. Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
    4. caption,
    5. "{"DWhite"}%s\n\n\
    6. {"DPrefix"}1. {"DWhite"}%s\n\
    7. {"DPrefix"}2. {"DWhite"}%s\n\
    8. {"DPrefix"}3. {"DWhite"}%s\n\
    9. {"DPrefix"}4. {"DWhite"}%s",
    10. "Далее",
    11. "Назад",
    12. Questions[question][Question],
    13. Questions[question][Answer1],
    14. Questions[question][Answer2],
    15. Questions[question][Answer3],
    16. Questions[question][Answer4]);


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

  3. #3
    Аватар для Kovshevoy
    Пользователь

    Статус
    Оффлайн
    Регистрация
    11.07.2015
    Сообщений
    190
    Репутация:
    25 ±
    Цитата Сообщение от ziggi Посмотреть сообщение
    caption диалога нужно форматировать отдельно.

    Типа так
    1. new caption[32];
    2. format(caption, sizeof(caption), "{"DPrefix"}Вопрос %i из 12", GetPVarInt(playerid, "QuestionNumber"));
    3. Dialog_Show(playerid, d_rp_test, DIALOG_STYLE_INPUT,
    4. caption,
    5. "{"DWhite"}%s\n\n\
    6. {"DPrefix"}1. {"DWhite"}%s\n\
    7. {"DPrefix"}2. {"DWhite"}%s\n\
    8. {"DPrefix"}3. {"DWhite"}%s\n\
    9. {"DPrefix"}4. {"DWhite"}%s",
    10. "Далее",
    11. "Назад",
    12. Questions[question][Question],
    13. Questions[question][Answer1],
    14. Questions[question][Answer2],
    15. Questions[question][Answer3],
    16. Questions[question][Answer4]);


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

  4. #4
    Аватар для Kovshevoy
    Пользователь

    Статус
    Оффлайн
    Регистрация
    11.07.2015
    Сообщений
    190
    Репутация:
    25 ±
    Когда показывает Вопрос 8 из 12, не перекидывает на 9 вопрос после любого из вариантов ответов, в чём может быть проблема?

  5. #5
    Аватар для ziggi
    Проверенный

    Статус
    Оффлайн
    Регистрация
    14.05.2015
    Сообщений
    1,181
    Репутация:
    790 ±
    Цитата Сообщение от NichWell Посмотреть сообщение
    Когда показывает Вопрос 8 из 12, не перекидывает на 9 вопрос после любого из вариантов ответов, в чём может быть проблема?
    Выход за пределы массива? crashdetect стоит?

  6. #6
    Аватар для Kovshevoy
    Пользователь

    Статус
    Оффлайн
    Регистрация
    11.07.2015
    Сообщений
    190
    Репутация:
    25 ±
    Цитата Сообщение от ziggi Посмотреть сообщение
    Выход за пределы массива? crashdetect стоит?
    Не стоит, прину домой поставлю и сброшу лог.

 

 

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •