JuSTaR

[CS1.6] Mod Hidonim v4

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