Boombox wip
This commit is contained in:
parent
3e517f0847
commit
d5f40ba2b6
@ -36,13 +36,13 @@ hook OnPlayerEnterDynArea( playerid, areaid )
|
||||
{
|
||||
foreach ( new i : Player )
|
||||
{
|
||||
if ( IsValidDynamicArea( g_boomboxData[ i ][ E_MUSIC_AREA ] ) )
|
||||
if ( IsValidDynamicArea( g_boomboxData[ i ] [ E_MUSIC_AREA ] ) )
|
||||
{
|
||||
if ( areaid == g_boomboxData[ i ][ E_MUSIC_AREA ] )
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -54,13 +54,13 @@ hook OnPlayerLeaveDynArea( playerid, areaid )
|
||||
{
|
||||
foreach ( new i : Player )
|
||||
{
|
||||
if ( IsValidDynamicArea( g_boomboxData[ i ][ E_MUSIC_AREA ] ) )
|
||||
if ( IsValidDynamicArea( g_boomboxData[ i ] [ E_MUSIC_AREA ] ) )
|
||||
{
|
||||
if ( areaid == g_boomboxData[ i ][ E_MUSIC_AREA ] )
|
||||
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" );
|
||||
}
|
||||
@ -125,7 +126,7 @@ stock Boombox_Destroy( playerid )
|
||||
g_boomboxData[ playerid ] [ E_X ] = 0.0;
|
||||
g_boomboxData[ playerid ] [ E_Y ] = 0.0;
|
||||
g_boomboxData[ playerid ] [ E_Z ] = 0.0;
|
||||
g_boomboxData[ playerid ] [ E_URL ][ 0 ] = '\0';
|
||||
g_boomboxData[ playerid ] [ E_URL ] [ 0 ] = '\0';
|
||||
|
||||
DestroyDynamicObject( g_boomboxData[ playerid ] [ E_OBJECT ] );
|
||||
DestroyDynamic3DTextLabel( g_boomboxData[ playerid ] [ E_LABEL ] );
|
||||
@ -135,10 +136,23 @@ stock Boombox_Destroy( playerid )
|
||||
|
||||
stock Boombox_Create( playerid, szURL[ ], Float: X, Float: Y, Float: Z, Float: Angle, Float: fDistance = DEFAULT_BOOMBOX_RANGE )
|
||||
{
|
||||
format( g_boomboxData[ playerid ][ E_URL ], 128, "%s", szURL );
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user