commit
cd1b756235
@ -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"
|
||||
|
159
gamemodes/irresistible/cnr/features/boom_box.pwn
Normal file
159
gamemodes/irresistible/cnr/features/boom_box.pwn
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* 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 ] ) )
|
||||
{
|
||||
if ( areaid == g_boomboxData[ i ] [ E_MUSIC_AREA ] )
|
||||
{
|
||||
// start the music
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ( 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 ( 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" );
|
||||
}
|
||||
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_X ] = X;
|
||||
g_boomboxData[ playerid ] [ E_Y ] = Y;
|
||||
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_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;
|
||||
}
|
@ -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** */
|
||||
|
@ -727,19 +727,19 @@ public OnPlayerSpawn( playerid )
|
||||
SpawnToPaintball( playerid, p_PaintBallArena{ playerid } );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#if defined __cloudy_event_system
|
||||
else if ( IsPlayerInEvent( playerid ) )
|
||||
{
|
||||
if( ! EventSettingAllow( 0 ) && g_eventData[ EV_STARTED ] )
|
||||
{
|
||||
if( ! EventSettingAllow( 0 ) && g_eventData[ EV_STARTED ] )
|
||||
{
|
||||
SetPlayerInEvent( playerid ); // respawns player in event.
|
||||
return 1;
|
||||
}
|
||||
else RemovePlayerFromEvent( playerid, true ); // changes the InEvent variable to false.
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if ( p_Class[ playerid ] == CLASS_CIVILIAN )
|
||||
{
|
||||
if ( !p_JobSet{ playerid } )
|
||||
@ -850,7 +850,7 @@ public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float: fX, Float:
|
||||
#else
|
||||
if ( p_Class[ playerid ] == CLASS_POLICE && p_WantedLevel[ hitid ] > 2 )
|
||||
#endif
|
||||
{
|
||||
{
|
||||
p_QuitToAvoidTimestamp[ hitid ] = g_iTime + 3;
|
||||
}
|
||||
|
||||
@ -5295,6 +5295,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
strcat( szCMDS, ""COL_GREY"/labelinfo{FFFFFF} - Displays your label text with the 32 character limit.\n"\
|
||||
""COL_GREY"/radio{FFFFFF} - Shows the list of radio stations you can listen to.\n"\
|
||||
""COL_GREY"/stopradio{FFFFFF} - Stops the radio from playing.\n"\
|
||||
""COL_GREY"/boombox{FFFFFF} - Places a boombox at your position which plays music in small area.\n"\
|
||||
""COL_GREY"/moviemode{FFFFFF} - Toggles movie mode so you can record without all the text on the screen." );
|
||||
ShowPlayerDialog( playerid, DIALOG_CMDS_REDIRECT, DIALOG_STYLE_MSGBOX, "{FFFFFF}Miscellaneous Commands", szCMDS, "Okay", "Back" );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user