Moved boombox to command

This commit is contained in:
Dusan 2019-06-08 00:31:50 +02:00
parent d4b6900fa4
commit 59cd4dd19e
2 changed files with 20 additions and 26 deletions

View File

@ -213,7 +213,6 @@
#define DIALOG_VIP_MAIN 1204 #define DIALOG_VIP_MAIN 1204
#define DIALOG_XPMARKET_SELL 1205 #define DIALOG_XPMARKET_SELL 1205
#define DIALOG_BUY_VIP_MAIN 1206 #define DIALOG_BUY_VIP_MAIN 1206
#define DIALOG_BOOMBOX_PLAY 1207
/* ** Hooks ** */ /* ** Hooks ** */
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )

View File

@ -86,42 +86,37 @@ hook OnPlayerLeaveDynArea( playerid, areaid )
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 ** */ /* ** Commands ** */
CMD:boombox( playerid, params[ ] ) CMD:boombox( playerid, params[ ] )
{ {
if ( ! GetPlayerBoombox( playerid ) ) if ( ! GetPlayerBoombox( playerid ) )
return SendError( playerid, "You can buy Boombox at Supa Save or a 24/7 store." ); return SendError( playerid, "You can buy Boombox at Supa Save or a 24/7 store." );
if ( IsPlayerInAnyVehicle(playerid) ) if ( IsPlayerInAnyVehicle(playerid) )
return SendError( playerid, "You cannot use Boombox inside of a vehicle."); 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." ); static
if ( IsPlayerNearBoombox( playerid ) ) return SendError( playerid, "You cannot be near another Boombox if you wish to create your own." ); 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." ); if ( ! IsPlayerUsingBoombox( playerid ) ) return SendError( playerid, "You are not using Boombox." );