Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- enum g_enSongs
- {
- g_mFolder[ 64 ],
- g_mAuthor[ 32 ],
- g_mName[ 64 ]
- };
- new const szMusic[ ][ g_enSongs ] =
- {
- { "Directory", "Author1", "Name1" },
- { "Directory", "Author2", "Name2" },
- { "Directory", "Author3", "Name3" }
- };
- new const szPrefix[ ] = "AdvGames";
- new szItem[ 128 ], g_iSong[ 33 ], g_iVolume[ 33 ];
- public plugin_init()
- {
- register_plugin( "Music Menu", "1.0", "Rejack" );
- register_clcmd( "say /music", "CmdMusicMenu" );
- register_clcmd( "say /stop", "CmdStopMusic" );
- }
- public plugin_natives()
- {
- register_library( "Music" );
- register_native( "MusicOn", "_MusicOn" );
- }
- public plugin_precache()
- {
- for ( new i; i < sizeof szMusic; i++ )
- precache_sound( szMusic[ i ][ g_mFolder ] );
- }
- public client_putinserver( client )
- {
- client_cmd( client, "MP3Volume ^"1.0^"" );
- g_iVolume[ client ] = 5;
- g_iSong[ client ] = 0;
- }
- public _MusicOn()
- {
- for ( new i = 1; i < get_maxplayers(); i++ )
- {
- if ( !is_user_connected( i ) )
- continue;
- g_iSong[ i ] = 0;
- PlaySong( i );
- CmdMusicMenu( i );
- }
- }
- public CmdStopMusic( client )
- {
- StopSong( client );
- }
- public CmdMusicMenu( client )
- {
- formatex( szItem, charsmax( szItem ), "\r[%s]\w Music Menu", szPrefix );
- new Menu = menu_create( szItem, "SubMusicMenu" );
- formatex( szItem, charsmax( szItem ), "\dPlaying:\y %s\w by\r %s^n", szMusic[ g_iSong[ client ] ][ g_mName ], szMusic[ g_iSong[ client ] ][ g_mAuthor ] );
- menu_additem( Menu, szItem );
- menu_additem( Menu, "\d[\r>>\d]\w Next Song " );
- menu_additem( Menu, "\d[\r<<\d]\w Previous Song" );
- menu_additem( Menu, "\d[\r><\d]\w Stop Song^n" );
- formatex( szItem, charsmax( szItem ), "Volume:\d %i0%%^n", g_iVolume[ client ] );
- menu_additem( Menu, szItem );
- menu_additem( Menu, "\yVolume Up" );
- menu_additem( Menu, "\rVolume Down" );
- menu_display( client, Menu );
- return 1;
- }
- public SubMusicMenu( client, Menu, Item )
- {
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- switch ( Item )
- {
- case 0: return CmdMusicMenu( client );
- case 1:
- {
- if ( g_iSong[ client ] == charsmax( szMusic ) )
- g_iSong[ client ] = -1;
- g_iSong[ client ]++;
- PlaySong( client );
- return CmdMusicMenu( client );
- }
- case 2:
- {
- if ( g_iSong[ client ] == 0 )
- g_iSong[ client ] = sizeof szMusic;
- g_iSong[ client ]--;
- PlaySong( client );
- return CmdMusicMenu( client );
- }
- case 3:
- {
- StopSong( client );
- return CmdMusicMenu( client );
- }
- case 4: return CmdMusicMenu( client );
- case 5:
- {
- if ( g_iVolume[ client ] != 10 )
- {
- g_iVolume[ client ]++;
- SetVolume( client );
- }
- return CmdMusicMenu( client );
- }
- case 6:
- {
- if ( g_iVolume[ client ] != 0 )
- {
- g_iVolume[ client ]--;
- SetVolume( client );
- }
- return CmdMusicMenu( client );
- }
- }
- return 1;
- }
- stock PlaySong( const index )
- {
- client_cmd( index, "mp3 play ^"sound/%s^"", szMusic[ g_iSong[ index ] ][ g_mFolder ] );
- }
- stock SetVolume( const index )
- {
- static Float: volume;
- volume = g_iVolume[ index ] * 0.2;
- client_cmd( index, "MP3Volume ^"%.1f^"", volume );
- }
- stock StopSong( const index )
- {
- client_cmd( index, "mp3 stop" );
- }
- stock ColorPrint( const index, const string[], any:... )
- {
- new szMsg[ 191 ], Players[ 32 ], PNum = 1;
- static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^4[%s]^1 ", szPrefix );
- vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
- if ( index )
- Players[ 0 ] = index;
- else
- get_players( Players, PNum, "ch" );
- for ( new i; i < PNum; i++ )
- {
- if( is_user_connected( Players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
- write_byte( Players[ i ] );
- write_string( szMsg );
- message_end( );
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement