RSSy MYGO.pl Opublikowano Wrzesień 25, 2020 o 17:34 RSSy Udostępnij Opublikowano Wrzesień 25, 2020 o 17:34 I need help with this plugin if i ask a question and someone write the right answer its not detect (always) the right answer? i dont know why?! Sometimes it works sometimes its not work Code: #include <amxmodx> #include <regex> #include <WPMGPrintChatColor> #define VERSION "1.0" #define TASKID_QUEST 123 new const g_szRegexPattern[] = "\/quest (.+?\?)\s*(.+)"; new Regex:g_QuestRegexPattern; new g_szUserQuestion[33][128], g_szUserAnswer[33][32]; new g_szQuestion[128], g_szAnswer[32]; new gp_QuestHoldTime; new g_iUnused, g_szUnused[2]; public plugin_init() { register_plugin("Admin Question", VERSION, "AMXX-BG.info"); register_cvar("admin_quest", VERSION, FCVAR_SPONLY | FCVAR_SERVER | FCVAR_UNLOGGED); register_clcmd("say", "CommandSayTyped"); register_clcmd("Question", "QuestionTyped"); register_clcmd("Answer", "AnswerTyped"); gp_QuestHoldTime = register_cvar("quest_holdtime", "20"); g_QuestRegexPattern = regex_compile(g_szRegexPattern, g_iUnused, g_szUnused, charsmax(g_szUnused)); } public QuestionTyped(id, lvl, cmdId) { if (!get_user_flags(id) & ADMIN_IMMUNITY) { return PLUGIN_CONTINUE; } if (read_argc() < 2) { return PLUGIN_HANDLED; } read_args(g_szUserQuestion[id], charsmax(g_szUserQuestion[])); remove_quotes(g_szUserQuestion[id]); ShowQuestMenu(id); return PLUGIN_HANDLED; } public AnswerTyped(id) { if (read_argc() < 2) { return PLUGIN_HANDLED; } read_args(g_szUserAnswer[id], charsmax(g_szUserAnswer[])); remove_quotes(g_szUserAnswer[id]); ShowQuestMenu(id); return PLUGIN_HANDLED; } public CommandSayTyped(id) { new szSaid[156]; read_args(szSaid, charsmax(szSaid)); remove_quotes(szSaid); if (equali(szSaid, "/quest", 6)) { if (!get_user_flags(id) & ADMIN_IMMUNITY) { return PLUGIN_HANDLED; } if (regex_match_c(szSaid, g_QuestRegexPattern, g_iUnused) > 0) { new szQuestion[128], szAnswer[32]; regex_substr(g_QuestRegexPattern, 1, szQuestion, charsmax(szQuestion)); regex_substr(g_QuestRegexPattern, 2, szAnswer, charsmax(szAnswer)); trim(szQuestion); trim(szAnswer); StartQuest(id, szQuestion, szAnswer); } else { ShowQuestMenu(id); } return PLUGIN_HANDLED; } if (!task_exists(TASKID_QUEST)) { return PLUGIN_CONTINUE; } if (equali(szSaid, g_szAnswer) && get_user_team(id) == 1 && is_user_alive(id)) { EndQuest(TASKID_QUEST + id); } return PLUGIN_CONTINUE; } ShowQuestMenu(id) { new iMenu = menu_create("Quest Game", "QuestGameHandler"); new szQuestionItem[156], szAnswerItem[64]; formatex(szQuestionItem, charsmax(szQuestionItem), "Question \y%s", g_szUserQuestion[id]); formatex(szAnswerItem, charsmax(szAnswerItem), "Answer \y%s", g_szUserAnswer[id]); menu_additem(iMenu, szQuestionItem); menu_additem(iMenu, szAnswerItem); menu_addblank(iMenu, 0); menu_additem(iMenu, "Start the quest"); menu_display(id, iMenu); } public QuestGameHandler(id, iMenu, Item) { if (Item == MENU_EXIT) { menu_destroy(iMenu); return; } switch (Item) { case 0: client_cmd(id, "messagemode Question"); case 1: client_cmd(id, "messagemode Answer"); case 2: { StartQuest(id, g_szUserQuestion[id], g_szUserAnswer[id]); menu_destroy(iMenu); return; } } menu_destroy(iMenu); ShowQuestMenu(id); } StartQuest(id, szQuestion[], szAnswer[]) { if (strlen(szQuestion) == 0 || strlen(szAnswer) == 0) { PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[!tQuest!g]!y You must type a valid question and answer in order to start the game!"); return; } copy(g_szQuestion, charsmax(g_szQuestion), szQuestion); copy(g_szAnswer, charsmax(g_szAnswer), szAnswer); copy(g_szUserAnswer[id], charsmax(g_szUserAnswer[]), ""); copy(g_szUserQuestion[id], charsmax(g_szUserQuestion[]), ""); new szName2[32] get_user_name(id, szName2, charsmax(szName2)) PrintChatColor(0, PRINT_COLOR_PLAYERTEAM, "!g[!tQuest!g]!y Admin !g%s !ystarted the quest game! You have !t%d seconds !yto answer the question!", szName2, get_pcvar_num(gp_QuestHoldTime)); PrintChatColor(0, PRINT_COLOR_PLAYERTEAM, "!g[!tQuest!g]!y Question: !g%s", g_szQuestion); set_task(get_pcvar_float(gp_QuestHoldTime), "EndQuest", TASKID_QUEST); } public EndQuest(taskid) { new id = taskid - TASKID_QUEST; if (!is_user_connected(id)) { PrintChatColor(0, PRINT_COLOR_PLAYERTEAM, "!g[!tQuest!g]!y No one answered the question. The answer is!t %s", g_szAnswer); } else { new szName[32]; get_user_name(id, szName, charsmax(szName)); PrintChatColor(0, PRINT_COLOR_PLAYERTEAM, "!g[!tQuest!g]!g %s!y has won the game! The answer is!t %s", szName, g_szAnswer); } copy(g_szAnswer, charsmax(g_szAnswer), ""); copy(g_szQuestion, charsmax(g_szQuestion), ""); remove_task(TASKID_QUEST); } Przeczytaj cały wpis Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi