Advertisement
JuSTaR

Hidonim [Unofficial-3]

Sep 30th, 2020
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.31 KB | None | 0 0
  1. #include <amxmodx>
  2. //#include <dhudmessage>
  3.  
  4. // Tasks
  5. #define HidonimGamesCount 6
  6. #define task_vote 1
  7. #define task_start_hidon 2
  8. #define task_hud 3
  9.  
  10. // Paths
  11. #define AnimeDefaultPath "sound/TopDeathrun/Anime/"
  12. #define NostalgiaDefaultPath "sound/TopDeathrun/Nostalgia/"
  13. #define LogoQuizHost "http://top-clan.000webhostapp.com/LogoQuiz/"
  14.  
  15. // Config Files
  16. #define MissingLetterCfgFile "addons/amxmodx/configs/Hidonim/missingletter.txt"
  17. #define LogoQuizCfgFile "addons/amxmodx/configs/Hidonim/logoquiz.txt"
  18. #define TriviaCfgFile "addons/amxmodx/configs/Hidonim/trivia.txt"
  19. #define AnimeCfgFile "addons/amxmodx/configs/Hidonim/anime.txt"
  20. #define NostalgiaCfgFile "addons/amxmodx/configs/Hidonim/nostalgia.txt"
  21.  
  22. // Constants
  23. #define MAX_QUESTIONS 64
  24. #define MAX_QUESTIONS_LENGTH 64
  25. #define MAX_ANSWER_LENGTH 32
  26. #define MAX_SONG_NAME 32
  27. #define MAX_PATH_SIZE 64
  28. #define MAX_ML_WORD_SIZE 32
  29.  
  30. native set_user_points(id, amount);
  31. native get_user_points(id);
  32.  
  33. enum _:HidonProperties
  34. {
  35.     name[32],
  36.     points
  37. }
  38.  
  39. enum _:SongProperties
  40. {
  41.     name[MAX_SONG_NAME],
  42.     file_name[MAX_PATH_SIZE]
  43. }
  44.  
  45. enum _:QuestionProperties
  46. {
  47.     Quest[MAX_QUESTIONS_LENGTH],
  48.     Answr[MAX_ANSWER_LENGTH]
  49. }
  50.  
  51. new const Hidon[][HidonProperties] =
  52. {
  53.     { "Math", 30 },
  54.     { "Nostalgia", 15 },
  55.     { "Anime", 20 },
  56.     { "Trivia", 25 },
  57.     { "LogoQuiz", 25 },
  58.     { "Missing Letter", 40 }
  59. }
  60.  
  61. new bool:HidonIsRunning = false;
  62. new GameCount = 0;
  63. new bool:isVoted[33];
  64. new VoteTimer = 100;
  65. new Votes[HidonimGamesCount];
  66. new ChoosenHidonId = -1;
  67. new StartHidonCD = 5;
  68. new WinnerId = -1;
  69. new WinnerName[33];
  70. new bool:ShowMsgOnce = false;
  71. new num1, num2;
  72. new HidonTimer = 60;
  73. new RndId = -1;
  74. new Answer[32];
  75. new MLWord[MAX_ML_WORD_SIZE];
  76. new ML_UpdateAmount = 0;
  77. new ML_LastIds[8] = { -1, -1, -1, -1, -1, -1 , -1 , -1 };
  78. new Float:ML_timer;
  79. new Array:MLWords_indexes;
  80. new HidonWaitingTime = 600;
  81. new sound[64];
  82. new AdminStartedHidon;
  83.  
  84. new NostalgiaSongsLoaded = 0;
  85. new AnimeSongsLoaded = 0;
  86. new TriviaQuestionsLoaded = 0;
  87. new LogoQuizQuestionsLoaded = 0;
  88. new MLQuestionsLoaded = 0;
  89.  
  90. new MLQuestions[MAX_QUESTIONS][MAX_ML_WORD_SIZE];
  91. new LogoQuizQuestions[MAX_QUESTIONS][QuestionProperties];
  92. new TriviaQuestions[MAX_QUESTIONS][QuestionProperties];
  93. new AnimeSongs[MAX_QUESTIONS][SongProperties];
  94. new NostalgiaSongs[MAX_QUESTIONS][SongProperties];
  95.  
  96.  
  97. public plugin_init()
  98. {
  99.     register_plugin("Hidonim", "v4", "JuSTaR (Original Idea by Ariel aka xBosh)");
  100.    
  101.     register_clcmd("say /start_hidon", "AdminMenu", ADMIN_RCON); // Opens Hidonim start menu
  102.     register_clcmd("say /stop_hidon", "ManualStopHidon", ADMIN_RCON); // Stop Hidon
  103.     register_clcmd("say /answer", "ShowAnswer", ADMIN_RCON); // ch3ater huh?
  104.    
  105.     register_clcmd("say /printAllSongsNames", "printAllSongsNames");
  106.     register_clcmd("say /hidon", "NextHidon");
  107.     register_clcmd("say /logo", "LogoQuiz_ShowLogo");
  108.     register_clcmd("say /s", "StopMusic");
  109.     register_clcmd("say /r", "ReplayMusic");
  110.     register_clcmd("say", "CheckAnswer");
  111.    
  112.     set_task(1.0, "HidonCD", _, _, _, "b");
  113.    
  114.     LoadNostalgia();
  115.     LoadAnime();
  116.     LoadTriviaQuestions();
  117.     LoadLogoQuiz();
  118.     LoadMissingLetter();
  119. }
  120.  
  121. public printAllSongsNames(id)
  122. {
  123.     new path[128];
  124.  
  125.     for (new i = 0; i < NostalgiaSongsLoaded; i++)
  126.     {
  127.         formatex(path, charsmax(path), "^"%s%s^"", NostalgiaDefaultPath, NostalgiaSongs[i][file_name]);
  128.         ColorChat(id, "%s", path);
  129.     }
  130.    
  131.     for (new i = 0; i < AnimeSongsLoaded; i++)
  132.     {
  133.         formatex(path, charsmax(path), "^"%s%s^"", AnimeDefaultPath, AnimeSongs[i][file_name]);
  134.         ColorChat(id, "%s", path);
  135.     }
  136.    
  137.     return PLUGIN_HANDLED;
  138. }
  139.  
  140. public ManualStopHidon(id)
  141. {
  142.     if (HidonIsRunning)
  143.     {
  144.         ResetHidon();
  145.         ColorChat(0, "^4%s ^1has stoped ^3Hidon^1.", get_player_name(id));
  146.     }
  147.     else
  148.         ColorChat(0, "Hidon has not been started yet.");
  149. }
  150.  
  151. public AdminMenu(id)
  152. {
  153.     new mAdmin = menu_create("\r[\y Top Deathrun \r] \yChoose a hidon to start:", "AdminMenu_Handler");
  154.    
  155.     menu_additem(mAdmin, "\yStart Hidon Vote");
  156.    
  157.     for (new i = 0; i < HidonimGamesCount; i++)
  158.         menu_additem(mAdmin, Hidon[i][name]);
  159.        
  160.     menu_display(id, mAdmin, 0);
  161.    
  162.     return PLUGIN_HANDLED;
  163. }
  164.  
  165. public AdminMenu_Handler(id, mAdmin, item)
  166. {
  167.     if (item != MENU_EXIT)
  168.     {
  169.         ResetHidon();
  170.         HidonIsRunning = true;
  171.        
  172.         if (item == 0)
  173.         {
  174.             HidonVote();
  175.             ColorChat(0, "^4%s ^1has started ^3Hidon Vote^1.", get_player_name(id));
  176.         }
  177.         else
  178.         {
  179.             GameCount = 3;
  180.             ChoosenHidonId = item-1;
  181.             AdminStartedHidon = true;
  182.             StartHidon();
  183.             ColorChat(0, "^4%s ^1has started ^3Hidon %s^1.", get_player_name(id), Hidon[item-1][name]);
  184.         }
  185.        
  186.         return PLUGIN_HANDLED;
  187.     }
  188.    
  189.     menu_destroy(mAdmin);
  190.     return PLUGIN_HANDLED;
  191. }
  192.  
  193. public HidonCD()
  194. {
  195.     if (HidonWaitingTime == 0)
  196.     {
  197.         HidonIsRunning = true;
  198.         HidonVote();
  199.     }
  200.    
  201.     HidonWaitingTime--;
  202. }
  203.  
  204. public NextHidon(id)
  205. {
  206.     if (HidonIsRunning)
  207.         ColorChat(id, "A ^3Hidon ^1is already in progress.");
  208.     else
  209.         ColorChat(id, "^3Next Hidon ^1in: ^4%d ^1minutes and ^4%d ^1seconds.", HidonWaitingTime/60, HidonWaitingTime%60);
  210.        
  211.     return PLUGIN_HANDLED;
  212. }
  213.  
  214. public ShowAnswer(id)
  215. {
  216.     ColorChat(id, "Answer is: %s", Answer);
  217.     return PLUGIN_HANDLED;
  218. }
  219.  
  220. public StopMusic(id)
  221. {
  222.     client_cmd(id, "mp3 stop");
  223. }
  224.  
  225. public ReplayMusic(id)
  226. {
  227.     if (sound[0])
  228.         client_cmd(id, "mp3 play ^"%s^"", sound);
  229. }
  230.  
  231. public LogoQuiz_ShowLogo(id)
  232. {
  233.     if (ChoosenHidonId != 4)
  234.         return;
  235.    
  236.     new path[128];
  237.     formatex(path, charsmax(path), "%s%s", LogoQuizHost, LogoQuizQuestions[RndId][Quest]);
  238.     show_motd(id, path, ".: [ Top Deathrun ] LogoQuiz :.");
  239. }
  240.  
  241. public plugin_precache()
  242. {
  243.     precache_generic("sound/TopDeathrun/Nostalgia/pokemon_fix.mp3");
  244.     precache_generic("sound/TopDeathrun/Nostalgia/marko.mp3");
  245.     precache_generic("sound/TopDeathrun/Nostalgia/A_Pigamot.mp3");
  246.     precache_generic("sound/TopDeathrun/Nostalgia/artur.mp3");
  247.     precache_generic("sound/TopDeathrun/Nostalgia/asfor.mp3");
  248.     precache_generic("sound/TopDeathrun/Nostalgia/beyblade.mp3");
  249.     precache_generic("sound/TopDeathrun/Nostalgia/Bilbi.mp3");
  250.     precache_generic("sound/TopDeathrun/Nostalgia/BobABanai.mp3");
  251.     precache_generic("sound/TopDeathrun/Nostalgia/code_lyoko.mp3");
  252.     precache_generic("sound/TopDeathrun/Nostalgia/digimon.mp3");
  253.     precache_generic("sound/TopDeathrun/Nostalgia/gur_ve_oah.mp3");
  254.     precache_generic("sound/TopDeathrun/Nostalgia/HaMuminim.mp3");
  255.     precache_generic("sound/TopDeathrun/Nostalgia/hshminia.mp3");
  256.     precache_generic("sound/TopDeathrun/Nostalgia/kirbi.mp3");
  257.     precache_generic("sound/TopDeathrun/Nostalgia/kobikobi.mp3");
  258.     precache_generic("sound/TopDeathrun/Nostalgia/miflezetBeTaot.mp3");
  259.     precache_generic("sound/TopDeathrun/Nostalgia/MoadonWinx.mp3");
  260.     precache_generic("sound/TopDeathrun/Nostalgia/nils.mp3");
  261.     precache_generic("sound/TopDeathrun/Nostalgia/SamiACabai.mp3");
  262.     precache_generic("sound/TopDeathrun/Nostalgia/sedrik.mp3");
  263.     precache_generic("sound/TopDeathrun/Nostalgia/Shemesh.mp3");
  264.     precache_generic("sound/TopDeathrun/Nostalgia/spongebob.mp3");
  265.     precache_generic("sound/TopDeathrun/Nostalgia/tomy_ve_oskar.mp3");
  266.     precache_generic("sound/TopDeathrun/Nostalgia/tzave_aninja.mp3");
  267.     precache_generic("sound/TopDeathrun/Nostalgia/wunschpunsch.mp3");
  268.     precache_generic("sound/TopDeathrun/Nostalgia/yladimgivatnapolion.mp3");
  269.     precache_generic("sound/TopDeathrun/Nostalgia/yu-gi-oh1.mp3");
  270.     precache_generic("sound/TopDeathrun/Nostalgia/yu-gi-oh-gx.mp3");
  271.    
  272.     precache_generic("sound/TopDeathrun/Anime/Bleach_1_Fix.mp3");
  273.     precache_generic("sound/TopDeathrun/Anime/dragonballgt.mp3");
  274.     precache_generic("sound/TopDeathrun/Anime/dragonballz_fix.mp3");
  275.     precache_generic("sound/TopDeathrun/Anime/dragonballz2_fix.mp3");
  276.     precache_generic("sound/TopDeathrun/Anime/Inuyasha.mp3");
  277.     precache_generic("sound/TopDeathrun/Anime/one_piece.mp3");
  278.     precache_generic("sound/TopDeathrun/Anime/Sakura.mp3");
  279.     precache_generic("sound/TopDeathrun/Anime/ShamanKing.mp3");
  280.     precache_generic("sound/TopDeathrun/Anime/sword_art_online.mp3");
  281.     precache_generic("sound/TopDeathrun/Anime/TokyoMewMew.mp3");
  282.    
  283.     precache_generic("sound/TopDeathrun/CD/one.wav");
  284.     precache_generic("sound/TopDeathrun/CD/two.wav");
  285.     precache_generic("sound/TopDeathrun/CD/three.wav");
  286.     precache_generic("sound/TopDeathrun/CD/four.wav");
  287.     precache_generic("sound/TopDeathrun/CD/five.wav");
  288. }
  289.  
  290. public HidonVote()
  291. {
  292.     if (GameCount == 3)
  293.     {
  294.         ResetHidon();
  295.         return;
  296.     }
  297.    
  298.     if (VoteTimer < 0)
  299.     {
  300.         ColorChat(0, "Vote was ended");
  301.         GameCount++;
  302.         show_menu(0, 0, "^n", 1);
  303.         ChooseHidon();
  304.         return;
  305.     }
  306.    
  307.     new players[32], pnum;
  308.     get_players(players, pnum, "ch");
  309.    
  310.     new buffer[128];
  311.    
  312.     for (new i = 0; i < pnum; i++)
  313.     {
  314.         new id = players[i]
  315.        
  316.         formatex(buffer, charsmax(buffer), "\r[\y Top Deathrun \r] \yHidon Vote:^n\r// \wStatus: %s^n\r// \wTime to choose: \y%0.1f", (isVoted[id] ? "\yVoted" : "\rNot Voted"), float(VoteTimer)/10.0);
  317.         new VoteMenu = menu_create(buffer, "ShowVoteMenu_Handler");
  318.        
  319.         for (new i = 0; i < HidonimGamesCount; i++)
  320.         {
  321.             #if defined USE_NATIVES
  322.             format(buffer, charsmax(buffer), "\w%s \r(\w%d \dPts \y& \w%d \r)\w \r[\w%d Votes\r]", Hidon[i][name], Hidon[i][points], Votes[i]);
  323.             #else
  324.             format(buffer, charsmax(buffer), "\w%s \r[\w%d Votes\r]", Hidon[i][name], Votes[i]);
  325.             #endif
  326.             menu_additem(VoteMenu, buffer);
  327.         }
  328.        
  329.         menu_setprop(VoteMenu, MPROP_EXIT, MEXIT_NEVER);
  330.         menu_display(id, VoteMenu, 0);
  331.     }
  332.    
  333.     VoteTimer--;
  334.     set_task(0.1, "HidonVote", task_vote);
  335.    
  336.     return;
  337. }
  338.  
  339. public ShowVoteMenu_Handler(id, VoteMenu, item)
  340. {
  341.     if (item == MENU_EXIT)
  342.     {
  343.         menu_destroy(VoteMenu);
  344.         return PLUGIN_HANDLED;
  345.     }
  346.    
  347.     if (isVoted[id] || VoteTimer < 0)
  348.         return PLUGIN_HANDLED;
  349.    
  350.     Votes[item]++;
  351.     isVoted[id] = true;
  352.    
  353.     return PLUGIN_HANDLED;
  354. }
  355.  
  356. public ChooseHidon()
  357. {
  358.     new biggestNum = Votes[0], Results = 0, Array:VotesArr;
  359.     VotesArr = ArrayCreate(HidonimGamesCount);
  360.    
  361.     // Find Biggest
  362.     for (new i = 1; i < HidonimGamesCount; i++)
  363.         if (biggestNum < Votes[i])
  364.             biggestNum= Votes[i];
  365.            
  366.     // Check if three is more same results
  367.     for (new i = 0; i < HidonimGamesCount; i++)
  368.     {
  369.         if (Votes[i] == biggestNum)
  370.         {
  371.             ArrayPushCell(VotesArr, i);
  372.             Results++;
  373.         }
  374.     }
  375.    
  376.     if (Results > 1)
  377.     {
  378.         ChoosenHidonId = ArrayGetCell(VotesArr, random_num(0, ArraySize(VotesArr)-1));
  379.         ColorChat(0, "Hidon ^4%s ^1was randomly choosen!", Hidon[ChoosenHidonId][name]);
  380.     }
  381.     else
  382.     {
  383.         ChoosenHidonId = ArrayGetCell(VotesArr, 0);
  384.         ColorChat(0, "Hidon ^4%s ^1was choosen.", Hidon[ChoosenHidonId][name]);
  385.     }
  386.    
  387.     StartHidon();
  388. }
  389.  
  390. public StartHidon()
  391. {
  392.     if (StartHidonCD == 0)
  393.     {
  394.         switch (ChoosenHidonId)
  395.         {
  396.             case 0: StartHidonMath();
  397.             case 1: StartHidonNostalgia();
  398.             case 2: StartHidonAnime();
  399.             case 3: StartHidonTrivia();
  400.             case 4: StartHidonLogoQuiz();
  401.             case 5: StartHidonMissingLetter();
  402.         }
  403.         return;
  404.     }
  405.    
  406.     set_dhudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, 0.3, 0, 1.0, 1.0, 0.5, 0.0);
  407.     show_dhudmessage(0, "%s Will be start in %d seconds.", Hidon[ChoosenHidonId][name], StartHidonCD);
  408.    
  409.     num_to_word(StartHidonCD, sound, charsmax(sound));
  410.     format(sound, charsmax(sound), "%s%s", "spk sound/TopDeathrun/CD/", sound);
  411.     client_cmd(0, sound);
  412.     StartHidonCD--;
  413.    
  414.     set_task(1.0, "StartHidon", task_start_hidon);
  415. }
  416.  
  417. public StartHidonMath()
  418. {
  419.     num1 = random_num(100, 999);
  420.     num2 = random_num(100, 999);
  421.    
  422.     new temp[4];
  423.     num_to_str(num1+num2, temp, sizeof(temp));
  424.     copy(Answer, sizeof(temp), temp);
  425.     ColorChat(0, "How much is ^4%d ^3+ ^4%d ^1?", num1, num2);
  426.    
  427.     set_task(0.0, "ShowHud", task_hud);
  428. }
  429.  
  430. public StartHidonNostalgia()
  431. {
  432.     RndId = random_num(0, NostalgiaSongsLoaded-1);
  433.     copy(Answer, sizeof(Answer), NostalgiaSongs[RndId][name]);
  434.    
  435.     formatex(sound, charsmax(sound), "%s%s", NostalgiaDefaultPath, NostalgiaSongs[RndId][file_name]);
  436.     client_cmd(0, "mp3 play ^"%s^"", sound);
  437.    
  438.     set_task(0.0, "ShowHud", task_hud);
  439. }
  440.  
  441. public StartHidonAnime()
  442. {
  443.     RndId = random_num(0, AnimeSongsLoaded-1);
  444.     copy(Answer, sizeof(Answer), AnimeSongs[RndId][name]);
  445.    
  446.     formatex(sound, charsmax(sound), "%s%s", AnimeDefaultPath, AnimeSongs[RndId][file_name]);
  447.     client_cmd(0, "mp3 play ^"%s^"", sound);
  448.    
  449.     set_task(0.0, "ShowHud", task_hud);
  450. }
  451.  
  452. public StartHidonTrivia()
  453. {
  454.     RndId = random_num(0, TriviaQuestionsLoaded-1);
  455.     copy(Answer, charsmax(Answer), TriviaQuestions[RndId][Answr]);
  456.    
  457.     set_task(0.0, "ShowHud", task_hud);
  458. }
  459.  
  460. public StartHidonLogoQuiz()
  461. {
  462.     RndId = random_num(0, LogoQuizQuestionsLoaded-1);
  463.     copy(Answer, charsmax(Answer), LogoQuizQuestions[RndId][Answr]);
  464.    
  465.     set_task(0.0, "ShowHud", task_hud);
  466. }
  467.  
  468. public StartHidonMissingLetter()
  469. {
  470.     RndId = random_num(0, MLQuestionsLoaded-1);
  471.     copy(Answer, sizeof(Answer), MLQuestions[RndId]);
  472.    
  473.     MLWords_indexes = ArrayCreate(MAX_ML_WORD_SIZE);
  474.    
  475.     for (new i = 0; i < strlen(Answer); i++)
  476.     {
  477.         ArrayPushCell(MLWords_indexes, i);
  478.         format(MLWord, sizeof(MLWord), "%s%c", MLWord, "_");
  479.     }
  480.    
  481.     ML_UpdateAmount = strlen(MLWord)/4;
  482.     ML_LastIds = { -1, -1, -1, -1, -1, -1 , -1 , -1 };
  483.    
  484.     for (new i = 0; i < 3; i++)
  485.         ML_AddLetter();
  486.    
  487.     set_task(0.0, "ShowHud", task_hud);
  488. }
  489.  
  490. public ShowHud()
  491. {
  492.     if (HidonTimer < 0)
  493.     {
  494.         if (WinnerId == -1)
  495.             ColorChat(0, "Nobody answered right... [^4Answer ^1was:^3 %s^1]", Answer);
  496.        
  497.         ResetHidon();
  498.         HidonVote();
  499.         return;
  500.     }
  501.    
  502.     set_dhudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, 0.30, 0, 1.0, 1.0);
  503.    
  504.     if (WinnerId != -1)
  505.     {
  506.         show_dhudmessage(0, "The Winner is %s!!!!!!!^nAnd he wins %d Points", get_player_name(WinnerId), Hidon[ChoosenHidonId][points]);
  507.        
  508.         if (ShowMsgOnce)
  509.         {
  510.             set_user_points(WinnerId, get_user_points(WinnerId) + Hidon[ChoosenHidonId][points]);
  511.             ColorChat(0, "^1The Winner Is ^4%s ^1and he wins ^3%d ^4Points^1! [^4Answer ^1was:^3 %s^1]", WinnerName, Hidon[ChoosenHidonId][points], Answer);
  512.             ShowMsgOnce = false;
  513.         }
  514.     }
  515.     else
  516.     {
  517.         switch (ChoosenHidonId)
  518.         {
  519.             case 0: show_dhudmessage(0, "How much is %d + %d ?", num1, num2);
  520.             case 1: show_dhudmessage(0, "The Name Of This Nosalgic Series Is???");
  521.             case 2: show_dhudmessage(0, "The Name Of This Anime Series Is???");
  522.             case 3: show_dhudmessage(0, "%s", TriviaQuestions[RndId][Quest]);
  523.             case 4: show_dhudmessage(0, "Do you know where this logo belongs?^nType /logo in chat to view the logo.", LogoQuizQuestions[RndId][Quest]);
  524.             case 5:
  525.             {
  526.                 ML_timer = float(HidonTimer%10);
  527.                 show_dhudmessage(0, "(%d Letters | Next help in: %1.f)^nWhat is that Word ?^n%s", strlen(Answer), (ArraySize(MLWords_indexes) >= ML_UpdateAmount) ? ML_timer : 0.0, MLWord);
  528.                 ProccessMLWord();
  529.             }
  530.         }
  531.     }
  532.        
  533.     HidonTimer--;
  534.     set_task(1.0, "ShowHud", task_hud);
  535. }
  536.  
  537. public ML_AddLetter()
  538. {
  539.     new rnd_num = random_num(0, ArraySize(MLWords_indexes)-1);
  540.     new rnd_location = ArrayGetCell(MLWords_indexes, rnd_num);
  541.     MLWord[rnd_location] = Answer[rnd_location];
  542.     ArrayDeleteItem(MLWords_indexes, rnd_num);
  543.    
  544.     return rnd_location;
  545. }
  546.  
  547. public ProccessMLWord()
  548. {
  549.     if (ML_timer == 0.0 && HidonTimer <= 50 && ArraySize(MLWords_indexes) > -1 && ArraySize(MLWords_indexes) >= ML_UpdateAmount)
  550.     {
  551.         for (new i = 0; i < ML_UpdateAmount; i++)
  552.             ML_LastIds[i] = ML_AddLetter();
  553.        
  554.     }
  555.     else
  556.     {
  557.         if (floatround(ML_timer) >= 6 && ArraySize(MLWords_indexes) >= ML_UpdateAmount)
  558.         {
  559.             for (new i = 0; i < ML_UpdateAmount; i++)
  560.             {
  561.                 if (ML_LastIds[i] == -1) continue;
  562.                
  563.                 if (floatround(ML_timer)%2 == 1)
  564.                     MLWord[ML_LastIds[i]] = '_';
  565.                 else
  566.                     MLWord[ML_LastIds[i]] = Answer[ML_LastIds[i]];
  567.             }
  568.         }
  569.     }
  570. }
  571.  
  572. public CheckAnswer(id)
  573. {
  574.     if (ChoosenHidonId == -1)
  575.         return PLUGIN_CONTINUE;
  576.        
  577.     new Msg[192];
  578.     read_argv(1, Msg, charsmax(Msg));
  579.    
  580.     if (equali(Msg, Answer) && WinnerId == -1 && StartHidonCD == 0)
  581.     {
  582.         WinnerId = id;
  583.         get_user_name(WinnerId, WinnerName, charsmax(WinnerName));
  584.         ShowMsgOnce = true;
  585.         remove_task(task_hud);
  586.         set_task(0.0, "ShowHud");
  587.     }
  588.     else if (ChoosenHidonId == 0 && WinnerId == -1 && StartHidonCD == 0)
  589.         ColorChat(id, "^3Wrong Answer.");
  590.    
  591.     return PLUGIN_CONTINUE;
  592. }
  593.  
  594. public ResetHidon()
  595. {
  596.     if (GameCount > 3)
  597.         GameCount = 0;
  598.        
  599.     HidonWaitingTime = 600;
  600.     HidonIsRunning = false;
  601.    
  602.     if (AdminStartedHidon)
  603.         AdminStartedHidon = false;
  604.     else
  605.         VoteTimer = 100;
  606.    
  607.     ChoosenHidonId = -1;
  608.     StartHidonCD = 5;
  609.     WinnerId = -1;
  610.     WinnerName = "";
  611.     ShowMsgOnce = false;
  612.     HidonTimer = 60;
  613.     RndId = -1;
  614.     MLWord = "";
  615.     sound[0] = '^0';
  616.     remove_task(task_vote);
  617.     remove_task(task_start_hidon);
  618.     remove_task(task_hud);
  619.    
  620.     for (new i = 0; i < HidonimGamesCount; i++)
  621.         Votes[i] = 0;
  622.    
  623.     for (new i = 0; i < get_maxplayers(); i++)
  624.         isVoted[i] = false;
  625. }
  626.  
  627. public LoadNostalgia()
  628. {
  629.     if (file_exists(NostalgiaCfgFile))
  630.     {
  631.         new text[128];
  632.         new file = fopen(NostalgiaCfgFile, "rt");
  633.        
  634.         while (!feof(file))
  635.         {
  636.             fgets(file, text, charsmax(text));
  637.             trim(text);
  638.             if (text[0] == ';' || !text[0]) continue;
  639.            
  640.             parse(text, NostalgiaSongs[NostalgiaSongsLoaded][name], MAX_SONG_NAME-1, NostalgiaSongs[NostalgiaSongsLoaded][file_name], MAX_PATH_SIZE-1);
  641.             replace_all(NostalgiaSongs[NostalgiaSongsLoaded][name], MAX_SONG_NAME-1, "_", " ");
  642.            
  643.             NostalgiaSongsLoaded++;
  644.         }
  645.        
  646.         fclose(file)
  647.     }
  648.     else
  649.         log_message("[ Hidonim ] (Error) Failed to load file nostalgia.txt.");
  650. }
  651.  
  652. public LoadAnime()
  653. {
  654.     if (file_exists(AnimeCfgFile))
  655.     {
  656.         new text[128];
  657.         new file = fopen(AnimeCfgFile, "rt");
  658.        
  659.         while (!feof(file))
  660.         {
  661.             fgets(file, text, charsmax(text));
  662.             trim(text);
  663.             if (text[0] == ';' || !text[0]) continue;
  664.            
  665.             parse(text, AnimeSongs[AnimeSongsLoaded][name], MAX_SONG_NAME-1, AnimeSongs[AnimeSongsLoaded][file_name], MAX_PATH_SIZE-1);
  666.             replace_all(AnimeSongs[AnimeSongsLoaded][name], MAX_SONG_NAME-1, "_", " ");
  667.            
  668.             AnimeSongsLoaded++;
  669.         }
  670.        
  671.         fclose(file)
  672.     }
  673.     else
  674.         log_message("[ Hidonim ] (Error) Failed to load file anime.txt.");
  675. }
  676.  
  677. public LoadTriviaQuestions()
  678. {
  679.     if (file_exists(TriviaCfgFile))
  680.     {
  681.         new text[128];
  682.         new file = fopen(TriviaCfgFile, "rt");
  683.        
  684.         while (!feof(file))
  685.         {
  686.             fgets(file, text, charsmax(text));
  687.             trim(text);
  688.             remove_quotes(text);
  689.             if (text[0] == ';' || !text[0]) continue;
  690.            
  691.             parse(text, TriviaQuestions[TriviaQuestionsLoaded][Quest], MAX_QUESTIONS_LENGTH-1, TriviaQuestions[TriviaQuestionsLoaded][Answr], MAX_ANSWER_LENGTH-1);
  692.             replace_all(TriviaQuestions[TriviaQuestionsLoaded][Quest], MAX_QUESTIONS_LENGTH-1, "_", " ");
  693.             replace_all(TriviaQuestions[TriviaQuestionsLoaded][Answr], MAX_ANSWER_LENGTH-1, "_", " ");
  694.            
  695.             TriviaQuestionsLoaded++;
  696.         }
  697.        
  698.         fclose(file)
  699.     }
  700.     else
  701.         log_message("[ Hidonim ] (Error) Failed to load file trivia.txt.");
  702. }
  703.  
  704. public LoadLogoQuiz()
  705. {
  706.     if (file_exists(LogoQuizCfgFile))
  707.     {
  708.         new text[128];
  709.         new file = fopen(LogoQuizCfgFile, "rt");
  710.        
  711.         while (!feof(file))
  712.         {
  713.             fgets(file, text, charsmax(text));
  714.             trim(text);
  715.             remove_quotes(text);
  716.             if (text[0] == ';' || !text[0]) continue;
  717.            
  718.             parse(text, LogoQuizQuestions[LogoQuizQuestionsLoaded][Quest], MAX_QUESTIONS_LENGTH-1, LogoQuizQuestions[LogoQuizQuestionsLoaded][Answr], MAX_ANSWER_LENGTH-1);
  719.             replace_all(LogoQuizQuestions[LogoQuizQuestionsLoaded][Answr], MAX_ANSWER_LENGTH-1, "_", " ");
  720.            
  721.             LogoQuizQuestionsLoaded++;
  722.         }
  723.        
  724.         fclose(file)
  725.     }
  726.     else
  727.         log_message("[ Hidonim ] (Error) Failed to load file logoquiz.txt.");
  728. }
  729.  
  730. public LoadMissingLetter()
  731. {
  732.     if (file_exists(MissingLetterCfgFile))
  733.     {
  734.         new text[128];
  735.         new file = fopen(MissingLetterCfgFile, "rt");
  736.        
  737.         while (!feof(file))
  738.         {
  739.             fgets(file, text, charsmax(text));
  740.             trim(text);
  741.             remove_quotes(text);
  742.             if (text[0] == ';' || !text[0]) continue;
  743.            
  744.             copy(MLQuestions[MLQuestionsLoaded], MAX_ML_WORD_SIZE, text);
  745.            
  746.             MLQuestionsLoaded++;
  747.         }
  748.  
  749.         fclose(file)
  750.     }
  751.     else
  752.         log_message("[ Hidonim ] (Error) Failed to load file missingletter.txt.");
  753. }
  754.  
  755. get_player_name(id)
  756. {
  757.     new szName[32];
  758.     get_user_name(id, szName, charsmax(szName));
  759.    
  760.     return szName;
  761. }
  762.  
  763. stock ColorChat( const client, const string[], any:... )
  764. {
  765.     new msg[ 191 ], players[ 32 ], count = 1;
  766.     static len; len = formatex( msg, charsmax( msg ), "^4[^1 Top Deathrun ^4]^1 " );
  767.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 );
  768.    
  769.     if( client )  players[ 0 ] = client;
  770.     else    get_players( players,count,"ch" );
  771.    
  772.     for ( new i = 0; i < count; i++ )
  773.     {
  774.         if( is_user_connected( players[ i ] ) )
  775.         {
  776.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] );
  777.             write_byte( players[ i ] );
  778.             write_string( msg );
  779.             message_end( );
  780.         }
  781.     }
  782.     return PLUGIN_HANDLED;
  783. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement