Merge pull request #33 from dusan01/bugfixes/boom_box

Bugfixes/boom-box
This commit is contained in:
Lorenc Pekaj 2019-06-09 21:14:10 +10:00 committed by GitHub
commit 51ce94bd81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 29 deletions

View File

@ -32,6 +32,24 @@ hook OnPlayerDisconnect( playerid, reason )
return 1;
}
#if defined AC_INCLUDED
hook OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart )
#else
hook OnPlayerDeath( playerid, killerid, reason )
#endif
{
p_UsingBoombox{ playerid } = false;
Boombox_Destroy( playerid );
return 1;
}
hook OnPlayerJailed( playerid )
{
p_UsingBoombox{ playerid } = false;
Boombox_Destroy( playerid );
return 1;
}
hook OnPlayerEnterDynArea( playerid, areaid )
{
foreach ( new i : Player )
@ -68,42 +86,37 @@ hook OnPlayerLeaveDynArea( playerid, areaid )
return 1;
}
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
if ( ( dialogid == DIALOG_BOOMBOX_PLAY ) && response )
{
static
Float: X, Float: Y, Float: Z, Float: Angle;
if ( isnull( inputtext ) ) return SendError( playerid, "Looks like you didn't provide any URL.");
if ( GetPlayerPos( playerid, X, Y, Z ) && GetPlayerFacingAngle( playerid, Angle ) )
{
Boombox_Create( playerid, inputtext, X, Y, Z, Angle );
p_UsingBoombox{ playerid } = true;
SendServerMessage( playerid, "If the stream doesn't respond then it must be offline. Use "COL_GREY"/boombox stop"COL_WHITE" to stop the stream." );
}
}
return 1;
}
/* ** Commands ** */
CMD:boombox( playerid, params[ ] )
{
if ( ! GetPlayerBoombox( playerid ) )
return SendError( playerid, "You can buy Boombox at Supa Save or a 24/7 store." );
if ( IsPlayerInAnyVehicle(playerid) )
return SendError( playerid, "You cannot use Boombox inside of a vehicle.");
if ( strmatch( params, "play" ) )
if ( ! strcmp( params, "play", false, 3 ) )
{
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." );
static
Float: X, Float: Y, Float: Z, Float: Angle;
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" );
new szURL[ 128 ];
if ( sscanf( params[ 5 ], "s[128]", szURL ) ) return SendUsage( playerid, "/boombox play [URL]" );
else if ( IsPlayerUsingBoombox( playerid ) ) return SendError( playerid, "You are already using Boombox." );
else if ( IsPlayerNearBoombox( playerid ) ) return SendError( playerid, "You cannot be near another Boombox if you wish to create your own." );
else
{
if ( GetPlayerPos( playerid, X, Y, Z ) && GetPlayerFacingAngle( playerid, Angle ) )
{
Boombox_Create( playerid, szURL, X, Y, Z, Angle );
p_UsingBoombox{ playerid } = true;
SendServerMessage( playerid, "If the stream doesn't respond then it must be offline. Use "COL_GREY"/boombox stop"COL_WHITE" to stop the stream." );
}
else if ( strmatch( params, "stop" ) )
}
}
else if ( ! strcmp( params, "stop", false, 3 ) )
{
if ( ! IsPlayerUsingBoombox( playerid ) ) return SendError( playerid, "You are not using Boombox." );
@ -143,7 +156,7 @@ stock Boombox_Create( playerid, szURL[ ], Float: X, Float: Y, Float: Z, Float: A
g_boomboxData[ playerid ] [ E_Z ] = Z;
g_boomboxData[ playerid ] [ E_OBJECT ] = CreateDynamicObject( 2103, X, Y, Z - 0.92, 0, 0, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ), -1, Angle );
g_boomboxData[ playerid ] [ E_LABEL ] = CreateDynamic3DTextLabel( sprintf( "%s(%d)'s Boombox", ReturnPlayerName( playerid ), playerid ), COLOR_GOLD, X, Y, Z, 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, 20, .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;
}

View File

@ -70,7 +70,8 @@ static stock
{ "{8ADE47}Stephanie:"COL_WHITE" Contribute to our feature "COL_GREY"/crowdfunds"COL_WHITE"! Early supporters get benefits!" },
{ "{8ADE47}Stephanie:"COL_WHITE" You can buy premium player homes using "COL_GREY"/estate"COL_WHITE"!" },
{ "{8ADE47}Stephanie:"COL_WHITE" You can buy Irresistible Coins from players using "COL_GREY"/ic buy"COL_WHITE"!" },
{ "{8ADE47}Stephanie:"COL_WHITE" Buy a secure wallet to reduce the amount of money you drop when you die!" }
{ "{8ADE47}Stephanie:"COL_WHITE" Buy a secure wallet to reduce the amount of money you drop when you die!" },
{ "{8ADE47}Stephanie:"COL_WHITE" Buy a boombox and have a music party with your friends in area!" }
},
g_randomMessageTick = 0
;

View File

@ -5417,8 +5417,9 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
format( szLargeString, 750, "%s"COL_GREY"Weed Seeds:"COL_WHITE" %d\n"\
""COL_GREY"Fireworks:{FFFFFF} %d\n"\
""COL_GREY"Explosive Bullets:{FFFFFF} %d\n",
szLargeString, GetPlayerShopItemAmount( playerid, SHOP_ITEM_WEED_SEED ), p_Fireworks[ pID ], p_ExplosiveBullets[ pID ] );
""COL_GREY"Explosive Bullets:{FFFFFF} %d\n"\
""COL_GREY"Boombox:{FFFFFF} %s\n",
szLargeString, GetPlayerShopItemAmount( playerid, SHOP_ITEM_WEED_SEED ), p_Fireworks[ pID ], p_ExplosiveBullets[ pID ], p_Boombox{ pID } == true ? ( "Yes" ) : ( "No" ) );
ShowPlayerDialog( playerid, DIALOG_STATS_REDIRECT, DIALOG_STYLE_MSGBOX, "{FFFFFF}Item Statistics", szLargeString, "Okay", "Back" );
}