Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include " a_samp "
- #include " a_mysql " //MySQL R8, cu functii cache.
- #include " sscanf2 "
- #include " zcmd "
- #include " ytstream "
- /* Ca sa va mearga bine stream-ul, trebuie sa puneti partea de PHP
- al acestui script, in celalate fisiere .php unde aveti forumul.
- http://forum.sa-mp.com/showthread.php?t=370450
- PS> Sa fiu sincer, pe Windows nu prea stiu unde sa puneti chestia aia :))
- */
- #define mysql_host "localhost"
- #define mysql_user "root"
- #define mysql_pass ""
- #define mysql_db "samp"
- #define MAX_PLAYER_TRACKS (10)
- #define DIALOG_SELECT_TRACK (1000)
- #define DIALOG_INSERT_TRACK_URL (1001)
- #define DIALOG_INSERT_TRACK_NAME (1002)
- //============================================================================//
- new
- c_Handle,
- f_global_query[ 512 ],
- f_global_string[ 512 ],
- bool:g_IsInDatabase[ MAX_PLAYERS ],
- g_PlayerTrackLing[ MAX_PLAYERS ][ MAX_PLAYER_TRACKS ][ 256 ],
- g_PlayerTrackName[ MAX_PLAYERS ][ MAX_PLAYER_TRACKS ][ 256 ],
- g_PlayerTotalTracks[ MAX_PLAYERS ]
- ;
- //============================================================================//
- public OnPlayerConnect( playerid )
- {
- format( f_global_query, 128, "SELECT * FROM `Tracks` WHERE `user` = '%s'", n_Get( playerid ) );
- return mysql_function_query( c_Handle, f_global_query, true, "CheckInTable", "i", playerid );
- }
- public OnFilterScriptInit( )
- {
- c_Handle = mysql_connect( mysql_host, mysql_user, mysql_db, mysql_pass, 3306 );
- mysql_function_query( c_Handle, "CREATE TABLE IF NOT EXISTS `Tracks` (`user` TEXT, `links` TEXT, `names` TEXT)", false, "", "" );
- return 1;
- }
- public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
- {
- switch( dialogid )
- {
- case DIALOG_SELECT_TRACK:
- {
- if ( !response )
- return 1;
- YoutubeStreamForPlayer( playerid, g_PlayerTrackLing[ playerid ][ listitem + 1 ] );
- format( f_global_string, 128, "INFO: {FFFFFF}You are now playing '{33AA33}%s{FFFFFF}'", g_PlayerTrackName[ playerid ][ listitem + 1 ] );
- SendClientMessage( playerid, 0xFFFF00FF, f_global_string );
- }
- case DIALOG_INSERT_TRACK_URL:
- {
- if ( !response )
- return 1;
- new url[ 256 ];
- if ( sscanf( inputtext, "s[256]", url ) )
- return ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_URL, DIALOG_STYLE_INPUT, "Add Track", "{FFFFFF}Please put here the youtube url of track do you want to\nbe in your playlist", "Add", "Cancel" );
- if ( strlen( url ) < 30 )
- return ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_URL, DIALOG_STYLE_INPUT, "Add Track", "{FFFFFF}Please put here the youtube url of track do you want to\nbe in your playlist", "Add", "Cancel" );
- if ( strfind( url, "youtube", false ) == -1 )
- return ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_URL, DIALOG_STYLE_INPUT, "Add Track", "{FFFFFF}Please put here the youtube url of track do you want to\nbe in your playlist", "Add", "Cancel" );
- format( g_PlayerTrackLing[ playerid ][ g_PlayerTotalTracks[ playerid ] + 1 ], 256, url );
- format( g_PlayerTrackName[ playerid ][ g_PlayerTotalTracks[ playerid ] + 1 ], 128, "No-Name Set" );
- g_PlayerTotalTracks[ playerid ]++;
- format( f_global_query, 128, "UPDATE `Tracks` SET `total_tracks` = %d WHERE `user` = '%s';", g_PlayerTotalTracks[ playerid ], n_Get( playerid ) );
- mysql_function_query( c_Handle, f_global_query, false, "", "" );
- ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_NAME, DIALOG_STYLE_INPUT, "Music Name", "{FFFFFF}Please type here the music name for what you've added it at your playlist", "Set", "Cancel" );
- return 1;
- }
- case DIALOG_INSERT_TRACK_NAME:
- {
- if ( !response )
- return 1;
- new t_name[ 256 ];
- if ( sscanf( inputtext, "s[256]", t_name ) )
- return ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_NAME, DIALOG_STYLE_INPUT, "Music Name", "{FFFFFF}Please type here the music name for what you've added it at your playlist", "Set", "Cancel" );
- if ( strlen( t_name ) < 3 )
- return ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_NAME, DIALOG_STYLE_INPUT, "Music Name", "{FFFFFF}Please type here the music name for what you've added it at your playlist", "Set", "Cancel" );
- format( g_PlayerTrackName[ playerid ][ g_PlayerTotalTracks[ playerid ] ], 128, t_name );
- format( f_global_string, 128, "You've added a track, called '{33AA33}%s{FFFFFF}'", g_PlayerTrackName[ playerid ][ g_PlayerTotalTracks[ playerid ] ] );
- SendClientMessage( playerid, ~1, f_global_string );
- format( f_global_query, 256, "SELECT `links`,`names` FROM `Tracks` WHERE `user` = '%s'", n_Get( playerid ) );
- mysql_function_query( c_Handle, f_global_query, true, "AddToTracklist", "i", playerid );
- return 1;
- }
- }
- return 1;
- }
- //============================================================================//
- COMMAND:mp3( playerid, params[ ] )
- {
- if ( g_IsInDatabase[ playerid ] == false )
- return SendClientMessage( playerid, 0xFF0000FF, "ERROR: {FFFFFF}You don't have any track in your track list" );
- format( f_global_query, 128, "SELECT * FROM `Tracks` WHERE `user` = '%s'", n_Get( playerid ) );
- return mysql_function_query( c_Handle, f_global_query, true, "ShowTracks", "i", playerid );
- }
- COMMAND:tadd( playerid, params[ ] )
- {
- if ( g_PlayerTotalTracks[ playerid ] >= MAX_PLAYER_TRACKS )
- return SendClientMessage( playerid, ~1, "You already have 10 in your track list" );
- if ( g_IsInDatabase[ playerid ] == true )
- ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_URL, DIALOG_STYLE_INPUT, "Add Track", "{FFFFFF}Please put here the youtube url of track do you want to\nbe in your playlist", "Add", "Cancel" );
- else
- {
- format( f_global_string, 128, "INSERT INTO `Tracks` (`user`,`links`,`names`) VALUES('%s',' ', ' ' )", n_Get( playerid ) );
- mysql_function_query( c_Handle, f_global_string, false, "", "" );
- g_IsInDatabase[ playerid ] = true;
- ShowPlayerDialog( playerid, DIALOG_INSERT_TRACK_URL, DIALOG_STYLE_INPUT, "Add Track", "{FFFFFF}Please put here the youtube url of track do you want to\nbe in your playlist", "Add", "Cancel" );
- }
- return 1;
- }
- COMMAND:tstop( playerid, params[ ] )
- {
- YoutubeStopStreamForPlayer( playerid );
- return SendClientMessage( playerid, 0xFFFF00FF, "INFO: {FFFFFF}You've stopped the audio streaming" );
- }
- //============================================================================//
- forward CheckInTable( playerid );
- public CheckInTable( playerid )
- {
- if ( !IsPlayerConnected( playerid ) )
- return 0;
- new Rows, Fields;
- cache_get_data( Rows, Fields, c_Handle );
- if ( Rows )
- g_IsInDatabase[ playerid ] = true;
- else
- g_IsInDatabase[ playerid ] = false;
- return 1;
- }
- forward ShowTracks( playerid );
- public ShowTracks( playerid )
- {
- if ( !IsPlayerConnected( playerid ) )
- return 0;
- new Rows, Fields, Field[ 1024 ], string[ 1024 ];
- cache_get_data( Rows, Fields, c_Handle );
- if ( !Rows )
- return SendClientMessage( playerid, ~1, "An error has encountered." );
- format( string, 128, "p<|>a<s[256]>[%d]", g_PlayerTotalTracks[ playerid ] );
- cache_get_field_content( 0, "links", Field, c_Handle );
- for ( new i = 0; i < MAX_PLAYER_TRACKS; ++ i )
- sscanf( Field, string, g_PlayerTrackLing[ playerid ][ i ] );
- cache_get_field_content( 0, "names", Field, c_Handle );
- for ( new i = 0; i < MAX_PLAYER_TRACKS; ++ i )
- sscanf( Field, string, g_PlayerTrackName[ playerid ][ i ] );
- for ( new i = 0; i < MAX_PLAYER_TRACKS; ++ i )
- format( string, 1024, "%s", g_PlayerTrackName[ playerid ][ i ] );
- return ShowPlayerDialog( playerid, DIALOG_SELECT_TRACK, DIALOG_STYLE_LIST, "Tracks", string, "Play", "Quit" );
- }
- forward AddToTracklist( playerid );
- public AddToTracklist( playerid )
- {
- if ( !IsPlayerConnected( playerid ) )
- return 0;
- new Field[ 2 ][ 1024 ];
- cache_get_field_content( 0, "links", Field[ 0 ] );
- cache_get_field_content( 0, "names", Field[ 1 ] );
- format( f_global_query, 256, "UPDATE `Tracks` SET `links` = '%s%s|',`names` = '%s%s|' WHERE `user` = '%s'", Field[ 0 ], g_PlayerTrackLing[ playerid ][ g_PlayerTotalTracks[ playerid ] ], Field[ 1 ], g_PlayerTrackName[ playerid ][ g_PlayerTotalTracks[ playerid ] ], n_Get( playerid ) );
- return mysql_function_query( c_Handle, f_global_query, false, "", "" );
- }
- //============================================================================//
- stock n_Get( playerid )
- {
- new name[ MAX_PLAYER_NAME ];
- GetPlayerName( playerid, name, MAX_PLAYER_NAME );
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement