RanAway

[ Pawn ] Hidons

May 29th, 2022 (edited)
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 28.84 KB | None | 0 0
  1. /*********** Includes ************/
  2. #include < amxmodx >
  3. #include < amxmisc >
  4. #include < fvault >
  5. #include < dhudmessage >
  6.  
  7. /*********** Defines ************/
  8. #define Prefix          "AMXX"          // The prefix
  9. #define ADMIN_ACCESS        ADMIN_IMMUNITY      // The access to the menu / start / stop hidons
  10. #define Vault           "Hidon-System"      // The vault save file
  11.  
  12. /*********** Hidons settings ************/
  13. #define Folder          "addons/amxmodx/configs/hidons"
  14. #define EnglishCfgFile      "addons/amxmodx/configs/hidons/english.txt"
  15. #define AnimeCfgFile        "addons/amxmodx/configs/hidons/anime.txt"
  16.  
  17. #define SoundFolder     "sound/hidons"
  18. #define EnglishDefaultPath  "sound/hidons/English"
  19. #define AnimeDefaultPath    "sound/hidons/Anime"
  20.  
  21. /*********** Timers ************/
  22. #define AutoID 1                    // Stop task of The timer of /hidon
  23. #define VoteID 2                    // Stop task of vote menu
  24. #define BeforeID 3                  // Stop task of the countdown to the vote menu
  25. #define ShowMsgID 4                 // Stop task of the showing of the question
  26. #define TimeDoneID 5                    // Stop task of the time to win
  27. #define WinneroffID 6                   // Stop task of the winner msg
  28.  
  29. #define SetTimetohidon 300              // Default time of waiting for the vote
  30. #define SetMenuTimer 15                 // The menu timer
  31. #define SetCountdown 6                  // The countdown for starting song
  32.  
  33. new Timeleft = SetTimetohidon
  34. new MenuTimer = SetMenuTimer
  35. new Countdown = SetCountdown
  36.  
  37. /*********** Hidons stuff ************/
  38. new const hidonItems[][] =
  39. {
  40.     "Math", "English", "Anime"
  41. }
  42.  
  43. /*********** Vote access ************/
  44. new VoteAccess[ 33 ]
  45.  
  46. /*********** Vote status ************/
  47. enum VoteStats
  48. {
  49.     Vote_NotRunning,
  50.     Vote_Running
  51. }
  52. new VoteStats: VoteStatus = Vote_NotRunning
  53.  
  54. /*********** Vote stuff ************/
  55. new MyVote[ 33 ], AllVotes
  56. new VoteItem[ sizeof hidonItems ], winneron = false
  57. new hidonlets[ 64 ], answer[ 32 ] = "", numberbind
  58. new szNamewin[ 32 ], hidonmsg
  59.  
  60. /*********** Ini items ************/
  61. new RndId = -1, sound[ 64 ]
  62. enum _:SongProperties
  63. {
  64.     song_name[ 31 ],
  65.     file_name[ 120 ]
  66. }
  67.  
  68. new exem1, exem2, Math = false
  69. new EnglishSongs[ 120 ][ SongProperties ], EnglishSongsLoaded = 0, English = false
  70. new AnimeSongs[ 120 ][ SongProperties ], AnimeSongsLoaded = 0, Anime = false
  71.  
  72. /************ Nes **************/
  73. new MenuType[ 33 ], MyChoose[ 33 ], SpecificItem = false, RandomNumber = false
  74.  
  75. /*********** Plugin init ************/
  76. public plugin_init()
  77. {
  78.     register_plugin( "Hidons", "v1.0", "RanAway`" )
  79.    
  80.     /*********** Commands ************/
  81.     register_clcmd( "say", "CmdSay" )
  82.    
  83.     /*********** Answers ************/
  84.     register_clcmd( "say", "maths" )
  85.     register_clcmd( "say", "Typeanswer" )
  86.    
  87.     /*********** Timer ************/
  88.     set_task( 1.0, "Timetostart", AutoID, _, _, "b" )
  89.    
  90.     /*********** Create the folder **********/
  91.     if( !dir_exists( Folder ) )
  92.         mkdir( Folder )
  93.    
  94.     /*********** Create the sound folder **********/
  95.     if( !dir_exists( SoundFolder ) )
  96.         mkdir( SoundFolder )
  97.    
  98.     /*********** Create the english folder **********/
  99.     if( !dir_exists( EnglishDefaultPath ) )
  100.         mkdir( EnglishDefaultPath )
  101.    
  102.     /*********** Create the anime folder **********/
  103.     if( !dir_exists( AnimeDefaultPath ) )
  104.         mkdir( AnimeDefaultPath )
  105.    
  106.     /*********** Load Hidons **********/
  107.     LoadHidons()
  108. }
  109.  
  110. /*********** Precache ************/
  111. public plugin_precache()
  112. {
  113.     new szItem[ 256 ]
  114.    
  115.     for( new i; i < EnglishSongsLoaded; i++ ) formatex( szItem, charsmax( szItem ), "%s/%s.mp3", EnglishDefaultPath, EnglishSongs[ i ][ file_name ] )
  116.     for( new i; i < AnimeSongsLoaded; i++ ) formatex( szItem, charsmax( szItem ), "%s/%s.mp3", AnimeDefaultPath, AnimeSongs[ i ][ file_name ] )
  117.    
  118.     if( EnglishSongsLoaded != 0 || AnimeSongsLoaded != 0 )
  119.         precache_generic( szItem )
  120. }
  121.  
  122. /*********** Connecting / Disconnecting ************/
  123. public client_disconnect( id ) Save( id )
  124. public client_putinserver( id )
  125. {
  126.     VoteAccess[ id ] = 0
  127.     Load( id )
  128. }
  129.  
  130. /*********** Time to start ************/
  131. public Timetostart()
  132. {
  133.     Timeleft--
  134.     if( Timeleft == 0 )
  135.     {
  136.         remove_task( AutoID )
  137.         VoteStatus = Vote_Running
  138.         ColorChat( 0, "The ^3hidon^1 has started" )
  139.        
  140.         votebefore()
  141.     }
  142. }
  143.  
  144. /*********** Hidon menu ************/
  145. public hidonmenu( id )
  146. {
  147.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
  148.    
  149.     new szMenu[ 250 ]
  150.    
  151.     formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w hidon menu^n\y> \wYou can turn \r%d\w more hidons\R", Prefix, VoteAccess[ id ] )
  152.     new menu = menu_create( szMenu, "sub_hidonmenu" )
  153.    
  154.     menu_additem( menu, "start vote", .callback = menu_makecallback( "blockcmd" ) )
  155.     menu_additem( menu, "stop hidon^n", .callback = menu_makecallback( "blockcmd" ) )
  156.    
  157.     menu_additem( menu, "Start Math" )
  158.     menu_additem( menu, "Start English" )
  159.     menu_additem( menu, "Start Anime^n" )
  160.    
  161.     if( get_user_flags( id ) & ADMIN_ACCESS )
  162.     {
  163.         menu_additem( menu, "Start specific song" )
  164.         menu_additem( menu, "Win English" )
  165.         menu_additem( menu, "Win Anime" )
  166.     }
  167.    
  168.     menu_display( id, menu )
  169.     return 1
  170. }
  171.  
  172. public sub_hidonmenu( id, menu, item )
  173. {
  174.     if( item == MENU_EXIT ) return menu_destroy( menu )
  175.     if( item == 0 ) startvote( id )
  176.     if( item == 1 ) stophidon( id )
  177.     if( item == 2 ) startmath( id )
  178.     if( item == 3 ) startenglish( id )
  179.     if( item == 4 ) startanime( id )
  180.     if( item == 5 ) return songmenu( id )
  181.     if( item >= 6 ) adminwin( id )
  182.    
  183.     return hidonmenu( id )
  184. }
  185.  
  186. public blockcmd( id, menu, item )
  187. {
  188.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) )
  189.         return ITEM_DISABLED
  190.    
  191.     return 0
  192. }
  193.  
  194. /*********** Song menu ************/
  195. public songmenu( id )
  196. {
  197.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
  198.    
  199.     new szMenu[ 250 ]
  200.    
  201.     formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w hidon menu", Prefix )
  202.     new menu = menu_create( szMenu, "sub_songmenu" )
  203.    
  204.     formatex( szMenu, charsmax( szMenu ), "English \r[\y %d\w songs \r]", EnglishSongsLoaded )
  205.     menu_additem( menu, szMenu )
  206.    
  207.     formatex( szMenu, charsmax( szMenu ), "Anime \r[\y %d\w series \r]", AnimeSongsLoaded )
  208.     menu_additem( menu, szMenu )
  209.    
  210.     menu_setprop( menu, MPROP_EXITNAME, "Back" )
  211.     menu_display( id, menu )
  212.     return 1
  213. }
  214.  
  215. public sub_songmenu( id, menu, item )
  216. {
  217.     if( item == MENU_EXIT ) return hidonmenu( id )
  218.     if( item == 0 ) MenuType[ id ] = 1
  219.     if( item == 1 ) MenuType[ id ] = 2
  220.    
  221.     MyChoose[ id ] = 0
  222.    
  223.     return ChooseSong( id )
  224. }
  225.  
  226. /*********** Song menu ************/
  227. public ChooseSong( id )
  228. {
  229.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
  230.    
  231.     new szMenu[ 250 ]
  232.    
  233.     if( MenuType[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w English menu \r[\y %d\w songs \r]\w", Prefix, EnglishSongsLoaded )
  234.     if( MenuType[ id ] == 2 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w Anime menu\r[\y %d\w series \r]\w", Prefix, AnimeSongsLoaded )
  235.    
  236.     new menu = menu_create( szMenu, "sub_choosesong" )
  237.    
  238.     if( MenuType[ id ] == 1 ) for( new i; i < EnglishSongsLoaded; i++ ) menu_additem( menu, ( "%s", EnglishSongs[ i ][ song_name ] ) )
  239.     if( MenuType[ id ] == 2 ) for( new i; i < AnimeSongsLoaded; i++ ) menu_additem( menu, ( "%s", AnimeSongs[ i ][ song_name ] ) )
  240.    
  241.     menu_setprop( menu, MPROP_EXITNAME, "Back" )
  242.     menu_display( id, menu )
  243.     return 1
  244. }
  245.  
  246. public sub_choosesong( id, menu, item )
  247. {
  248.     if( item == MENU_EXIT ) return songmenu( id )
  249.    
  250.     MyChoose[ id ] = item
  251.    
  252.     return PlayMenu( id )
  253. }
  254.  
  255. /*********** Play menu ************/
  256. public PlayMenu( id )
  257. {
  258.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
  259.    
  260.     new szMenu[ 250 ]
  261.    
  262.     if( MenuType[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w Play English", Prefix )
  263.     if( MenuType[ id ] == 2 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w Play Anime", Prefix )
  264.     new menu = menu_create( szMenu, "sub_playmenu" )
  265.    
  266.     if( RandomNumber )
  267.     {
  268.         formatex( szMenu, charsmax( szMenu ), "Random number \r[\w %d \r]", numberbind )
  269.         menu_additem( menu, szMenu )
  270.     }
  271.     else menu_additem( menu, "Random number" )
  272.    
  273.     if( MenuType[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "Play \r[\w %s \r]", EnglishSongs[ MyChoose[ id ] ][ song_name ] )
  274.     if( MenuType[ id ] == 2 ) formatex( szMenu, charsmax( szMenu ), "Play \r[\w %s \r]", AnimeSongs[ MyChoose[ id ] ][ song_name ] )
  275.     menu_additem( menu, szMenu )
  276.    
  277.     menu_setprop( menu, MPROP_EXITNAME, "Back" )
  278.     menu_display( id, menu )
  279.     return 1
  280. }
  281.  
  282. public sub_playmenu( id, menu, item )
  283. {
  284.     if( item == MENU_EXIT ) return songmenu( id )
  285.    
  286.     SpecificItem = true
  287.    
  288.     if( item == 0 )
  289.     {
  290.         RandomNumber = true
  291.         numberbind = random_num( 1, 50 )
  292.         PlayMenu( id )
  293.     }
  294.     if( item == 1 )
  295.     {
  296.         if( !RandomNumber ) numberbind = random_num( 1, 50 )
  297.        
  298.         if( MenuType[ id ] == 1 )
  299.         {
  300.             copy( answer, sizeof( answer ), EnglishSongs[ MyChoose[ id ] ][ song_name ] )
  301.             formatex( sound, charsmax( sound ), "%s/%s.mp3", EnglishDefaultPath, EnglishSongs[ MyChoose[ id ] ][ file_name ] )
  302.             startenglish( id )
  303.         }
  304.        
  305.         if( MenuType[ id ] == 2 )
  306.         {
  307.             copy( answer, sizeof( answer ), AnimeSongs[ MyChoose[ id ] ][ song_name ] )
  308.             formatex( sound, charsmax( sound ), "%s%s.mp3", AnimeDefaultPath, AnimeSongs[ MyChoose[ id ] ][ file_name ] )
  309.             startanime( id )
  310.         }
  311.     }
  312.    
  313.     return 1
  314. }
  315.  
  316. /*********** CmdSay ************/
  317. public CmdSay( id )
  318. {
  319.     new szMsg[ 192 ], szArgs[ 3 ][ 32 ]
  320.    
  321.     read_argv( 1, szMsg, charsmax( szMsg ) )
  322.    
  323.     parse( szMsg, szArgs[ 0 ], charsmax( szArgs ), szArgs[ 1 ], charsmax( szArgs ), szArgs[ 2 ], charsmax( szArgs ) )
  324.    
  325.     /************ Admin commands ****************/
  326.     if( equali( szMsg, "/starthidon" ) && get_user_flags( id ) & ADMIN_ACCESS ) return startvote( id )
  327.     if( equali( szMsg, "/stophidon" ) && get_user_flags( id ) & ADMIN_ACCESS ) return stophidon( id )
  328.     if( equali( szMsg, "/hidonmenu" ) ) return hidonmenu( id )
  329.     if( equali( szMsg, "/math" ) ) return startmath( id )
  330.     if( equali( szMsg, "/english" ) ) return startenglish( id )
  331.     if( equali( szMsg, "/anime" ) ) return startanime( id )
  332.    
  333.     /************ Commands ****************/
  334.     if( equali( szMsg, "/stop" ) || equali( szMsg, "/stopsong" ) || equali( szMsg, "/stopmusic" ) || equali( szMsg, "/s" ) ) return client_cmd( id, "Mp3 stop" )
  335.     if( equali( szMsg, "/replay" ) || equali( szMsg, "/replaysong" ) || equali( szMsg, "/replaymusic" ) ) return client_cmd( id, "mp3 play ^"%s.mp3^"", sound )
  336.    
  337.     /************ Show how much hidons you can turn ****************/
  338.     if( equali( szMsg, "/status" ) )
  339.         if( VoteAccess[ id ] > 0 )
  340.             return ColorChat( id, "You can turn only ^3%d^1 more hidons", VoteAccess[ id ] )
  341.    
  342.     /************ Show when hidon ****************/
  343.     if( equali( szMsg, "/hidon" ) || equali ( szMsg, "/hidons" ) || equali( szMsg, "/nexthidon" ) || equali( szMsg, "/nexthidons" ) )
  344.     {
  345.         if( VoteStatus == Vote_Running )
  346.             return ColorChat( id, "The ^3hidon^1 is already running" )
  347.        
  348.         return ColorChat( id, "The hidon will be start in ^3%02d:%02d^1 minute%s", Timeleft/60, Timeleft%60, Timeleft/60 > 1 ? "s" : "" )
  349.     }
  350.    
  351.     /************ Reset timer ****************/
  352.     if( equali( szMsg, "/fixtimer" ) && get_user_flags( id ) & ADMIN_ACCESS )
  353.         return order()
  354.    
  355.     /************ Give hidons access ****************/
  356.     if( equali( szArgs[ 0 ], "/givehidon" ) && get_user_flags( id ) & ADMIN_ACCESS )
  357.     {
  358.         new iPlayer = cmd_target( id, szArgs[ 1 ], 8 )
  359.         new Amount = str_to_num( szArgs[ 2 ] )
  360.        
  361.         if( !is_str_num( szArgs[ 2 ] ) || equali( szMsg, "/givehidon" ) )
  362.             return ColorChat( id, "Usage: /^3givehidon^1 <^3name^1> <^3amount^1>" )
  363.        
  364.         if( !iPlayer )
  365.             return ColorChat( id, "^3%s^1 was not found!", szArgs[ 1 ] )
  366.        
  367.         if( Amount < 0 )
  368.             return ColorChat( id, "You can't set a value lower than^3 0^1." )
  369.        
  370.         if( get_user_flags( iPlayer ) & ADMIN_ACCESS )
  371.             return ColorChat( id, "^3%s^1 has full access to turn hidons", GetName( iPlayer ) )
  372.        
  373.         ColorChat( id, "You gave ^3%s^1 access to turn ^3%i^1 hidons", GetName( iPlayer ), Amount )
  374.         ColorChat( iPlayer, "You got ^3access^1 to turn hidons now. You can start ^3%i^1 hidons", Amount )
  375.        
  376.         VoteAccess[ iPlayer ] = Amount
  377.        
  378.         return Save( iPlayer )
  379.     }
  380.    
  381.     /************ Take hidons access ****************/
  382.     if( equali( szArgs[ 0 ], "/takehidon" ) && get_user_flags( id ) & ADMIN_ACCESS )
  383.     {
  384.         new iPlayer = cmd_target( id, szArgs[ 1 ], 8 )
  385.        
  386.         if( equali( szMsg, "/takehidon" ) )
  387.             return ColorChat( id, "Usage: /^3takehidon^1 <^3name^1>" )
  388.        
  389.         if( !iPlayer )
  390.             return ColorChat( id, "^3%s^1 was not found!", szArgs[ 1 ] )
  391.        
  392.         if( get_user_flags( iPlayer ) & ADMIN_ACCESS )
  393.             return ColorChat( id, "^3%s^1 has full access to turn hidons", GetName( iPlayer ) )
  394.        
  395.         if( VoteAccess[ iPlayer ] == 0 )
  396.             return ColorChat( id, "^3%s^1 has not access to turn hidons", GetName( iPlayer ) )
  397.        
  398.         ColorChat( id, "You took ^3%s^1 the access to turn hidons", GetName( iPlayer ) )
  399.         ColorChat( iPlayer, "Your ^3access^1 to turn hidons has removed" )
  400.        
  401.         VoteAccess[ iPlayer ] = 0
  402.        
  403.         return Save( iPlayer )
  404.     }
  405.    
  406.     return 0
  407. }
  408.  
  409. /************ Start vote ****************/
  410. public startvote( id )
  411. {
  412.     if( VoteStatus == Vote_Running )
  413.         return ColorChat( id, "The ^3hidon^1 is already running" )
  414.    
  415.     remove_task( AutoID )
  416.     set_task( 1.0, "votebefore" )
  417.    
  418.     return ColorChat( 0, "Admin: ^3%s^1 has started ^3hidon^1 vote", GetName( id ) )
  419. }
  420.  
  421. /************ Stop vote ****************/
  422. public stophidon( id )
  423. {
  424.     if( VoteStatus == Vote_NotRunning )
  425.         return ColorChat( id, "There is no ^3hidon^1 running" )
  426.    
  427.     MenuTimer = 0
  428.     winneron = false
  429.    
  430.     order()
  431.     remove_task( WinneroffID )
  432.     remove_task( ShowMsgID )
  433.    
  434.     show_menu( 0, 0, "^n", 1 )
  435.    
  436.     return ColorChat( 0, "Admin: ^3%s^1 has stopped the hidon", GetName( id ) )
  437. }
  438.  
  439. /************ Start math ****************/
  440. public startmath( id )
  441. {
  442.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
  443.    
  444.     if( VoteStatus == Vote_Running ) return ColorChat( id, "The ^3hidon^1 is already running" )
  445.     if( VoteAccess[ id ] > 0 )
  446.     {
  447.         VoteAccess[ id ] -= 1
  448.        
  449.         if( VoteAccess[ id ] > 0 ) ColorChat( id, "You start hidon. you can turn more ^3%d^1 hidons", VoteAccess[ id ] )
  450.         else if( VoteAccess[ id ] == 0 ) ColorChat( id, "Your ^3access^1 to turn hidons has removed" )
  451.        
  452.         Save( id )
  453.     }
  454.    
  455.     Countdown = SetCountdown
  456.     VoteStatus = Vote_Running
  457.     hidonmsg = 1
  458.    
  459.     remove_task( AutoID )
  460.     set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
  461.    
  462.     if( get_user_flags( id ) & ADMIN_ACCESS )
  463.         ColorChat( 0, "Admin: ^3%s^1 has started ^3math quiz", GetName( id ) )
  464.     else
  465.         ColorChat( 0, "^3%s^1 has started ^3math quiz", GetName( id ) )
  466.    
  467.     return 1
  468. }
  469.  
  470. /************ Start english ****************/
  471. public startenglish( id )
  472. {
  473.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
  474.    
  475.     if( VoteStatus == Vote_Running ) return ColorChat( id, "The ^3hidon^1 is already running" )
  476.     if( VoteAccess[ id ] > 0 )
  477.     {
  478.         VoteAccess[ id ] -= 1
  479.        
  480.         if( VoteAccess[ id ] > 0 ) ColorChat( id, "You start hidon. you can turn more ^3%d^1 hidons", VoteAccess[ id ] )
  481.         else if( VoteAccess[ id ] == 0 ) ColorChat( id, "Your ^3access^1 to turn hidons has removed" )
  482.        
  483.         Save( id )
  484.     }
  485.    
  486.     Countdown = SetCountdown
  487.     VoteStatus = Vote_Running
  488.     hidonmsg = 2
  489.    
  490.     remove_task( AutoID )
  491.     set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
  492.    
  493.     if( get_user_flags( id ) & ADMIN_ACCESS )
  494.         ColorChat( 0, "Admin: ^3%s^1 has started ^3english song", GetName( id ) )
  495.     else
  496.         ColorChat( 0, "^3%s^1 has started ^3english song", GetName( id ) )
  497.    
  498.     return 1
  499. }
  500.  
  501. /************ Start anime ****************/
  502. public startanime( id )
  503. {
  504.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
  505.    
  506.     if( VoteStatus == Vote_Running ) return ColorChat( id, "The ^3hidon^1 is already running" )
  507.     if( VoteAccess[ id ] > 0 )
  508.     {
  509.         VoteAccess[ id ] -= 1
  510.        
  511.         if( VoteAccess[ id ] > 0 ) ColorChat( id, "You start hidon. you can turn more ^3%d^1 hidons", VoteAccess[ id ] )
  512.         else if( VoteAccess[ id ] == 0 ) ColorChat( id, "Your ^3access^1 to turn hidons has removed" )
  513.        
  514.         Save( id )
  515.     }
  516.    
  517.     Countdown = SetCountdown
  518.     VoteStatus = Vote_Running
  519.     hidonmsg = 3
  520.    
  521.     remove_task( AutoID )
  522.     set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
  523.    
  524.     if( get_user_flags( id ) & ADMIN_ACCESS )
  525.         ColorChat( 0, "Admin: ^3%s^1 has started ^3anime opening", GetName( id ) )
  526.     else
  527.         ColorChat( 0, "^3%s^1 has started ^3anime opening", GetName( id ) )
  528.    
  529.     return 1
  530. }
  531.  
  532. /************ Before vote ****************/
  533. public votebefore()
  534. {
  535.     winneron = false
  536.     AllVotes = 0
  537.     hidonmsg = 0
  538.     VoteStatus = Vote_Running
  539.     MenuTimer = SetMenuTimer
  540.     Countdown = SetCountdown
  541.    
  542.     arrayset( MyVote, 0, sizeof MyVote )
  543.     arrayset( VoteItem, 0, sizeof VoteItem )
  544.    
  545.     set_task( 1.0, "timelefthidon", VoteID, _, _, "b" )
  546.    
  547.     return PLUGIN_HANDLED
  548. }
  549.  
  550. /************ Before hidon ****************/
  551. public beforehidon()
  552. {
  553.     Countdown--
  554.     if( Countdown == 0 )
  555.     {
  556.         if( hidonmsg == 1 ) Math = true
  557.         if( hidonmsg == 2 ) English = true
  558.         if( hidonmsg == 3 ) Anime = true
  559.        
  560.         remove_task( BeforeID )
  561.        
  562.         return viewhidon()
  563.     }
  564.    
  565.  
  566.     remove_task( WinneroffID )
  567.     remove_task( ShowMsgID )
  568.     winneron = false
  569.     Math = false
  570.     English = false
  571.     Anime = false
  572.    
  573.     client_cmd( 0, "Mp3 stop" )
  574.    
  575.     set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
  576.    
  577.     if( hidonmsg == 1 ) show_dhudmessage( 0, "Math Quiz Will start in %d second%s", Countdown, Countdown == 1 ? ". " : "s." )
  578.     if( hidonmsg == 2 ) show_dhudmessage( 0, "English Song Will start in %d second%s", Countdown, Countdown == 1 ? ". " : "s." )
  579.     if( hidonmsg == 3 ) show_dhudmessage( 0, "Anime Opening Will start in %d second%s", Countdown, Countdown == 1 ? ". " : "s." )
  580.    
  581.     return 1
  582. }
  583.  
  584. /************ View hidon ****************/
  585. public viewhidon()
  586. {
  587.     if( SpecificItem )
  588.     {
  589.         RandomNumber = false
  590.         SpecificItem = false
  591.        
  592.         ColorChat( 0, "The number is: ^3%d^1", numberbind )
  593.        
  594.         set_task( 60.0, "timedone", TimeDoneID )
  595.         set_task( 0.1, "showmsg", ShowMsgID )
  596.        
  597.         formatex( hidonlets, charsmax( hidonlets ), "%d %s", numberbind, answer )
  598.         client_cmd( 0, "mp3 play ^"%s.mp3^"", sound )
  599.        
  600.         return 1
  601.     }
  602.    
  603.     if( hidonmsg == 1 )
  604.     {
  605.         exem1 = random_num( 100, 1000 )
  606.         exem2 = random_num( 100, 1000 )
  607.        
  608.         ColorChat( 0, "how much is ^3%d + %d^1?", exem1, exem2 )
  609.        
  610.         set_task( 10.0, "timedone", TimeDoneID )
  611.         set_task( 0.1, "showmsg", ShowMsgID )
  612.        
  613.         return 1
  614.     }
  615.    
  616.     if( hidonmsg == 2 || hidonmsg == 3 )
  617.     {
  618.         numberbind = random_num( 1, 50 )
  619.         ColorChat( 0, "The number is: ^3%d^1", numberbind )
  620.        
  621.         set_task( 60.0, "timedone", TimeDoneID )
  622.         set_task( 0.1, "showmsg", ShowMsgID )
  623.     }
  624.    
  625.     if( hidonmsg == 2 )
  626.     {
  627.         RndId = random_num( 0, EnglishSongsLoaded-1 )
  628.         copy( answer, sizeof( answer ), EnglishSongs[ RndId ][ song_name ] )
  629.        
  630.         formatex( sound, charsmax( sound ), "%s/%s.mp3", EnglishDefaultPath, EnglishSongs[ RndId ][ file_name ] )
  631.     }
  632.    
  633.     if( hidonmsg == 3 )
  634.     {
  635.         RndId = random_num( 0, AnimeSongsLoaded-1 )
  636.         copy( answer, sizeof( answer ), AnimeSongs[ RndId ][ song_name ] )
  637.        
  638.         formatex( sound, charsmax( sound ), "%s/%s.mp3", AnimeDefaultPath, AnimeSongs[ RndId ][ file_name ] )
  639.     }
  640.    
  641.     formatex( hidonlets, charsmax( hidonlets ), "%d %s", numberbind, answer )
  642.     client_cmd( 0, "mp3 play ^"%s.mp3^"", sound )
  643.    
  644.     return 1
  645. }
  646.  
  647. /************ Show menu ****************/
  648. public timelefthidon()
  649. {
  650.     MenuTimer--
  651.     if( MenuTimer == 0 )
  652.     {
  653.         remove_task( VoteID )
  654.         show_menu( 0, 0, "^n", 1 )
  655.        
  656.         endvote()
  657.         return 1
  658.     }
  659.    
  660.     for( new i; i < get_maxplayers(); i++ )
  661.         if( is_user_connected( i ) )
  662.             votemenu( i )
  663.    
  664.     return 1
  665. }
  666.  
  667. public votemenu( id )
  668. {
  669.     new szMenu[ 555 ]
  670.    
  671.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w choose hidon \d[ All votes \r%d\w/\r%d \d]^n\y> \wStatus: %s^n\
  672.     \y> \wTime to choose: \y%d \wsecond%s ", Prefix, AllVotes, get_playersnum( id ), MyVote[ id ] ? "\yvoted" : "\ddidn't vote", MenuTimer, MenuTimer <= 1 ? "" : "s" )
  673.    
  674.     new menu = menu_create( szMenu, "sub_vote" )
  675.    
  676.     for( new i; i < sizeof hidonItems; i++ )
  677.     {
  678.         formatex( szMenu, charsmax( szMenu ), "%s \d[\w votes: \y%d \d ]", hidonItems[ i ], VoteItem[ i ] )
  679.         menu_additem( menu, szMenu )
  680.     }
  681.    
  682.     menu_display( id, menu )
  683.    
  684.     return 1
  685. }
  686.  
  687. public sub_vote( id, menu, item )
  688. {
  689.     if( item == MENU_EXIT || VoteStatus == Vote_NotRunning ) return menu_destroy( menu )
  690.    
  691.     if( MyVote[ id ] ) return ColorChat( id, "You cannot ^3vote^1 twice." )
  692.    
  693.     ColorChat( 0, "^3%s^1 has chosen ^3%s^1 hidon", GetName( id ), hidonItems[ item ] )
  694.     client_cmd( id, "spk sound/buttons/lightswitch2.wav" )
  695.    
  696.     MyVote[ id ] = true
  697.     VoteItem[ item ]++
  698.     AllVotes++
  699.    
  700.     return votemenu( id )
  701. }
  702.  
  703. /************ Check votes ****************/
  704. public endvote()
  705. {
  706.     new winner, winnercount
  707.     new tie[ sizeof hidonItems ], tienum
  708.    
  709.     for( new i; i < sizeof hidonItems; i++ )
  710.     {
  711.         if( VoteItem[ i ] == winnercount )
  712.             tie[ tienum++ ] = i
  713.        
  714.         else if( VoteItem[ i ] > winnercount )
  715.         {
  716.             winner = i
  717.             winnercount = VoteItem[ i ]
  718.            
  719.             arrayset( tie, 0, sizeof tie )
  720.             tienum = 0
  721.         }
  722.     }
  723.    
  724.     if( !winnercount )
  725.     {
  726.         new randomitem[ 35 ]
  727.         switch( random_num( 1, sizeof hidonItems ) )
  728.         {
  729.             case 1: hidonmsg = 1, randomitem = "Math"
  730.             case 2: hidonmsg = 2, randomitem = "English"
  731.             case 3: hidonmsg = 3, randomitem = "Anime"
  732.         }
  733.        
  734.         set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
  735.         return ColorChat( 0, "No one has voted. ^3%s^1 was ^3randomly^1 chosen.", randomitem )
  736.     }
  737.     else
  738.     {
  739.         if( tienum && VoteItem[ tie[ 0 ] ] == winnercount && winnercount )
  740.         {
  741.             winner = tie[ random( tienum ) ]
  742.             ColorChat( 0, "^3%d^1 or more votes has the same number of votes. ^3random one^1 will be chosen", 2 )
  743.         }
  744.        
  745.         ColorChat( 0, "^3%s^1 won with ^3%d^1 vote%s", hidonItems[ winner ], VoteItem[ winner ], VoteItem[ winner ] == 1 ? "" : "s" )
  746.     }
  747.    
  748.     if( winner == 0 ) hidonmsg = 1
  749.     if( winner == 1 ) hidonmsg = 2
  750.     if( winner == 2 ) hidonmsg = 3
  751.    
  752.     set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
  753.     return 1
  754. }
  755.  
  756. /************ Win msg ****************/
  757. public maths( id )
  758. {
  759.     new szMsg[ 192 ], Arg[ 38 ]
  760.    
  761.     read_argv( 1, szMsg, charsmax( szMsg ) )
  762.    
  763.     parse( szMsg, Arg, charsmax( Arg ) )
  764.    
  765.     if( Math )
  766.     {
  767.         if( equal( Arg, szMsg ) )
  768.         {
  769.             new iNum = str_to_num( szMsg )
  770.             if( iNum == exem1 + exem2 )
  771.             {
  772.                 get_user_name( id, szNamewin, charsmax( szNamewin ) )
  773.                
  774.                 set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
  775.                 show_dhudmessage( 0, "The Winner is %s!!!!!!!.", szNamewin )
  776.                
  777.                 order()
  778.                
  779.                 remove_task( ShowMsgID )
  780.                
  781.                 ColorChat( 0, "The winner is ^3%s^1!. Answer is: ^3%d", szNamewin, exem1 + exem2 )
  782.             }
  783.         }
  784.     }
  785.     return 0
  786. }
  787.  
  788. public Typeanswer( id )
  789. {
  790.     new szArgs[ 192 ]
  791.    
  792.     read_args( szArgs, charsmax( szArgs ) )
  793.    
  794.     remove_quotes( szArgs )
  795.    
  796.     if( !IsChatValid( szArgs ) ) return 0
  797.    
  798.     if( English || Anime )
  799.     {
  800.         if( equali( szArgs, hidonlets ) )
  801.         {
  802.             get_user_name( id, szNamewin, charsmax( szNamewin ) )
  803.             winneron = true
  804.            
  805.             order()
  806.            
  807.             set_task( 10.0, "winneroff", WinneroffID, _, _, "b" )
  808.            
  809.             ColorChat( 0, "The winner is ^3%s^1!. Answer is: ^3%s", szNamewin,  answer )
  810.             ColorChat( 0, "to stop sound write: ^3/s^1 or ^3/stop" )
  811.         }
  812.     }
  813.     return 0
  814. }
  815.  
  816. /************ Admin win msg ****************/
  817. public adminwin( id )
  818. {
  819.     if( get_user_flags( id ) & ADMIN_ACCESS )
  820.     {
  821.         if( English || Anime )
  822.         {
  823.             get_user_name( id, szNamewin, charsmax( szNamewin ) )
  824.             winneron = true
  825.            
  826.             order()
  827.            
  828.             set_task( 10.0, "winneroff", WinneroffID, _, _, "b" )
  829.            
  830.             ColorChat( 0, "The winner is ^3%s^1!. Answer is: ^3%s", szNamewin, answer )
  831.             ColorChat( 0, "to stop sound write: ^3/s^1 or ^3/stop" )
  832.         }
  833.     }
  834.     return 1
  835. }
  836.  
  837. /************ Info msg ****************/
  838. public showmsg()
  839. {
  840.     if( hidonmsg == 1 )
  841.     {
  842.         set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
  843.         show_dhudmessage( 0, "How much is %d + %d ?", exem1, exem2 )
  844.     }
  845.    
  846.     if( winneron )
  847.     {
  848.         if( hidonmsg == 2 || hidonmsg == 3 )
  849.         {
  850.             set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 2, 6.0, 6.0, 0.1, 1.5 )
  851.             show_dhudmessage( 0, "The Winner is %s!!!!!!!^nto stop sound write: /s or /stop", szNamewin )
  852.         }
  853.     }
  854.    
  855.     if( !winneron )
  856.     {
  857.         set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
  858.        
  859.         if( hidonmsg == 2 ) show_dhudmessage( 0, "The Name Of This English Song Is???^nType %d and answer.", numberbind )
  860.         if( hidonmsg == 3 ) show_dhudmessage( 0, "The Name Of This Anime Series Is???^nType %d and answer.", numberbind )
  861.     }
  862.    
  863.     set_task( 3.0, "showmsg", ShowMsgID )
  864. }
  865.  
  866. /************ Time done ****************/
  867. public timedone()
  868. {
  869.     if( Math ) ColorChat( 0, "No one won. the answer is: ^3%d^1", exem1 + exem2 )
  870.     if( English || Anime ) ColorChat( 0, "No one won. the answer is: ^3%s^1", answer )
  871.    
  872.     remove_task( ShowMsgID )
  873.     order()
  874. }
  875.  
  876. public order()
  877. {
  878.     VoteStatus = Vote_NotRunning
  879.     Timeleft = SetTimetohidon
  880.    
  881.     Math = false
  882.     English = false
  883.     Anime = false
  884.    
  885.     remove_task( VoteID )
  886.     remove_task( TimeDoneID )
  887.     remove_task( BeforeID )
  888.    
  889.     set_task( 1.0, "Timetostart", AutoID, _, _, "b" )
  890.    
  891.     return 1
  892. }
  893.  
  894. public winneroff() remove_task( ShowMsgID )
  895.  
  896. /************* Load hidons ****************/
  897. public LoadHidons()
  898. {
  899.     new text[ 64 ]
  900.     if( !file_exists( EnglishCfgFile ) )
  901.     {
  902.         write_file( EnglishCfgFile, "; Song name        Song file^n" )
  903.         write_file( EnglishCfgFile, "; Song name - the name and the answer of the song" )
  904.         write_file( EnglishCfgFile, "; Song file -  The file of the song just need to write the name of the file without .mp3^n" )
  905.         write_file( EnglishCfgFile, "; Example - ^"Im sexy and i know it^"  ^"Im_sexy_and_i_know_it^"" )
  906.         log_amx( "No English were found!" )
  907.     }
  908.     else if( file_exists( EnglishCfgFile ) )
  909.     {
  910.         new file = fopen( EnglishCfgFile, "rt" )
  911.        
  912.         while( !feof( file ) )
  913.         {
  914.             fgets( file, text, charsmax( text ) )
  915.             trim( text )
  916.            
  917.             if( text[ 0 ] == ';' || !text[ 0 ] ) continue
  918.            
  919.             parse( text, EnglishSongs[ EnglishSongsLoaded ][ song_name ], charsmax( EnglishSongs ), EnglishSongs[ EnglishSongsLoaded ][ file_name ], charsmax( EnglishSongs ) )
  920.             replace_all( EnglishSongs[ EnglishSongsLoaded ][ file_name ], charsmax( EnglishSongs ), "_", "" )
  921.            
  922.             EnglishSongsLoaded++
  923.         }
  924.         fclose( file )
  925.     }
  926.    
  927.     if( !file_exists( AnimeCfgFile ) )
  928.     {
  929.         write_file( AnimeCfgFile, "; Song name      Song file^n" )
  930.         write_file( AnimeCfgFile, "; Song name - the name and the answer of the song" )
  931.         write_file( AnimeCfgFile, "; Song file -  The file of the song just need to write the name of the file without .mp3^n" )
  932.         write_file( AnimeCfgFile, "; Example - ^"Dragon ball super^"    ^"Dragon_ball_super^"" )
  933.         log_amx( "No Anime were found!" )
  934.     }
  935.     else if( file_exists( AnimeCfgFile ) )
  936.     {
  937.         new file = fopen( AnimeCfgFile, "rt" )
  938.        
  939.         while( !feof( file ) )
  940.         {
  941.             fgets( file, text, charsmax( text ) )
  942.             trim( text )
  943.            
  944.             if( text[ 0 ] == ';' || !text[ 0 ] ) continue
  945.            
  946.             parse( text, AnimeSongs[ AnimeSongsLoaded ][ song_name ], charsmax( AnimeSongs ), AnimeSongs[ AnimeSongsLoaded ][ file_name ], charsmax( AnimeSongs ) )
  947.             replace_all( AnimeSongs[ AnimeSongsLoaded ][ file_name ], charsmax( AnimeSongs ), "_", "" )
  948.            
  949.             AnimeSongsLoaded++
  950.         }
  951.         fclose( file )
  952.     }
  953.    
  954.     if( !file_exists( EnglishCfgFile ) && !file_exists( AnimeCfgFile ) ) pause( "a" )
  955.     return 1
  956. }
  957.  
  958. /************* Save ****************/
  959. stock Save( id )
  960. {
  961.     new szData[ 256 ]
  962.    
  963.     formatex( szData, charsmax( szData ), "%i %s", VoteAccess[ id ], GetName( id ) )
  964.     fvault_set_data( Vault, GetAuth( id ), szData )
  965.    
  966.     return 1
  967. }
  968.  
  969. /************* Load ****************/
  970. stock Load( id )
  971. {
  972.     new szData[ 256 ], SetData[ 1 ][ 32 ]
  973.    
  974.     formatex( szData, charsmax( szData ), "%i", VoteAccess[ id ] )
  975.     fvault_get_data( Vault, GetAuth( id ), szData, charsmax( szData ) )
  976.    
  977.     parse( szData, SetData[ 0 ], charsmax( SetData ) )
  978.    
  979.     VoteAccess[ id ]        = str_to_num( SetData[ 0 ] )
  980.    
  981.     return 1
  982. }
  983.  
  984. /************ Is chat valid ****************/
  985. IsChatValid( const szChat[] )
  986. {
  987.     new cChar, iCharCounter
  988.     while( ( cChar = szChat[ iCharCounter++ ] ) != EOS )
  989.         if ( cChar != ' ' )
  990.             return 1
  991.    
  992.     return 0
  993. }
  994.  
  995. /************* Stocks ****************/
  996. stock GetName( id )
  997. {
  998.     new name[ 32 ]
  999.     get_user_name( id, name, charsmax( name ) )
  1000.     return name
  1001. }
  1002.  
  1003. stock GetAuth( id )
  1004. {
  1005.     new AuthID[ 32 ]
  1006.     get_user_authid( id, AuthID, charsmax( AuthID ) )
  1007.     return AuthID
  1008. }
  1009.  
  1010. /************* ColorChat ****************/
  1011. stock ColorChat( const client, const string[ ], { Float, Sql, Resul,_ }:... )
  1012. {
  1013.     new msg[ 191 ], players[ 32 ], count = 1
  1014.    
  1015.     static len; len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
  1016.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
  1017.    
  1018.     if( client )
  1019.         players[ 0 ] = client
  1020.     else
  1021.         get_players( players, count, "ch" )
  1022.    
  1023.     for( new i; i < count; i++ )
  1024.     {
  1025.         if( is_user_connected( players[ i ] ) )
  1026.         {
  1027.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
  1028.             write_byte( players[ i ] )
  1029.             write_string( msg )
  1030.             message_end()
  1031.         }
  1032.     }
  1033.     return 1
  1034. }
Add Comment
Please, Sign In to add comment