Boombox [WIP]
This commit is contained in:
parent
7fe5a21de8
commit
46e43f24f8
@ -213,6 +213,7 @@
|
||||
#define DIALOG_VIP_MAIN 1204
|
||||
#define DIALOG_XPMARKET_SELL 1205
|
||||
#define DIALOG_BUY_VIP_MAIN 1206
|
||||
#define DIALOG_BOOMBOX_PLAY 1207
|
||||
|
||||
/* ** Hooks ** */
|
||||
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "irresistible\cnr\features\shamal.pwn"
|
||||
#include "irresistible\cnr\features\billboards.pwn"
|
||||
#include "irresistible\cnr\features\trolley_car.pwn"
|
||||
#include "irresistible\cnr\features\boom_box.pwn"
|
||||
|
||||
// pool
|
||||
#include "irresistible\cnr\features\pool.pwn"
|
||||
|
142
gamemodes/irresistible/cnr/features/boom_box.pwn
Normal file
142
gamemodes/irresistible/cnr/features/boom_box.pwn
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Irresistible Gaming 2018
|
||||
* Developed by Night
|
||||
* Module: cnr\features\boom_box.pwn
|
||||
* Purpose: boombox related feature
|
||||
*/
|
||||
|
||||
/* ** Includes ** */
|
||||
#include < YSI\y_hooks >
|
||||
|
||||
/* ** Definitions ** */
|
||||
#define DEFAULT_BOOMBOX_RANGE ( 50.0 )
|
||||
|
||||
/* ** Variables ** */
|
||||
enum E_BOOMBOX_DATA
|
||||
{
|
||||
E_OBJECT, Text3D: E_LABEL, E_MUSIC_AREA,
|
||||
E_URL[ 128 ],
|
||||
Float: E_X, Float: E_Y, Float: E_Z
|
||||
};
|
||||
|
||||
static stock
|
||||
g_boomboxData [ MAX_PLAYERS ] [ E_BOOMBOX_DATA ]
|
||||
;
|
||||
|
||||
/* ** Hooks ** */
|
||||
hook OnPlayerDisconnect( playerid, reason )
|
||||
{
|
||||
p_UsingBoombox{ playerid } = false;
|
||||
p_Boombox{ playerid } = false;
|
||||
Boombox_Destroy( playerid );
|
||||
return 1;
|
||||
}
|
||||
|
||||
hook OnPlayerEnterDynArea( playerid, areaid )
|
||||
{
|
||||
foreach ( new i : Player )
|
||||
{
|
||||
if ( IsValidDynamicArea( g_boomboxData[ i ][ E_MUSIC_AREA ] ) && ! IsPlayerUsingBoombox( i ) )
|
||||
{
|
||||
if ( areaid == g_boomboxData[ i ][ E_MUSIC_AREA ] )
|
||||
{
|
||||
// start the music
|
||||
PlayAudioStreamForPlayer( playerid, g_boomboxData[ playerid ][ E_URL ], g_boomboxData[ playerid ][ E_X ], g_boomboxData[ playerid ][ E_Y ], g_boomboxData[ playerid ][ E_Z ] );
|
||||
SendServerMessage( playerid, "You are now listening to a nearby boombox!" );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
hook OnPlayerLeaveDynArea( playerid, areaid )
|
||||
{
|
||||
foreach ( new i : Player )
|
||||
{
|
||||
if ( IsValidDynamicArea( g_boomboxData[ i ][ E_MUSIC_AREA ] ) )
|
||||
{
|
||||
if ( areaid == g_boomboxData[ i ][ E_MUSIC_AREA ] )
|
||||
{
|
||||
// stop the music
|
||||
StopAudioStreamForPlayer( playerid );
|
||||
SendServerMessage( playerid, "You stopped listening to a nearby boombox!" );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ( 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." );
|
||||
}
|
||||
}
|
||||
|
||||
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 ( strmatch( params, "play" ) )
|
||||
{
|
||||
if ( IsPlayerUsingBoombox( playerid ) ) return SendError( playerid, "You are already using Boombox." );
|
||||
|
||||
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" );
|
||||
}
|
||||
else if ( strmatch( params, "stop" ) )
|
||||
{
|
||||
if ( ! IsPlayerUsingBoombox( playerid ) ) return SendError( playerid, "You are not using Boombox." );
|
||||
|
||||
StopAudioStreamForPlayer( playerid );
|
||||
Boombox_Destroy( playerid );
|
||||
SendServerMessage( playerid, "You have removed your Boombox.");
|
||||
p_UsingBoombox{ playerid } = false;
|
||||
}
|
||||
else SendUsage( playerid, "/boombox [PLAY/STOP]" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ** Functions ** */
|
||||
stock IsPlayerUsingBoombox( playerid ) return p_UsingBoombox{ playerid };
|
||||
|
||||
stock GetPlayerBoombox( playerid ) return p_Boombox{ playerid };
|
||||
|
||||
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';
|
||||
|
||||
DestroyDynamicObject( g_boomboxData[ playerid ] [ E_OBJECT ] );
|
||||
DestroyDynamic3DTextLabel( g_boomboxData[ playerid ] [ E_LABEL ] );
|
||||
DestroyDynamicArea( g_boomboxData[ playerid ] [ E_MUSIC_AREA ] );
|
||||
return 1;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
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.3, 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;
|
||||
}
|
@ -24,7 +24,8 @@ enum E_SHOP_ITEMS
|
||||
SHOP_ITEM_DRILL,
|
||||
SHOP_ITEM_METAL_MELTER,
|
||||
SHOP_ITEM_WEED_SEED,
|
||||
SHOP_ITEM_FIREWORKS
|
||||
SHOP_ITEM_FIREWORKS,
|
||||
SHOP_ITEM_BOOMBOX
|
||||
}
|
||||
|
||||
enum E_SHOP_DATA
|
||||
@ -49,7 +50,8 @@ new
|
||||
{ SHOP_ITEM_MONEY_CASE, false, "Money Case", "Increases robbing amount", 1, 4500 }, // [1250]
|
||||
{ SHOP_ITEM_DRILL, true , "Thermal Drill", "Halves safe cracking time", 1, 5000 },
|
||||
{ SHOP_ITEM_METAL_MELTER, true , "Metal Melter", "/breakout", 4, 7500 },
|
||||
{ SHOP_ITEM_FIREWORKS, true , "Firework", "/fireworks", 0, 50000 }
|
||||
{ SHOP_ITEM_FIREWORKS, true , "Firework", "/fireworks", 0, 50000 },
|
||||
{ SHOP_ITEM_BOOMBOX, false, "Boombox", "/boombox", 1, 15000 }
|
||||
},
|
||||
g_playerShopItems [ MAX_PLAYERS ] [ E_SHOP_ITEMS ] // gradually move to this
|
||||
;
|
||||
@ -102,6 +104,11 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
{
|
||||
GivePlayerFireworks( playerid, 1 );
|
||||
}
|
||||
case SHOP_ITEM_BOOMBOX:
|
||||
{
|
||||
if ( p_Boombox{ playerid } == true ) return SendError( playerid, "You have already purchased this item." );
|
||||
p_Boombox{ playerid } = true;
|
||||
}
|
||||
}
|
||||
GivePlayerCash( playerid, -( g_shopItemData[ listitem ] [ E_PRICE ] ) );
|
||||
SendServerMessage( playerid, "You have bought a "COL_GREY"%s"COL_WHITE" for "COL_GOLD"%s"COL_WHITE".", g_shopItemData[ listitem ] [ E_NAME ], cash_format( g_shopItemData[ listitem ] [ E_PRICE ] ) );
|
||||
@ -191,6 +198,7 @@ stock GetShopItemAmount( playerid, id )
|
||||
case SHOP_ITEM_METAL_MELTER: return p_MetalMelter[ playerid ];
|
||||
case SHOP_ITEM_WEED_SEED: return g_playerShopItems[ playerid ] [ SHOP_ITEM_WEED_SEED ];
|
||||
case SHOP_ITEM_FIREWORKS: return p_Fireworks[ playerid ];
|
||||
case SHOP_ITEM_BOOMBOX: return p_Boombox[ playerid ];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -213,6 +221,7 @@ stock SetPlayerShopItemAmount( playerid, id, value )
|
||||
case SHOP_ITEM_METAL_MELTER: p_MetalMelter[ playerid ] = value;
|
||||
case SHOP_ITEM_WEED_SEED: g_playerShopItems[ playerid ] [ SHOP_ITEM_WEED_SEED ] = value;
|
||||
case SHOP_ITEM_FIREWORKS: p_Fireworks[ playerid ] = value;
|
||||
case SHOP_ITEM_BOOMBOX: p_Boombox[ playerid ] = !!value;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -209,7 +209,9 @@ new
|
||||
p_TazingImmunity [ MAX_PLAYERS ],
|
||||
p_PlayerAltBind [ MAX_PLAYERS ] = { -1, ... },
|
||||
p_PlayerAltBindTick [ MAX_PLAYERS ],
|
||||
p_AimedAtPolice [ MAX_PLAYERS ]
|
||||
p_AimedAtPolice [ MAX_PLAYERS ],
|
||||
bool: p_UsingBoombox [ MAX_PLAYERS char ],
|
||||
bool: p_Boombox [ MAX_PLAYERS char ]
|
||||
;
|
||||
|
||||
/* ** Getters And Setters** */
|
||||
|
Loading…
Reference in New Issue
Block a user