Music Player pe server :)[Rezolvat!]

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
Post Reply
User avatar
valio_skull
Membru, skill 0
Membru, skill 0
Posts: 66
Joined: 10 Jan 2013, 16:17
Detinator Steam: Nu
CS Status: Caut pluginuri
Has thanked: 14 times
Been thanked: 1 time
Contact:

31 Jul 2013, 17:04

Salutare eXtreamCS, As dori un Plugin
Vreau un plugin la care sa scrii /music si sa-ti apara un meniu:
1. Melodia 1
2. Melodia mea
...
7. Melodia lui ...
8. Inapoi
9. Inainte
0. Iesi

Iar melodiile sa fie in sound/
Si sa le scriu untr-un fisier .ini in genu asta
"sound/misc/music.mp3" "Numele_Melodiei"
"sound/Music2.wav" "Numele_Melodiei2"
DAR NU VREAU SA LA AUD DOAR EU, Sa le auda toti de pe server
Si sa ai nevoie de ADMIN_IMMUNITY Ca sa ai acces
Multumesc MUULT Si anticipat !!!!! ^_^
Contact | Afiseaza codul
Contact: valio_skull
Skype: zzz_maddoxx
RoyalServer 2
User avatar
oneeightone
Fost moderator
Fost moderator
Posts: 2547
Joined: 17 Jul 2009, 19:29
Detinator Steam: Da
Reputatie: Fost super moderator
Membru Club eXtreamCS (o luna)
Nick anterior : LiGHTERS
0.3 / 3
Has thanked: 68 times
Been thanked: 521 times

31 Jul 2013, 21:53

| Afiseaza codul
#include < amxmodx >
#include < amxmisc >

#define MUSIC_ACCESS	 ADMIN_IMMUNITY

enum _:g_mMusicArray
{
	g_mName[ 32 ],
	g_mAuthor[ 18 ],
	g_mPath[ 64 ]
}

new g_szMusicFile[ 64 ], g_iSong[ 33 ], g_iToAll[ 33 ], Float:g_fVolume[ 33 ];

new Array:g_aSongs;

public plugin_init( )
{
	register_plugin( "Music Menu", "v1.0", "XControlX" );
	
	register_saycmd( "/music", "CmdMusicMenu", ADMIN_IMMUNITY, "- Open the music menu." );
	
	register_saycmd( "/stop", "CmdStopMusic", ADMIN_IMMUNITY, "- Stop the music." );
	
}

public plugin_precache( )
{
	g_aSongs = ArrayCreate( g_mMusicArray );
	
	loadMusics( );
	
	new music[ g_mMusicArray ];
	
	for ( new i = 0; i < ArraySize( g_aSongs ) - 1; i++ )
	{
		ArrayGetArray( g_aSongs, i, music );
		
		precache_sound( music[ g_mPath ] );
	}
}

public plugin_end( )
{
	ArrayDestroy( g_aSongs );
}

public client_connect( client )
{
	g_iSong[ client ] = 0;
	
	g_iToAll[ client ] = 0;
	
	g_fVolume[ client ] = 0.5;
}

public CmdMusicMenu( client )
{
	if ( ! is_user_connected( client ) )	return 1;
	
	if ( ArraySize( g_aSongs ) <= 1 )	return ColorChat( client, "The server didn't load any song." );
	
	new music[ g_mMusicArray ], item[ 50 ];
	
	ArrayGetArray( g_aSongs, g_iSong[ client ], music );
	
	new menu = menu_create( "\r[Music] \yMusic Menu^n\wChoose your options:", "CmdMusicHandler" );
	
	new callback = menu_makecallback( "CmdMusicCallback" );
	
	formatex( item, charsmax( item ), "\rSong: [\y%s\r]", music[ g_mName ] );
	
	menu_additem( menu, item );
	
	formatex( item, charsmax( item ), "\rAuthor: [\y%s\r]", music[ g_mAuthor ] );
	
	menu_additem( menu, item, _, _, callback );
	
	formatex( item, charsmax( item ), "\rVolume: [\y%.1f\r]", g_fVolume[ client ] );
	
	menu_additem( menu, item );
	
	formatex( item, charsmax( item ), "\rPlay To All: [\y%sable\r]", g_iToAll[ client ] ? "En" : "Dis" );
	
	menu_additem( menu, item, _, _, callback );
	
	menu_addblank( menu, 0 );
	
	menu_additem( menu, "\rStart The Music" );
	
	menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
	
	menu_setprop( menu, MPROP_EXITNAME, "\rExit Music Menu" );
	
	menu_setprop( menu, MPROP_NUMBER_COLOR, "\d" );
	
	menu_display( client, menu, 0 );
	
	return 1;
}

