adds a confirmation dialog before selling a business

This commit is contained in:
Steven Howard 2018-10-09 10:09:15 +01:00
parent 9c48bbeebc
commit 2d1094574c
2 changed files with 26 additions and 12 deletions

View File

@ -209,7 +209,8 @@
#define DIALOG_IC_BUY 1199 #define DIALOG_IC_BUY 1199
#define DIALOG_COMPONENTS_SELL 1200 #define DIALOG_COMPONENTS_SELL 1200
#define DIALOG_HOUSE_SELL 1201 #define DIALOG_HOUSE_SELL 1201
#define DIALOG_BUSINESS_SELL_CONFIRM 1202
/* ** Hooks ** */ /* ** Hooks ** */
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{ {

View File

@ -370,17 +370,9 @@ CMD:business( playerid, params[ ] )
new new
iCashMoney = floatround( g_businessData[ iBusiness ] [ E_COST ] / 2 ); iCashMoney = floatround( g_businessData[ iBusiness ] [ E_COST ] / 2 );
p_OwnedBusinesses[ playerid ] --; SetPVarInt( playerid, "biz_sell_id", iBusiness );
g_businessData[ iBusiness ] [ E_OWNER_ID ] = 0;
ResetBusiness( iBusiness, .hard_reset = true ); ShowPlayerDialog( playerid, DIALOG_BUSINESS_SELL_CONFIRM, DIALOG_STYLE_MSGBOX, ""COL_WHITE"Sell Business", sprintf( ""COL_WHITE"Are you sure you want to sell this business for "COL_GOLD"%s"COL_WHITE"?", cash_format( iCashMoney ) ), "Sell", "Cancel" );
StopBusinessExportMission( iBusiness );
UpdateBusinessData( iBusiness );
UpdateBusinessTitle( iBusiness ); // No point querying (add on resale)
GivePlayerCash( playerid, iCashMoney );
SetPlayerPosEx( playerid, g_businessData[ iBusiness ] [ E_X ], g_businessData[ iBusiness ] [ E_Y ], g_businessData[ iBusiness ] [ E_Z ], 0 ), SetPlayerVirtualWorld( playerid, 0 );
SendServerMessage( playerid, "You have successfully sold your business for "COL_GOLD"%s"COL_WHITE".", cash_format( iCashMoney ) );
} }
return 1; return 1;
} }
@ -592,7 +584,28 @@ function Timer_DestroyObject( objectid )
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{ {
if ( dialogid == DIALOG_BUSINESSES ) if ( dialogid == DIALOG_BUSINESS_SELL_CONFIRM && response )
{
new
iBusiness = GetPVarInt( playerid, "biz_sell_id" ),
iCashMoney = floatround( g_businessData[ iBusiness ] [ E_COST ] / 2 );
p_OwnedBusinesses[ playerid ] --;
g_businessData[ iBusiness ] [ E_OWNER_ID ] = 0;
ResetBusiness( iBusiness, .hard_reset = true );
StopBusinessExportMission( iBusiness );
UpdateBusinessData( iBusiness );
UpdateBusinessTitle( iBusiness ); // No point querying (add on resale)
GivePlayerCash( playerid, iCashMoney );
SetPlayerPosEx( playerid, g_businessData[ iBusiness ] [ E_X ], g_businessData[ iBusiness ] [ E_Y ], g_businessData[ iBusiness ] [ E_Z ], 0 ), SetPlayerVirtualWorld( playerid, 0 );
SendServerMessage( playerid, "You have successfully sold your business for "COL_GOLD"%s"COL_WHITE".", cash_format( iCashMoney ) );
DeletePVar( playerid, "biz_sell_id" );
return 1;
}
else if ( dialogid == DIALOG_BUSINESSES )
{ {
if ( ! response ) if ( ! response )
return ShowPlayerSpawnMenu( playerid ); return ShowPlayerSpawnMenu( playerid );