Plugin działa, lecz po podaniu odpowiedniej odpowiedzi nic się nie dzieje, nie przyznaje nagród.
Chciałbym aby:
1. Zostało naprawione przyznawanie nagród
2. Zostały usunięte napisy z hud a zamiast tego dodać informacje na czacie.
#include <amxmodx> #include <amxmisc> #include <ColorChat> #include <fakemeta_util> #if cellbits == 32 #define OFFSET_CSMONEY 115 #else #define OFFSET_CSMONEY 140 #endif enum FastAnsInfo { Array:InfoQuestion, Array:InfoAnsewer } new Array:gaFastAnsInfo[FastAnsInfo] new giQuestion, giHudTimes; public plugin_init() { register_plugin("Fast Ansewer", "0.1", "MarWit") register_clcmd("say", "handleSay") register_clcmd("say_team", "handleSay") gaFastAnsInfo[InfoQuestion] = ArrayCreate(256) gaFastAnsInfo[InfoAnsewer] = ArrayCreate(192) LoadConfigFile(); set_task(random_float(90.0, 190.0), "SayQuestion", _, _, _, "b"); } public LoadConfigFile() { new szFile[128] get_configsdir(szFile, charsmax(szFile)) format(szFile, 127, "%s/quizy.ini", szFile) new iFile; if(!(iFile = fopen(szFile, "r"))) set_fail_state("[Fast Ansewer] Nie ma pliku quiz.ini!") new szBuffer[512], szFastAnsQuestion[256], szFastAnsAnsewer[192] while(!feof(iFile)) { fgets(iFile, szBuffer, 511) trim(szBuffer) if(!szBuffer[0] || szBuffer[0] == ';' || szBuffer[0] == ' ') continue; parse(szBuffer, szFastAnsQuestion, 255, szFastAnsAnsewer, 191); remove_quotes(szFastAnsQuestion); remove_quotes(szFastAnsAnsewer); ArrayPushString(gaFastAnsInfo[InfoQuestion], szFastAnsQuestion) ArrayPushString(gaFastAnsInfo[InfoAnsewer], szFastAnsAnsewer) } if(!ArraySize(gaFastAnsInfo[InfoQuestion])) log_amx("[Fast Ansewer] W pliku nie ma zadnych pytan!"); else log_amx("[Fast Ansewer] Zaladowano %d pytan!", ArraySize(gaFastAnsInfo[InfoQuestion])); } public handleSay(id) { if(giQuestion == -1) return PLUGIN_CONTINUE new szBuffer[192], szAnsewer[192]; read_args(szBuffer, 191); ArrayGetString(gaFastAnsInfo[InfoAnsewer], giQuestion, szAnsewer, 191); if(equali(szBuffer, szAnsewer)) GiveAward(id); return PLUGIN_CONTINUE } public SayQuestion() { new giQuestion = random_num(0, ArraySize(gaFastAnsInfo[InfoQuestion])); new szBuffer[256]; ArrayGetString(gaFastAnsInfo[InfoQuestion], giQuestion, szBuffer, 255); ColorChat(0, RED, "[Fast Ansewer]^x01 %s", szBuffer); set_task(1.0, "_taskHud", 9741, _, _, "a", 10) giHudTimes = 10; } public GiveAward(id) { remove_task(9741); giHudTimes = 0; giQuestion = -1; new szName[64], iAwardAmount; get_user_name(id, szName, 63); set_hudmessage(255, 0, 0, -1.0, 0.01, 0, 0.1, 3.0, 0.1, 0.1) switch(random(1)) { case 0: { iAwardAmount = random_num(1, 8); show_hudmessage(0, "[Fast Ansewer]^x01 %s za poprawna odpowiedz dostal %d fragow!", szName, iAwardAmount); set_pev(id, pev_frags, float(pev(id, pev_frags)+iAwardAmount)) message_begin(MSG_ALL, get_user_msgid("ScoreInfo")); write_byte(id); write_short(pev(id, pev_frags)); write_short(get_user_deaths(id)); write_short(0); write_short(pev(id, pev_team)); message_end(); } case 1: { iAwardAmount = random_num(800, 16000); iAwardAmount = get_pdata_int(id, OFFSET_CSMONEY, 5) + iAwardAmount > 16000 ? 16000 : iAwardAmount; show_hudmessage(0, "[Fast Ansewer]^x01 %s za poprawna odpowiedz dostal +%d $!", szName, iAwardAmount); set_pdata_int(id, OFFSET_CSMONEY, iAwardAmount, 5); message_begin(MSG_ONE, get_user_msgid("Money"), {0, 0, 0}, id); write_long(iAwardAmount); write_byte(1); message_end(); } } } public _taskHud(iTask) { if(--giHudTimes > 0) { set_hudmessage(255, 0, 0, -1.0, 0.01, 0, 0.1, 3.0, 0.1, 0.1) show_hudmessage(0, "[Fast Ansewer]^x01 Zostalo %d sekund!", giHudTimes) } else { set_hudmessage(255, 0, 0, -1.0, 0.01, 0, 0.1, 3.0, 0.1, 0.1) show_hudmessage(0, "[Fast Ansewer]^x01 Niestety, nikt nie wygral <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/sad.png' class='bbc_emoticon' alt=':(' />") giHudTimes = 0; giQuestion = -1; } }
Użytkownik Tomek179 edytował ten post 17.08.2012 13:32