public CmdMusicCallback( client, menu, item )
{
	switch ( item )
	{
		case 1:		return ITEM_DISABLED;
		
		case 3:		return ( get_user_flags( client ) & MUSIC_ACCESS ) ? ITEM_ENABLED : ITEM_DISABLED;
	}
	
	return ITEM_ENABLED;
}

public CmdMusicHandler( client, menu, item )
{
	if ( item != MENU_EXIT )
	{
		switch ( item )
		{
			case 0:
			{
				( g_iSong[ client ] >= ( ArraySize( g_aSongs )  - 1 ) ) ? ( g_iSong[ client ] = 0 ) : ( g_iSong[ client ] += 1 );
				
				return CmdMusicMenu( client );
			}
			
			case 2:
			{
				( g_fVolume[ client ] > 1.0 ) ? ( g_fVolume[ client ] = 0.1 ) : ( g_fVolume[ client ] += 0.1 );
				
				return CmdMusicMenu( client );
			}
			
			case 3:
			{
				if ( ! ( get_user_flags( client ) & MUSIC_ACCESS ) ) return CmdMusicMenu( client );
				
				g_iToAll[ client ] = ! g_iToAll[ client ];
				
				return CmdMusicMenu( client );
			}
			
			case 4:
			{				
				new music[ g_mMusicArray ];
				
				ArrayGetArray( g_aSongs, g_iSong[ client ], music );
				
				( g_iToAll[ client ] ) ? client_cmd( 0, "mp3 play ^"sound/%s^"", music[ g_mPath ] ) : client_cmd( client, "mp3 play ^"sound/%s^"", music[ g_mPath ] );
				
				( g_iToAll[ client ] ) ? client_cmd( 0, "MP3Volume %.1f", g_fVolume[ client ] ) : client_cmd( client, "MP3Volume %.1f", g_fVolume[ client ] );
				
				( g_iToAll[ client ] ) ? ColorChat( 0, "^x03 Admin %s^x01 has started the song^x03 ^"%s^"^x01, by^x03 ^"%s^"^x01.^x04 (Volume: %.1f)", GetUserName( client ), music[ g_mName ], music[ g_mAuthor ], g_fVolume[ client ] ) : ColorChat( client, "You have started the song^x03 ^"%s^"^x01, by^x03 ^"%s^"^x01.^x04 (Volume: %.1f)", music[ g_mName ], music[ g_mAuthor ], g_fVolume[ client ] );
			}
		}
	}
	
	menu_destroy( menu );
	
	return 1;
}

public CmdStopMusic( client )
{
	if ( ! is_user_connected( client ) )	return 1;
	
	client_cmd( client, "mp3 stop" );
	
	ColorChat( client, "You have^x03 stoped^x01 the music." );
	
	return 1;
}

stock GetUserName( const index )
{
	static name[ 32 ];
	
	get_user_name( index, name, charsmax( name ) );
	
	return name;
}

