Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********** Includes ************/
- #include < amxmodx >
- #include < amxmisc >
- #include < fvault >
- #include < dhudmessage >
- /*********** Defines ************/
- #define Prefix "AMXX" // The prefix
- #define ADMIN_ACCESS ADMIN_IMMUNITY // The access to the menu / start / stop hidons
- #define Vault "Hidon-System" // The vault save file
- /*********** Hidons settings ************/
- #define Folder "addons/amxmodx/configs/hidons"
- #define EnglishCfgFile "addons/amxmodx/configs/hidons/english.txt"
- #define AnimeCfgFile "addons/amxmodx/configs/hidons/anime.txt"
- #define SoundFolder "sound/hidons"
- #define EnglishDefaultPath "sound/hidons/English"
- #define AnimeDefaultPath "sound/hidons/Anime"
- /*********** Timers ************/
- #define AutoID 1 // Stop task of The timer of /hidon
- #define VoteID 2 // Stop task of vote menu
- #define BeforeID 3 // Stop task of the countdown to the vote menu
- #define ShowMsgID 4 // Stop task of the showing of the question
- #define TimeDoneID 5 // Stop task of the time to win
- #define WinneroffID 6 // Stop task of the winner msg
- #define SetTimetohidon 300 // Default time of waiting for the vote
- #define SetMenuTimer 15 // The menu timer
- #define SetCountdown 6 // The countdown for starting song
- new Timeleft = SetTimetohidon
- new MenuTimer = SetMenuTimer
- new Countdown = SetCountdown
- /*********** Hidons stuff ************/
- new const hidonItems[][] =
- {
- "Math", "English", "Anime"
- }
- /*********** Vote access ************/
- new VoteAccess[ 33 ]
- /*********** Vote status ************/
- enum VoteStats
- {
- Vote_NotRunning,
- Vote_Running
- }
- new VoteStats: VoteStatus = Vote_NotRunning
- /*********** Vote stuff ************/
- new MyVote[ 33 ], AllVotes
- new VoteItem[ sizeof hidonItems ], winneron = false
- new hidonlets[ 64 ], answer[ 32 ] = "", numberbind
- new szNamewin[ 32 ], hidonmsg
- /*********** Ini items ************/
- new RndId = -1, sound[ 64 ]
- enum _:SongProperties
- {
- song_name[ 31 ],
- file_name[ 120 ]
- }
- new exem1, exem2, Math = false
- new EnglishSongs[ 120 ][ SongProperties ], EnglishSongsLoaded = 0, English = false
- new AnimeSongs[ 120 ][ SongProperties ], AnimeSongsLoaded = 0, Anime = false
- /************ Nes **************/
- new MenuType[ 33 ], MyChoose[ 33 ], SpecificItem = false, RandomNumber = false
- /*********** Plugin init ************/
- public plugin_init()
- {
- register_plugin( "Hidons", "v1.0", "RanAway`" )
- /*********** Commands ************/
- register_clcmd( "say", "CmdSay" )
- /*********** Answers ************/
- register_clcmd( "say", "maths" )
- register_clcmd( "say", "Typeanswer" )
- /*********** Timer ************/
- set_task( 1.0, "Timetostart", AutoID, _, _, "b" )
- /*********** Create the folder **********/
- if( !dir_exists( Folder ) )
- mkdir( Folder )
- /*********** Create the sound folder **********/
- if( !dir_exists( SoundFolder ) )
- mkdir( SoundFolder )
- /*********** Create the english folder **********/
- if( !dir_exists( EnglishDefaultPath ) )
- mkdir( EnglishDefaultPath )
- /*********** Create the anime folder **********/
- if( !dir_exists( AnimeDefaultPath ) )
- mkdir( AnimeDefaultPath )
- /*********** Load Hidons **********/
- LoadHidons()
- }
- /*********** Precache ************/
- public plugin_precache()
- {
- new szItem[ 256 ]
- for( new i; i < EnglishSongsLoaded; i++ ) formatex( szItem, charsmax( szItem ), "%s/%s.mp3", EnglishDefaultPath, EnglishSongs[ i ][ file_name ] )
- for( new i; i < AnimeSongsLoaded; i++ ) formatex( szItem, charsmax( szItem ), "%s/%s.mp3", AnimeDefaultPath, AnimeSongs[ i ][ file_name ] )
- if( EnglishSongsLoaded != 0 || AnimeSongsLoaded != 0 )
- precache_generic( szItem )
- }
- /*********** Connecting / Disconnecting ************/
- public client_disconnect( id ) Save( id )
- public client_putinserver( id )
- {
- VoteAccess[ id ] = 0
- Load( id )
- }
- /*********** Time to start ************/
- public Timetostart()
- {
- Timeleft--
- if( Timeleft == 0 )
- {
- remove_task( AutoID )
- VoteStatus = Vote_Running
- ColorChat( 0, "The ^3hidon^1 has started" )
- votebefore()
- }
- }
- /*********** Hidon menu ************/
- public hidonmenu( id )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
- new szMenu[ 250 ]
- 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 ] )
- new menu = menu_create( szMenu, "sub_hidonmenu" )
- menu_additem( menu, "start vote", .callback = menu_makecallback( "blockcmd" ) )
- menu_additem( menu, "stop hidon^n", .callback = menu_makecallback( "blockcmd" ) )
- menu_additem( menu, "Start Math" )
- menu_additem( menu, "Start English" )
- menu_additem( menu, "Start Anime^n" )
- if( get_user_flags( id ) & ADMIN_ACCESS )
- {
- menu_additem( menu, "Start specific song" )
- menu_additem( menu, "Win English" )
- menu_additem( menu, "Win Anime" )
- }
- menu_display( id, menu )
- return 1
- }
- public sub_hidonmenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return menu_destroy( menu )
- if( item == 0 ) startvote( id )
- if( item == 1 ) stophidon( id )
- if( item == 2 ) startmath( id )
- if( item == 3 ) startenglish( id )
- if( item == 4 ) startanime( id )
- if( item == 5 ) return songmenu( id )
- if( item >= 6 ) adminwin( id )
- return hidonmenu( id )
- }
- public blockcmd( id, menu, item )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) )
- return ITEM_DISABLED
- return 0
- }
- /*********** Song menu ************/
- public songmenu( id )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
- new szMenu[ 250 ]
- formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w hidon menu", Prefix )
- new menu = menu_create( szMenu, "sub_songmenu" )
- formatex( szMenu, charsmax( szMenu ), "English \r[\y %d\w songs \r]", EnglishSongsLoaded )
- menu_additem( menu, szMenu )
- formatex( szMenu, charsmax( szMenu ), "Anime \r[\y %d\w series \r]", AnimeSongsLoaded )
- menu_additem( menu, szMenu )
- menu_setprop( menu, MPROP_EXITNAME, "Back" )
- menu_display( id, menu )
- return 1
- }
- public sub_songmenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return hidonmenu( id )
- if( item == 0 ) MenuType[ id ] = 1
- if( item == 1 ) MenuType[ id ] = 2
- MyChoose[ id ] = 0
- return ChooseSong( id )
- }
- /*********** Song menu ************/
- public ChooseSong( id )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
- new szMenu[ 250 ]
- if( MenuType[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w English menu \r[\y %d\w songs \r]\w", Prefix, EnglishSongsLoaded )
- if( MenuType[ id ] == 2 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w Anime menu\r[\y %d\w series \r]\w", Prefix, AnimeSongsLoaded )
- new menu = menu_create( szMenu, "sub_choosesong" )
- if( MenuType[ id ] == 1 ) for( new i; i < EnglishSongsLoaded; i++ ) menu_additem( menu, ( "%s", EnglishSongs[ i ][ song_name ] ) )
- if( MenuType[ id ] == 2 ) for( new i; i < AnimeSongsLoaded; i++ ) menu_additem( menu, ( "%s", AnimeSongs[ i ][ song_name ] ) )
- menu_setprop( menu, MPROP_EXITNAME, "Back" )
- menu_display( id, menu )
- return 1
- }
- public sub_choosesong( id, menu, item )
- {
- if( item == MENU_EXIT ) return songmenu( id )
- MyChoose[ id ] = item
- return PlayMenu( id )
- }
- /*********** Play menu ************/
- public PlayMenu( id )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
- new szMenu[ 250 ]
- if( MenuType[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w Play English", Prefix )
- if( MenuType[ id ] == 2 ) formatex( szMenu, charsmax( szMenu ), "\r[ \w%s\r ]\w Play Anime", Prefix )
- new menu = menu_create( szMenu, "sub_playmenu" )
- if( RandomNumber )
- {
- formatex( szMenu, charsmax( szMenu ), "Random number \r[\w %d \r]", numberbind )
- menu_additem( menu, szMenu )
- }
- else menu_additem( menu, "Random number" )
- if( MenuType[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "Play \r[\w %s \r]", EnglishSongs[ MyChoose[ id ] ][ song_name ] )
- if( MenuType[ id ] == 2 ) formatex( szMenu, charsmax( szMenu ), "Play \r[\w %s \r]", AnimeSongs[ MyChoose[ id ] ][ song_name ] )
- menu_additem( menu, szMenu )
- menu_setprop( menu, MPROP_EXITNAME, "Back" )
- menu_display( id, menu )
- return 1
- }
- public sub_playmenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return songmenu( id )
- SpecificItem = true
- if( item == 0 )
- {
- RandomNumber = true
- numberbind = random_num( 1, 50 )
- PlayMenu( id )
- }
- if( item == 1 )
- {
- if( !RandomNumber ) numberbind = random_num( 1, 50 )
- if( MenuType[ id ] == 1 )
- {
- copy( answer, sizeof( answer ), EnglishSongs[ MyChoose[ id ] ][ song_name ] )
- formatex( sound, charsmax( sound ), "%s/%s.mp3", EnglishDefaultPath, EnglishSongs[ MyChoose[ id ] ][ file_name ] )
- startenglish( id )
- }
- if( MenuType[ id ] == 2 )
- {
- copy( answer, sizeof( answer ), AnimeSongs[ MyChoose[ id ] ][ song_name ] )
- formatex( sound, charsmax( sound ), "%s%s.mp3", AnimeDefaultPath, AnimeSongs[ MyChoose[ id ] ][ file_name ] )
- startanime( id )
- }
- }
- return 1
- }
- /*********** CmdSay ************/
- public CmdSay( id )
- {
- new szMsg[ 192 ], szArgs[ 3 ][ 32 ]
- read_argv( 1, szMsg, charsmax( szMsg ) )
- parse( szMsg, szArgs[ 0 ], charsmax( szArgs ), szArgs[ 1 ], charsmax( szArgs ), szArgs[ 2 ], charsmax( szArgs ) )
- /************ Admin commands ****************/
- if( equali( szMsg, "/starthidon" ) && get_user_flags( id ) & ADMIN_ACCESS ) return startvote( id )
- if( equali( szMsg, "/stophidon" ) && get_user_flags( id ) & ADMIN_ACCESS ) return stophidon( id )
- if( equali( szMsg, "/hidonmenu" ) ) return hidonmenu( id )
- if( equali( szMsg, "/math" ) ) return startmath( id )
- if( equali( szMsg, "/english" ) ) return startenglish( id )
- if( equali( szMsg, "/anime" ) ) return startanime( id )
- /************ Commands ****************/
- if( equali( szMsg, "/stop" ) || equali( szMsg, "/stopsong" ) || equali( szMsg, "/stopmusic" ) || equali( szMsg, "/s" ) ) return client_cmd( id, "Mp3 stop" )
- if( equali( szMsg, "/replay" ) || equali( szMsg, "/replaysong" ) || equali( szMsg, "/replaymusic" ) ) return client_cmd( id, "mp3 play ^"%s.mp3^"", sound )
- /************ Show how much hidons you can turn ****************/
- if( equali( szMsg, "/status" ) )
- if( VoteAccess[ id ] > 0 )
- return ColorChat( id, "You can turn only ^3%d^1 more hidons", VoteAccess[ id ] )
- /************ Show when hidon ****************/
- if( equali( szMsg, "/hidon" ) || equali ( szMsg, "/hidons" ) || equali( szMsg, "/nexthidon" ) || equali( szMsg, "/nexthidons" ) )
- {
- if( VoteStatus == Vote_Running )
- return ColorChat( id, "The ^3hidon^1 is already running" )
- return ColorChat( id, "The hidon will be start in ^3%02d:%02d^1 minute%s", Timeleft/60, Timeleft%60, Timeleft/60 > 1 ? "s" : "" )
- }
- /************ Reset timer ****************/
- if( equali( szMsg, "/fixtimer" ) && get_user_flags( id ) & ADMIN_ACCESS )
- return order()
- /************ Give hidons access ****************/
- if( equali( szArgs[ 0 ], "/givehidon" ) && get_user_flags( id ) & ADMIN_ACCESS )
- {
- new iPlayer = cmd_target( id, szArgs[ 1 ], 8 )
- new Amount = str_to_num( szArgs[ 2 ] )
- if( !is_str_num( szArgs[ 2 ] ) || equali( szMsg, "/givehidon" ) )
- return ColorChat( id, "Usage: /^3givehidon^1 <^3name^1> <^3amount^1>" )
- if( !iPlayer )
- return ColorChat( id, "^3%s^1 was not found!", szArgs[ 1 ] )
- if( Amount < 0 )
- return ColorChat( id, "You can't set a value lower than^3 0^1." )
- if( get_user_flags( iPlayer ) & ADMIN_ACCESS )
- return ColorChat( id, "^3%s^1 has full access to turn hidons", GetName( iPlayer ) )
- ColorChat( id, "You gave ^3%s^1 access to turn ^3%i^1 hidons", GetName( iPlayer ), Amount )
- ColorChat( iPlayer, "You got ^3access^1 to turn hidons now. You can start ^3%i^1 hidons", Amount )
- VoteAccess[ iPlayer ] = Amount
- return Save( iPlayer )
- }
- /************ Take hidons access ****************/
- if( equali( szArgs[ 0 ], "/takehidon" ) && get_user_flags( id ) & ADMIN_ACCESS )
- {
- new iPlayer = cmd_target( id, szArgs[ 1 ], 8 )
- if( equali( szMsg, "/takehidon" ) )
- return ColorChat( id, "Usage: /^3takehidon^1 <^3name^1>" )
- if( !iPlayer )
- return ColorChat( id, "^3%s^1 was not found!", szArgs[ 1 ] )
- if( get_user_flags( iPlayer ) & ADMIN_ACCESS )
- return ColorChat( id, "^3%s^1 has full access to turn hidons", GetName( iPlayer ) )
- if( VoteAccess[ iPlayer ] == 0 )
- return ColorChat( id, "^3%s^1 has not access to turn hidons", GetName( iPlayer ) )
- ColorChat( id, "You took ^3%s^1 the access to turn hidons", GetName( iPlayer ) )
- ColorChat( iPlayer, "Your ^3access^1 to turn hidons has removed" )
- VoteAccess[ iPlayer ] = 0
- return Save( iPlayer )
- }
- return 0
- }
- /************ Start vote ****************/
- public startvote( id )
- {
- if( VoteStatus == Vote_Running )
- return ColorChat( id, "The ^3hidon^1 is already running" )
- remove_task( AutoID )
- set_task( 1.0, "votebefore" )
- return ColorChat( 0, "Admin: ^3%s^1 has started ^3hidon^1 vote", GetName( id ) )
- }
- /************ Stop vote ****************/
- public stophidon( id )
- {
- if( VoteStatus == Vote_NotRunning )
- return ColorChat( id, "There is no ^3hidon^1 running" )
- MenuTimer = 0
- winneron = false
- order()
- remove_task( WinneroffID )
- remove_task( ShowMsgID )
- show_menu( 0, 0, "^n", 1 )
- return ColorChat( 0, "Admin: ^3%s^1 has stopped the hidon", GetName( id ) )
- }
- /************ Start math ****************/
- public startmath( id )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
- if( VoteStatus == Vote_Running ) return ColorChat( id, "The ^3hidon^1 is already running" )
- if( VoteAccess[ id ] > 0 )
- {
- VoteAccess[ id ] -= 1
- if( VoteAccess[ id ] > 0 ) ColorChat( id, "You start hidon. you can turn more ^3%d^1 hidons", VoteAccess[ id ] )
- else if( VoteAccess[ id ] == 0 ) ColorChat( id, "Your ^3access^1 to turn hidons has removed" )
- Save( id )
- }
- Countdown = SetCountdown
- VoteStatus = Vote_Running
- hidonmsg = 1
- remove_task( AutoID )
- set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
- if( get_user_flags( id ) & ADMIN_ACCESS )
- ColorChat( 0, "Admin: ^3%s^1 has started ^3math quiz", GetName( id ) )
- else
- ColorChat( 0, "^3%s^1 has started ^3math quiz", GetName( id ) )
- return 1
- }
- /************ Start english ****************/
- public startenglish( id )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
- if( VoteStatus == Vote_Running ) return ColorChat( id, "The ^3hidon^1 is already running" )
- if( VoteAccess[ id ] > 0 )
- {
- VoteAccess[ id ] -= 1
- if( VoteAccess[ id ] > 0 ) ColorChat( id, "You start hidon. you can turn more ^3%d^1 hidons", VoteAccess[ id ] )
- else if( VoteAccess[ id ] == 0 ) ColorChat( id, "Your ^3access^1 to turn hidons has removed" )
- Save( id )
- }
- Countdown = SetCountdown
- VoteStatus = Vote_Running
- hidonmsg = 2
- remove_task( AutoID )
- set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
- if( get_user_flags( id ) & ADMIN_ACCESS )
- ColorChat( 0, "Admin: ^3%s^1 has started ^3english song", GetName( id ) )
- else
- ColorChat( 0, "^3%s^1 has started ^3english song", GetName( id ) )
- return 1
- }
- /************ Start anime ****************/
- public startanime( id )
- {
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) && VoteAccess[ id ] == 0 ) return 0
- if( VoteStatus == Vote_Running ) return ColorChat( id, "The ^3hidon^1 is already running" )
- if( VoteAccess[ id ] > 0 )
- {
- VoteAccess[ id ] -= 1
- if( VoteAccess[ id ] > 0 ) ColorChat( id, "You start hidon. you can turn more ^3%d^1 hidons", VoteAccess[ id ] )
- else if( VoteAccess[ id ] == 0 ) ColorChat( id, "Your ^3access^1 to turn hidons has removed" )
- Save( id )
- }
- Countdown = SetCountdown
- VoteStatus = Vote_Running
- hidonmsg = 3
- remove_task( AutoID )
- set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
- if( get_user_flags( id ) & ADMIN_ACCESS )
- ColorChat( 0, "Admin: ^3%s^1 has started ^3anime opening", GetName( id ) )
- else
- ColorChat( 0, "^3%s^1 has started ^3anime opening", GetName( id ) )
- return 1
- }
- /************ Before vote ****************/
- public votebefore()
- {
- winneron = false
- AllVotes = 0
- hidonmsg = 0
- VoteStatus = Vote_Running
- MenuTimer = SetMenuTimer
- Countdown = SetCountdown
- arrayset( MyVote, 0, sizeof MyVote )
- arrayset( VoteItem, 0, sizeof VoteItem )
- set_task( 1.0, "timelefthidon", VoteID, _, _, "b" )
- return PLUGIN_HANDLED
- }
- /************ Before hidon ****************/
- public beforehidon()
- {
- Countdown--
- if( Countdown == 0 )
- {
- if( hidonmsg == 1 ) Math = true
- if( hidonmsg == 2 ) English = true
- if( hidonmsg == 3 ) Anime = true
- remove_task( BeforeID )
- return viewhidon()
- }
- remove_task( WinneroffID )
- remove_task( ShowMsgID )
- winneron = false
- Math = false
- English = false
- Anime = false
- client_cmd( 0, "Mp3 stop" )
- set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
- if( hidonmsg == 1 ) show_dhudmessage( 0, "Math Quiz Will start in %d second%s", Countdown, Countdown == 1 ? ". " : "s." )
- if( hidonmsg == 2 ) show_dhudmessage( 0, "English Song Will start in %d second%s", Countdown, Countdown == 1 ? ". " : "s." )
- if( hidonmsg == 3 ) show_dhudmessage( 0, "Anime Opening Will start in %d second%s", Countdown, Countdown == 1 ? ". " : "s." )
- return 1
- }
- /************ View hidon ****************/
- public viewhidon()
- {
- if( SpecificItem )
- {
- RandomNumber = false
- SpecificItem = false
- ColorChat( 0, "The number is: ^3%d^1", numberbind )
- set_task( 60.0, "timedone", TimeDoneID )
- set_task( 0.1, "showmsg", ShowMsgID )
- formatex( hidonlets, charsmax( hidonlets ), "%d %s", numberbind, answer )
- client_cmd( 0, "mp3 play ^"%s.mp3^"", sound )
- return 1
- }
- if( hidonmsg == 1 )
- {
- exem1 = random_num( 100, 1000 )
- exem2 = random_num( 100, 1000 )
- ColorChat( 0, "how much is ^3%d + %d^1?", exem1, exem2 )
- set_task( 10.0, "timedone", TimeDoneID )
- set_task( 0.1, "showmsg", ShowMsgID )
- return 1
- }
- if( hidonmsg == 2 || hidonmsg == 3 )
- {
- numberbind = random_num( 1, 50 )
- ColorChat( 0, "The number is: ^3%d^1", numberbind )
- set_task( 60.0, "timedone", TimeDoneID )
- set_task( 0.1, "showmsg", ShowMsgID )
- }
- if( hidonmsg == 2 )
- {
- RndId = random_num( 0, EnglishSongsLoaded-1 )
- copy( answer, sizeof( answer ), EnglishSongs[ RndId ][ song_name ] )
- formatex( sound, charsmax( sound ), "%s/%s.mp3", EnglishDefaultPath, EnglishSongs[ RndId ][ file_name ] )
- }
- if( hidonmsg == 3 )
- {
- RndId = random_num( 0, AnimeSongsLoaded-1 )
- copy( answer, sizeof( answer ), AnimeSongs[ RndId ][ song_name ] )
- formatex( sound, charsmax( sound ), "%s/%s.mp3", AnimeDefaultPath, AnimeSongs[ RndId ][ file_name ] )
- }
- formatex( hidonlets, charsmax( hidonlets ), "%d %s", numberbind, answer )
- client_cmd( 0, "mp3 play ^"%s.mp3^"", sound )
- return 1
- }
- /************ Show menu ****************/
- public timelefthidon()
- {
- MenuTimer--
- if( MenuTimer == 0 )
- {
- remove_task( VoteID )
- show_menu( 0, 0, "^n", 1 )
- endvote()
- return 1
- }
- for( new i; i < get_maxplayers(); i++ )
- if( is_user_connected( i ) )
- votemenu( i )
- return 1
- }
- public votemenu( id )
- {
- new szMenu[ 555 ]
- 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\
- \y> \wTime to choose: \y%d \wsecond%s ", Prefix, AllVotes, get_playersnum( id ), MyVote[ id ] ? "\yvoted" : "\ddidn't vote", MenuTimer, MenuTimer <= 1 ? "" : "s" )
- new menu = menu_create( szMenu, "sub_vote" )
- for( new i; i < sizeof hidonItems; i++ )
- {
- formatex( szMenu, charsmax( szMenu ), "%s \d[\w votes: \y%d \d ]", hidonItems[ i ], VoteItem[ i ] )
- menu_additem( menu, szMenu )
- }
- menu_display( id, menu )
- return 1
- }
- public sub_vote( id, menu, item )
- {
- if( item == MENU_EXIT || VoteStatus == Vote_NotRunning ) return menu_destroy( menu )
- if( MyVote[ id ] ) return ColorChat( id, "You cannot ^3vote^1 twice." )
- ColorChat( 0, "^3%s^1 has chosen ^3%s^1 hidon", GetName( id ), hidonItems[ item ] )
- client_cmd( id, "spk sound/buttons/lightswitch2.wav" )
- MyVote[ id ] = true
- VoteItem[ item ]++
- AllVotes++
- return votemenu( id )
- }
- /************ Check votes ****************/
- public endvote()
- {
- new winner, winnercount
- new tie[ sizeof hidonItems ], tienum
- for( new i; i < sizeof hidonItems; i++ )
- {
- if( VoteItem[ i ] == winnercount )
- tie[ tienum++ ] = i
- else if( VoteItem[ i ] > winnercount )
- {
- winner = i
- winnercount = VoteItem[ i ]
- arrayset( tie, 0, sizeof tie )
- tienum = 0
- }
- }
- if( !winnercount )
- {
- new randomitem[ 35 ]
- switch( random_num( 1, sizeof hidonItems ) )
- {
- case 1: hidonmsg = 1, randomitem = "Math"
- case 2: hidonmsg = 2, randomitem = "English"
- case 3: hidonmsg = 3, randomitem = "Anime"
- }
- set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
- return ColorChat( 0, "No one has voted. ^3%s^1 was ^3randomly^1 chosen.", randomitem )
- }
- else
- {
- if( tienum && VoteItem[ tie[ 0 ] ] == winnercount && winnercount )
- {
- winner = tie[ random( tienum ) ]
- ColorChat( 0, "^3%d^1 or more votes has the same number of votes. ^3random one^1 will be chosen", 2 )
- }
- ColorChat( 0, "^3%s^1 won with ^3%d^1 vote%s", hidonItems[ winner ], VoteItem[ winner ], VoteItem[ winner ] == 1 ? "" : "s" )
- }
- if( winner == 0 ) hidonmsg = 1
- if( winner == 1 ) hidonmsg = 2
- if( winner == 2 ) hidonmsg = 3
- set_task( 1.0, "beforehidon", BeforeID, _, _, "b" )
- return 1
- }
- /************ Win msg ****************/
- public maths( id )
- {
- new szMsg[ 192 ], Arg[ 38 ]
- read_argv( 1, szMsg, charsmax( szMsg ) )
- parse( szMsg, Arg, charsmax( Arg ) )
- if( Math )
- {
- if( equal( Arg, szMsg ) )
- {
- new iNum = str_to_num( szMsg )
- if( iNum == exem1 + exem2 )
- {
- get_user_name( id, szNamewin, charsmax( szNamewin ) )
- set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
- show_dhudmessage( 0, "The Winner is %s!!!!!!!.", szNamewin )
- order()
- remove_task( ShowMsgID )
- ColorChat( 0, "The winner is ^3%s^1!. Answer is: ^3%d", szNamewin, exem1 + exem2 )
- }
- }
- }
- return 0
- }
- public Typeanswer( id )
- {
- new szArgs[ 192 ]
- read_args( szArgs, charsmax( szArgs ) )
- remove_quotes( szArgs )
- if( !IsChatValid( szArgs ) ) return 0
- if( English || Anime )
- {
- if( equali( szArgs, hidonlets ) )
- {
- get_user_name( id, szNamewin, charsmax( szNamewin ) )
- winneron = true
- order()
- set_task( 10.0, "winneroff", WinneroffID, _, _, "b" )
- ColorChat( 0, "The winner is ^3%s^1!. Answer is: ^3%s", szNamewin, answer )
- ColorChat( 0, "to stop sound write: ^3/s^1 or ^3/stop" )
- }
- }
- return 0
- }
- /************ Admin win msg ****************/
- public adminwin( id )
- {
- if( get_user_flags( id ) & ADMIN_ACCESS )
- {
- if( English || Anime )
- {
- get_user_name( id, szNamewin, charsmax( szNamewin ) )
- winneron = true
- order()
- set_task( 10.0, "winneroff", WinneroffID, _, _, "b" )
- ColorChat( 0, "The winner is ^3%s^1!. Answer is: ^3%s", szNamewin, answer )
- ColorChat( 0, "to stop sound write: ^3/s^1 or ^3/stop" )
- }
- }
- return 1
- }
- /************ Info msg ****************/
- public showmsg()
- {
- if( hidonmsg == 1 )
- {
- set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
- show_dhudmessage( 0, "How much is %d + %d ?", exem1, exem2 )
- }
- if( winneron )
- {
- if( hidonmsg == 2 || hidonmsg == 3 )
- {
- 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 )
- show_dhudmessage( 0, "The Winner is %s!!!!!!!^nto stop sound write: /s or /stop", szNamewin )
- }
- }
- if( !winneron )
- {
- set_dhudmessage( random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ), -1.0, 0.30, 0, 1.0, 1.0 )
- if( hidonmsg == 2 ) show_dhudmessage( 0, "The Name Of This English Song Is???^nType %d and answer.", numberbind )
- if( hidonmsg == 3 ) show_dhudmessage( 0, "The Name Of This Anime Series Is???^nType %d and answer.", numberbind )
- }
- set_task( 3.0, "showmsg", ShowMsgID )
- }
- /************ Time done ****************/
- public timedone()
- {
- if( Math ) ColorChat( 0, "No one won. the answer is: ^3%d^1", exem1 + exem2 )
- if( English || Anime ) ColorChat( 0, "No one won. the answer is: ^3%s^1", answer )
- remove_task( ShowMsgID )
- order()
- }
- public order()
- {
- VoteStatus = Vote_NotRunning
- Timeleft = SetTimetohidon
- Math = false
- English = false
- Anime = false
- remove_task( VoteID )
- remove_task( TimeDoneID )
- remove_task( BeforeID )
- set_task( 1.0, "Timetostart", AutoID, _, _, "b" )
- return 1
- }
- public winneroff() remove_task( ShowMsgID )
- /************* Load hidons ****************/
- public LoadHidons()
- {
- new text[ 64 ]
- if( !file_exists( EnglishCfgFile ) )
- {
- write_file( EnglishCfgFile, "; Song name Song file^n" )
- write_file( EnglishCfgFile, "; Song name - the name and the answer of the song" )
- write_file( EnglishCfgFile, "; Song file - The file of the song just need to write the name of the file without .mp3^n" )
- write_file( EnglishCfgFile, "; Example - ^"Im sexy and i know it^" ^"Im_sexy_and_i_know_it^"" )
- log_amx( "No English were found!" )
- }
- else if( file_exists( EnglishCfgFile ) )
- {
- new file = fopen( EnglishCfgFile, "rt" )
- while( !feof( file ) )
- {
- fgets( file, text, charsmax( text ) )
- trim( text )
- if( text[ 0 ] == ';' || !text[ 0 ] ) continue
- parse( text, EnglishSongs[ EnglishSongsLoaded ][ song_name ], charsmax( EnglishSongs ), EnglishSongs[ EnglishSongsLoaded ][ file_name ], charsmax( EnglishSongs ) )
- replace_all( EnglishSongs[ EnglishSongsLoaded ][ file_name ], charsmax( EnglishSongs ), "_", "" )
- EnglishSongsLoaded++
- }
- fclose( file )
- }
- if( !file_exists( AnimeCfgFile ) )
- {
- write_file( AnimeCfgFile, "; Song name Song file^n" )
- write_file( AnimeCfgFile, "; Song name - the name and the answer of the song" )
- write_file( AnimeCfgFile, "; Song file - The file of the song just need to write the name of the file without .mp3^n" )
- write_file( AnimeCfgFile, "; Example - ^"Dragon ball super^" ^"Dragon_ball_super^"" )
- log_amx( "No Anime were found!" )
- }
- else if( file_exists( AnimeCfgFile ) )
- {
- new file = fopen( AnimeCfgFile, "rt" )
- while( !feof( file ) )
- {
- fgets( file, text, charsmax( text ) )
- trim( text )
- if( text[ 0 ] == ';' || !text[ 0 ] ) continue
- parse( text, AnimeSongs[ AnimeSongsLoaded ][ song_name ], charsmax( AnimeSongs ), AnimeSongs[ AnimeSongsLoaded ][ file_name ], charsmax( AnimeSongs ) )
- replace_all( AnimeSongs[ AnimeSongsLoaded ][ file_name ], charsmax( AnimeSongs ), "_", "" )
- AnimeSongsLoaded++
- }
- fclose( file )
- }
- if( !file_exists( EnglishCfgFile ) && !file_exists( AnimeCfgFile ) ) pause( "a" )
- return 1
- }
- /************* Save ****************/
- stock Save( id )
- {
- new szData[ 256 ]
- formatex( szData, charsmax( szData ), "%i %s", VoteAccess[ id ], GetName( id ) )
- fvault_set_data( Vault, GetAuth( id ), szData )
- return 1
- }
- /************* Load ****************/
- stock Load( id )
- {
- new szData[ 256 ], SetData[ 1 ][ 32 ]
- formatex( szData, charsmax( szData ), "%i", VoteAccess[ id ] )
- fvault_get_data( Vault, GetAuth( id ), szData, charsmax( szData ) )
- parse( szData, SetData[ 0 ], charsmax( SetData ) )
- VoteAccess[ id ] = str_to_num( SetData[ 0 ] )
- return 1
- }
- /************ Is chat valid ****************/
- IsChatValid( const szChat[] )
- {
- new cChar, iCharCounter
- while( ( cChar = szChat[ iCharCounter++ ] ) != EOS )
- if ( cChar != ' ' )
- return 1
- return 0
- }
- /************* Stocks ****************/
- stock GetName( id )
- {
- new name[ 32 ]
- get_user_name( id, name, charsmax( name ) )
- return name
- }
- stock GetAuth( id )
- {
- new AuthID[ 32 ]
- get_user_authid( id, AuthID, charsmax( AuthID ) )
- return AuthID
- }
- /************* ColorChat ****************/
- stock ColorChat( const client, const string[ ], { Float, Sql, Resul,_ }:... )
- {
- new msg[ 191 ], players[ 32 ], count = 1
- static len; len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
- if( client )
- players[ 0 ] = client
- else
- get_players( players, count, "ch" )
- for( new i; i < count; i++ )
- {
- if( is_user_connected( players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
- write_byte( players[ i ] )
- write_string( msg )
- message_end()
- }
- }
- return 1
- }
Add Comment
Please, Sign In to add comment