JuSTaR

Hidonim [Unofficial-2]

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