Boombox wip

This commit is contained in:
Dusan 2019-06-05 15:51:14 +02:00
parent 3e517f0847
commit d5f40ba2b6

View File

@ -41,8 +41,8 @@ hook OnPlayerEnterDynArea( playerid, areaid )
if ( areaid == g_boomboxData[ i ] [ E_MUSIC_AREA ] )
{
// start the music
PlayAudioStreamForPlayer( i, g_boomboxData[ playerid ][ E_URL ], g_boomboxData[ playerid ][ E_X ], g_boomboxData[ playerid ][ E_Y ], g_boomboxData[ playerid ][ E_Z ] );
SendServerMessage( i, "You are now listening to a nearby boombox!" );
PlayAudioStreamForPlayer( playerid, g_boomboxData[ i ] [ E_URL ], g_boomboxData[ i ] [ E_X ], g_boomboxData[ i ] [ E_Y ], g_boomboxData[ i ] [ E_Z ], DEFAULT_BOOMBOX_RANGE, 1 );
SendServerMessage( playerid, "You are now listening to a nearby boombox!" );
return 1;
}
}
@ -59,8 +59,8 @@ hook OnPlayerLeaveDynArea( playerid, areaid )
if ( areaid == g_boomboxData[ i ] [ E_MUSIC_AREA ] )
{
// stop the music
StopAudioStreamForPlayer( i );
SendServerMessage( i, "You stopped listening to a nearby boombox!" );
StopAudioStreamForPlayer( playerid );
SendServerMessage( playerid, "You stopped listening to a nearby boombox!" );
return 1;
}
}
@ -78,10 +78,10 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
if ( GetPlayerPos( playerid, X, Y, Z ) && GetPlayerFacingAngle( playerid, Angle ) )
{
Boombox_Create( playerid, inputtext, X, Y, Z, Angle );
p_UsingBoombox{ playerid } = true;
PlayAudioStreamForPlayer( playerid, g_boomboxData[ playerid ][ E_URL ], X, Y, Z, 30, 1 );
SendServerMessage( playerid, "If the stream doesn't respond then it must be offline. Use "COL_GREY"/stopboombox"COL_WHITE" to stop the stream." );
// PlayAudioStreamForPlayer( playerid, g_boomboxData[ playerid ] [ E_URL ], X, Y, Z, DEFAULT_BOOMBOX_RANGE, 1 );
SendServerMessage( playerid, "If the stream doesn't respond then it must be offline. Use "COL_GREY"/boombox stop"COL_WHITE" to stop the stream." );
}
}
@ -99,6 +99,7 @@ CMD:boombox( playerid, params[ ] )
if ( strmatch( params, "play" ) )
{
if ( IsPlayerUsingBoombox( playerid ) ) return SendError( playerid, "You are already using Boombox." );
if ( IsPlayerNearBoombox( playerid ) ) return SendError( playerid, "You cannot be near another Boombox if you wish to create your own." );
ShowPlayerDialog( playerid, DIALOG_BOOMBOX_PLAY, DIALOG_STYLE_INPUT, ""COL_WHITE"Boombox", ""COL_WHITE"Enter the URL below, and streaming will begin.\n\n"COL_ORANGE"Please note, if there isn't a response. It's likely to be an invalid URL.", "Stream", "Back" );
}
@ -137,8 +138,21 @@ stock Boombox_Create( playerid, szURL[ ], Float: X, Float: Y, Float: Z, Float: A
{
format( g_boomboxData[ playerid ] [ E_URL ], 128, "%s", szURL );
g_boomboxData[ playerid ] [ E_X ] = X;
g_boomboxData[ playerid ] [ E_Y ] = Y;
g_boomboxData[ playerid ] [ E_Z ] = Z;
g_boomboxData[ playerid ] [ E_OBJECT ] = CreateDynamicObject( 2226, X, Y, Z - 0.92, 0, 0, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ), -1, Angle );
g_boomboxData[ playerid ] [ E_LABEL ] = CreateDynamic3DTextLabel( sprintf( "Owner: %s(%d)", ReturnPlayerName( playerid ), playerid ), COLOR_GOLD, X, Y, Z+0.1, 10, .worldid = GetPlayerVirtualWorld( playerid ), .interiorid = GetPlayerInterior( playerid ) );
g_boomboxData[ playerid ] [ E_LABEL ] = CreateDynamic3DTextLabel( sprintf( "%s(%d)'s Boombox", ReturnPlayerName( playerid ), playerid ), COLOR_GOLD, X, Y, Z+0.1, 10, .worldid = GetPlayerVirtualWorld( playerid ), .interiorid = GetPlayerInterior( playerid ) );
g_boomboxData[ playerid ] [ E_MUSIC_AREA ] = CreateDynamicSphere( X, Y, Z, fDistance, .worldid = GetPlayerVirtualWorld( playerid ), .interiorid = GetPlayerInterior( playerid ) );
return 1;
stock IsPlayerNearBoombox( playerid )
{
foreach ( new i : Player ) {
if ( GetPlayerDistanceFromPoint( playerid, g_boomboxData[ i ] [ E_X ], g_boomboxData[ i ] [ E_Y ], g_boomboxData[ i ] [ E_Z ] ) < DEFAULT_BOOMBOX_RANGE ) {
return true;
}
}
return false;
}