stock loadMusics( )
{
	get_configsdir( g_szMusicFile, charsmax( g_szMusicFile ) );
	
	add( g_szMusicFile, charsmax( g_szMusicFile ), "/MusicMenu.ini" );
	
	if ( ! file_exists( g_szMusicFile ) )
	{
		write_file( g_szMusicFile, "; Music Menu By xControl" );
		
		write_file( g_szMusicFile, "; ==================================================" );
		
		write_file( g_szMusicFile, "; How to add a song to the menu:" );
		
		write_file( g_szMusicFile, "; ^"music name^" ^"music author^" ^"music path^"" );
		
		write_file( g_szMusicFile, "; ==================================================" );
	}
	
	new buffer[ 128 ], args[ g_mMusicArray ];
	
	new file = fopen( g_szMusicFile, "rt" );
	
	while ( ! feof( file ) )
	{
		fgets( file, buffer, charsmax( buffer ) );
		
		remove_quotes( buffer );
		
		if ( buffer[ 0 ] == ';' || equali( buffer, "//", 2 ) || strlen( buffer ) < 5 )	continue;
		
		parse( buffer, args[ g_mName ], charsmax( args[ g_mName ] ), args[ g_mAuthor ], charsmax( args[ g_mAuthor ] ), args[ g_mPath ], charsmax( args[ g_mPath ] ) );
		
		new song[ 64 ];
		
		formatex( song, charsmax( song ), "sound/%s", args[ g_mPath ] );
		
		if ( ! file_exists( song ) )
		{
			log_amx( "Can't load song %s by %s (%s)", args[ g_mName ], args[ g_mAuthor ], song );
			
			continue;
		}
		
		ArrayPushArray( g_aSongs, args );
	}
	
	fclose( file );
	
	( ArraySize( g_aSongs ) < 1 ) ? log_amx( "Can't load any song from file." ) : log_amx( "Successfuly loaded %i songs from file.", ArraySize( g_aSongs ) );
}

stock register_saycmd( command[ ], function[ ], flags, description[ ] )
{
	new signs[ ] = { "/", "!", "." };
	
	new types[ ] = { "say", "say_team" };
	
	new temp[ 64 ];
	
	for ( new i = 0; i < sizeof( signs ); i++ )
	{
		for ( new j = 0; j < sizeof( types ); j++ )
		{
			formatex( temp, charsmax( temp ), "%s %s%s", types[ j ], signs[ i ], command );
			
			register_clcmd( temp, function, flags, description );
		}
	}
}

stock ColorChat( const iPlayer, const szMsg[ ], { Float, Sql, Resul, _ } : ... ) 	
{
	new iMsg[ 191 ], iPlayers[ 32 ], iCount = 1;
	
	static iLen;
	iLen = formatex( iMsg, charsmax( iMsg ), "^x04[Music]^x01 " );
	
	vformat( iMsg[ iLen ], charsmax( iMsg ) - iLen, szMsg, 3 ); 
	    
	if ( iPlayer )
		iPlayers[ 0 ] = iPlayer;
		
	else    
		get_players( iPlayers, iCount, "ch" );
		
	for ( new i = 0; i < iCount; i++ )
	{
		if ( ! is_user_connected( iPlayers[ i ] ) )
			continue;
			
		message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, iPlayers[ i ] );
		write_byte( iPlayers[ i ] );
		write_string( iMsg );
		message_end( );
	}
	
	return 1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ lang1037\\ f0\\ fs16 \n\\ par }
*/
Aproximativ ceea ce vrei tu.

Adaugi melodiile in MusicMenu.ini (fie il creezi tu, fie ti-l creeaza serverul cand rulezi plugin-ul) din configs dupa urmatorul mode:

Code: Select all

"Nume melodie" "Autor" "Locatie"
Exemplu:

"Gangnam Style" "PSY" "MusicMenu/gangnam_style.mp3"
User avatar
valio_skull
Membru, skill 0
Membru, skill 0
Posts: 66
Joined: 10 Jan 2013, 16:17
Detinator Steam: Nu
CS Status: Caut pluginuri
Has thanked: 14 times
Been thanked: 1 time
Contact:

01 Aug 2013, 20:07

Multumesc muult !!!
Last edited by d3zz on 03 Aug 2013, 09:32, edited 1 time in total.
Reason: Rezolvat
Contact | Afiseaza codul
Contact: valio_skull
Skype: zzz_maddoxx
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests