adds a option to preview a garage component before buying

This commit is contained in:
Steven Howard 2018-10-08 22:41:29 +01:00
parent 41b8c22061
commit e33c2c3efb
2 changed files with 276 additions and 108 deletions

View File

@ -126,55 +126,56 @@
#define DIALOG_COMPONENT_EDIT 1115
#define DIALOG_COMPONENT_EDIT_MENU 1116
#define DIALOG_COMPONENT_MENU 1117
#define DIALOG_DONATED_DIAGOLD 1118
#define DIALOG_LATEST_DONOR 1119
#define DIALOG_FINISHED_DONATING 1120
#define DIALOG_MODIFY_HITSOUND 1121
#define DIALOG_VIP_NOTE 1122
#define DIALOG_REGISTER_QUIT 1123
#define DIALOG_LOGIN_QUIT 1124
#define DIALOG_WEAPON_LOCKER 1125
#define DIALOG_WEAPON_LOCKER_BUY 1126
#define DIALOG_FEEDBACK 1127
#define DIALOG_IC_MARKET_2 1128
#define DIALOG_BUSINESS_CAR 1129
#define DIALOG_BUSINESS_HELI 1130
#define DIALOG_ACC_GUARD 1131
#define DIALOG_ACC_GUARD_EMAIL 1132
#define DIALOG_ACC_GUARD_MODE 1133
#define DIALOG_ACC_GUARD_CONFIRM 1134
#define DIALOG_ACC_GUARD_DEL_CANCEL 1135
#define DIALOG_RACE 1136
#define DIALOG_RACE_MODE 1137
#define DIALOG_RACE_FEE 1138
#define DIALOG_RACE_POS 1139
#define DIALOG_RACE_DISTANCE 1140
#define DIALOG_RACE_KICK 1141
#define DIALOG_RACE_DEST 1142
#define DIALOG_RACE_PRESELECT 1143
#define DIALOG_RACE_CUSTOM_DEST 1144
#define DIALOG_BUSINESS_SELL 1145
#define DIALOG_BUSINESS_NAME 1146
#define DIALOG_BUSINESS_ADD_MEMBER 1147
#define DIALOG_BUSINESS_MEMBERS 1148
#define DIALOG_BUSINESS_WITHDRAW 1149
#define DIALOG_BUSINESS_UPGRADES 1150
#define DIALOG_BUSINESSES 1151
#define DIALOG_CASINO_REWARDS 1152
#define DIALOG_AIRPORT 1153
#define DIALOG_CASINO_BAR 1154
#define DIALOG_ACC_EMAIL 1155
#define DIALOG_BUSINESS_SECURITY 1156
#define DIALOG_FACILITY_SPAWN 1157
#define DIALOG_IC_MARKET_3 1158
#define DIALOG_BUY_VIP 1159
#define DIALOG_TOYS_COLOR 1160
#define DIALOG_HIGHSCORES 1161
#define DIALOG_HIGHSCORES_BACK 1162
#define DIALOG_CROWDFUNDS 1163
#define DIALOG_CROWDFUND_OPTIONS 1164
#define DIALOG_CROWDFUND_INFO 1165
#define DIALOG_CROWDFUND_DONATE 1166
#define DIALOG_COMPONENTS_RESPONSE 1118
#define DIALOG_DONATED_DIAGOLD 1119
#define DIALOG_LATEST_DONOR 1120
#define DIALOG_FINISHED_DONATING 1121
#define DIALOG_MODIFY_HITSOUND 1123
#define DIALOG_VIP_NOTE 1124
#define DIALOG_REGISTER_QUIT 1125
#define DIALOG_LOGIN_QUIT 1126
#define DIALOG_WEAPON_LOCKER 1127
#define DIALOG_WEAPON_LOCKER_BUY 1128
#define DIALOG_FEEDBACK 1129
#define DIALOG_IC_MARKET_2 1130
#define DIALOG_BUSINESS_CAR 1131
#define DIALOG_BUSINESS_HELI 1132
#define DIALOG_ACC_GUARD 1133
#define DIALOG_ACC_GUARD_EMAIL 1134
#define DIALOG_ACC_GUARD_MODE 1135
#define DIALOG_ACC_GUARD_CONFIRM 1136
#define DIALOG_ACC_GUARD_DEL_CANCEL 1137
#define DIALOG_RACE 1138
#define DIALOG_RACE_MODE 1139
#define DIALOG_RACE_FEE 1140
#define DIALOG_RACE_POS 1141
#define DIALOG_RACE_DISTANCE 1142
#define DIALOG_RACE_KICK 1143
#define DIALOG_RACE_DEST 1144
#define DIALOG_RACE_PRESELECT 1145
#define DIALOG_RACE_CUSTOM_DEST 1146
#define DIALOG_BUSINESS_SELL 1147
#define DIALOG_BUSINESS_NAME 1148
#define DIALOG_BUSINESS_ADD_MEMBER 1149
#define DIALOG_BUSINESS_MEMBERS 1150
#define DIALOG_BUSINESS_WITHDRAW 1151
#define DIALOG_BUSINESS_UPGRADES 1152
#define DIALOG_BUSINESSES 1153
#define DIALOG_CASINO_REWARDS 1154
#define DIALOG_AIRPORT 1155
#define DIALOG_CASINO_BAR 1156
#define DIALOG_ACC_EMAIL 1157
#define DIALOG_BUSINESS_SECURITY 1158
#define DIALOG_FACILITY_SPAWN 1159
#define DIALOG_IC_MARKET_3 1160
#define DIALOG_BUY_VIP 1161
#define DIALOG_TOYS_COLOR 1162
#define DIALOG_HIGHSCORES 1163
#define DIALOG_HIGHSCORES_BACK 1164
#define DIALOG_CROWDFUNDS 1165
#define DIALOG_CROWDFUND_OPTIONS 1166
#define DIALOG_CROWDFUND_INFO 1167
#define DIALOG_CROWDFUND_DONATE 1168
/* ** Hooks ** */
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )

View File

@ -328,15 +328,33 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
return ShowPlayerVehicleComponents( playerid, listitem );
}
else if ( dialogid == DIALOG_COMPONENTS )
{
SetPVarInt( playerid, "components_item", listitem );
if ( response )
{
ShowPlayerDialog(playerid, DIALOG_COMPONENTS_RESPONSE, DIALOG_STYLE_LIST, ""COL_WHITE"Pimp My Ride", "Purchase Component\nPreview Component", "Select", "Back" );
}
else
{
return cmd_garage( playerid, "vehicle pimp" );
}
}
else if ( dialogid == DIALOG_COMPONENTS_RESPONSE )
{
new
iItem = GetPVarInt( playerid, "components_item" ),
iComponent = GetPVarInt( playerid, "components_category" );
if ( response )
{
switch( listitem )
{
case 0:
{
for( new i = 0, x = 0; i < sizeof( g_vehicleComponentsData ); i++ ) if ( g_vehicleComponentsData[ i ] [ E_CATEGORY ] == iComponent )
{
if ( listitem == x++ )
if ( iItem == x++ )
{
if ( !IsPlayerInAnyVehicle( playerid ) )
return SendError( playerid, "You need to be in a vehicle to use this command." );
@ -408,6 +426,122 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
}
}
}
case 1:
{
new model = -1;
for( new i = 0, x = 0; i < sizeof( g_vehicleComponentsData ); i++ ) if ( g_vehicleComponentsData[ i ] [ E_CATEGORY ] == iComponent )
{
if ( iItem == x++ )
{
model = g_vehicleComponentsData[ i ] [ E_MODEL_ID ];
}
}
p_VehiclePreviewTD[ 0 ] = CreatePlayerTextDraw(playerid,289.000000, 230.000000, "preview 2");
PlayerTextDrawBackgroundColor(playerid,p_VehiclePreviewTD[ 0 ], 112);
PlayerTextDrawFont(playerid,p_VehiclePreviewTD[ 0 ], 5);
PlayerTextDrawLetterSize(playerid,p_VehiclePreviewTD[ 0 ], 0.500000, 4.400000);
PlayerTextDrawColor(playerid,p_VehiclePreviewTD[ 0 ], -1);
PlayerTextDrawUseBox(playerid,p_VehiclePreviewTD[ 0 ], 1);
PlayerTextDrawBoxColor(playerid,p_VehiclePreviewTD[ 0 ], 0);
PlayerTextDrawTextSize(playerid,p_VehiclePreviewTD[ 0 ], 60.000000, 60.000000);
PlayerTextDrawSetPreviewModel(playerid, p_VehiclePreviewTD[ 0 ], model);
PlayerTextDrawSetPreviewRot(playerid, p_VehiclePreviewTD[ 0 ], -16.000000, 0.000000, 0.000000, 1.000000);
PlayerTextDrawSetSelectable(playerid,p_VehiclePreviewTD[ 0 ], 0);
p_VehiclePreviewTD[ 1 ] = CreatePlayerTextDraw(playerid,358.000000, 160.000000, "preview 3");
PlayerTextDrawBackgroundColor(playerid,p_VehiclePreviewTD[ 1 ], 112);
PlayerTextDrawFont(playerid,p_VehiclePreviewTD[ 1 ], 5);
PlayerTextDrawLetterSize(playerid,p_VehiclePreviewTD[ 1 ], 0.500000, 4.400000);
PlayerTextDrawColor(playerid,p_VehiclePreviewTD[ 1 ], -1);
PlayerTextDrawUseBox(playerid,p_VehiclePreviewTD[ 1 ], 1);
PlayerTextDrawBoxColor(playerid,p_VehiclePreviewTD[ 1 ], 0);
PlayerTextDrawTextSize(playerid,p_VehiclePreviewTD[ 1 ], 60.000000, 60.000000);
PlayerTextDrawSetPreviewModel(playerid, p_VehiclePreviewTD[ 1 ], model);
PlayerTextDrawSetPreviewRot(playerid, p_VehiclePreviewTD[ 1 ], -16.000000, 0.000000, 270.000000, 1.000000);
PlayerTextDrawSetSelectable(playerid,p_VehiclePreviewTD[ 1 ], 0);
p_VehiclePreviewTD[ 2 ] = CreatePlayerTextDraw(playerid,358.000000, 230.000000, "preview 4");
PlayerTextDrawBackgroundColor(playerid,p_VehiclePreviewTD[ 2 ], 112);
PlayerTextDrawFont(playerid,p_VehiclePreviewTD[ 2 ], 5);
PlayerTextDrawLetterSize(playerid,p_VehiclePreviewTD[ 2 ], 0.500000, 4.400000);
PlayerTextDrawColor(playerid,p_VehiclePreviewTD[ 2 ], -1);
PlayerTextDrawUseBox(playerid,p_VehiclePreviewTD[ 2 ], 1);
PlayerTextDrawBoxColor(playerid,p_VehiclePreviewTD[ 2 ], 0);
PlayerTextDrawTextSize(playerid,p_VehiclePreviewTD[ 2 ], 60.000000, 60.000000);
PlayerTextDrawSetPreviewModel(playerid, p_VehiclePreviewTD[ 2 ], model);
PlayerTextDrawSetPreviewRot(playerid, p_VehiclePreviewTD[ 2 ], -16.000000, 0.000000, 90.000000, 1.000000);
PlayerTextDrawSetSelectable(playerid,p_VehiclePreviewTD[ 2 ], 0);
p_VehiclePreviewTD[ 3 ] = CreatePlayerTextDraw(playerid,428.000000, 160.000000, "preview 4");
PlayerTextDrawBackgroundColor(playerid,p_VehiclePreviewTD[ 3 ], 112);
PlayerTextDrawFont(playerid,p_VehiclePreviewTD[ 3 ], 5);
PlayerTextDrawLetterSize(playerid,p_VehiclePreviewTD[ 3 ], 0.500000, 4.400000);
PlayerTextDrawColor(playerid,p_VehiclePreviewTD[ 3 ], -1);
PlayerTextDrawUseBox(playerid,p_VehiclePreviewTD[ 3 ], 1);
PlayerTextDrawBoxColor(playerid,p_VehiclePreviewTD[ 3 ], 0);
PlayerTextDrawTextSize(playerid,p_VehiclePreviewTD[ 3 ], 60.000000, 60.000000);
PlayerTextDrawSetPreviewModel(playerid, p_VehiclePreviewTD[ 3 ], model);
PlayerTextDrawSetPreviewRot(playerid, p_VehiclePreviewTD[ 3 ], 270.000000, 0.000000, 0.000000, 1.000000);
PlayerTextDrawSetSelectable(playerid,p_VehiclePreviewTD[ 3 ], 0);
p_VehiclePreviewTD[ 4 ] = CreatePlayerTextDraw(playerid,428.000000, 230.000000, "preview 5");
PlayerTextDrawBackgroundColor(playerid,p_VehiclePreviewTD[ 4 ], 112);
PlayerTextDrawFont(playerid,p_VehiclePreviewTD[ 4 ], 5);
PlayerTextDrawLetterSize(playerid,p_VehiclePreviewTD[ 4 ], 0.500000, 4.400000);
PlayerTextDrawColor(playerid,p_VehiclePreviewTD[ 4 ], -1);
PlayerTextDrawUseBox(playerid,p_VehiclePreviewTD[ 4 ], 1);
PlayerTextDrawBoxColor(playerid,p_VehiclePreviewTD[ 4 ], 0);
PlayerTextDrawTextSize(playerid,p_VehiclePreviewTD[ 4 ], 60.000000, 60.000000);
PlayerTextDrawSetPreviewModel(playerid, p_VehiclePreviewTD[ 4 ], model);
PlayerTextDrawSetPreviewRot(playerid, p_VehiclePreviewTD[ 4 ], 90.000000, 0.000000, 0.000000, 1.000000);
PlayerTextDrawSetSelectable(playerid,p_VehiclePreviewTD[ 4 ], 0);
p_VehiclePreviewTD[ 5 ] = CreatePlayerTextDraw(playerid,150.000000, 160.000000, "big preview");
PlayerTextDrawBackgroundColor(playerid,p_VehiclePreviewTD[ 5 ], 112);
PlayerTextDrawFont(playerid,p_VehiclePreviewTD[ 5 ], 5);
PlayerTextDrawLetterSize(playerid,p_VehiclePreviewTD[ 5 ], 0.500000, 1.000000);
PlayerTextDrawColor(playerid,p_VehiclePreviewTD[ 5 ], -1);
PlayerTextDrawUseBox(playerid,p_VehiclePreviewTD[ 5 ], 1);
PlayerTextDrawBoxColor(playerid,p_VehiclePreviewTD[ 5 ], 0);
PlayerTextDrawTextSize(playerid,p_VehiclePreviewTD[ 5 ], 130.000000, 130.000000);
PlayerTextDrawSetPreviewModel(playerid, p_VehiclePreviewTD[ 5 ], model);
PlayerTextDrawSetPreviewRot(playerid, p_VehiclePreviewTD[ 5 ], -16.000000, 0.000000, 45.000000, 1.000000);
PlayerTextDrawSetSelectable(playerid,p_VehiclePreviewTD[ 5 ], 0);
p_VehiclePreviewTD[ 6 ] = CreatePlayerTextDraw(playerid,289.000000, 160.000000, "preview 6");
PlayerTextDrawBackgroundColor(playerid,p_VehiclePreviewTD[ 6 ], 112);
PlayerTextDrawFont(playerid,p_VehiclePreviewTD[ 6 ], 5);
PlayerTextDrawLetterSize(playerid,p_VehiclePreviewTD[ 6 ], 0.500000, 4.400000);
PlayerTextDrawColor(playerid,p_VehiclePreviewTD[ 6 ], -1);
PlayerTextDrawUseBox(playerid,p_VehiclePreviewTD[ 6 ], 1);
PlayerTextDrawBoxColor(playerid,p_VehiclePreviewTD[ 6 ], 0);
PlayerTextDrawTextSize(playerid,p_VehiclePreviewTD[ 6 ], 60.000000, 60.000000);
PlayerTextDrawSetPreviewModel(playerid, p_VehiclePreviewTD[ 6 ], model);
PlayerTextDrawSetPreviewRot(playerid, p_VehiclePreviewTD[ 6 ], -16.000000, 0.000000, 180.000000, 1.000000);
PlayerTextDrawSetSelectable(playerid, p_VehiclePreviewTD[ 6 ], 0);
TextDrawShowForPlayer( playerid, g_VehiclePreviewBoxTD );
TextDrawSetString( g_VehiclePreviewTxtTD, "Component Preview" );
TextDrawShowForPlayer( playerid, g_VehiclePreviewTxtTD );
TextDrawShowForPlayer( playerid, p_VehiclePreviewCloseTD );
PlayerTextDrawShow( playerid, p_VehiclePreviewTD[ 0 ] );
PlayerTextDrawShow( playerid, p_VehiclePreviewTD[ 1 ] );
PlayerTextDrawShow( playerid, p_VehiclePreviewTD[ 2 ] );
PlayerTextDrawShow( playerid, p_VehiclePreviewTD[ 3 ] );
PlayerTextDrawShow( playerid, p_VehiclePreviewTD[ 4 ] );
PlayerTextDrawShow( playerid, p_VehiclePreviewTD[ 5 ] );
PlayerTextDrawShow( playerid, p_VehiclePreviewTD[ 6 ] );
p_inMovieMode{ playerid } = false;
cmd_moviemode( playerid, "" ); // Hide textdraws :3
SelectTextDraw( playerid, COLOR_RED );
SetPVarInt( playerid, "viewing_component", 1 );
}
}
}
else
{
return cmd_garage( playerid, "vehicle pimp" );
@ -690,3 +824,36 @@ stock ShowVehicleComponentCategories( playerid )
}
return ShowPlayerDialog( playerid, DIALOG_COMPONENTS_CATEGORY, DIALOG_STYLE_LIST, "Pimp My Ride - Categories", szCategory, "Select", "Cancel" );
}
hook OnPlayerClickTextDraw(playerid, Text: clickedid)
{
// Pressed ESC
if ( clickedid == Text: INVALID_TEXT_DRAW ) {
if ( GetPVarInt( playerid, "recently_previewed" ) < GetTickCount( ) && GetPVarInt( playerid, "viewing_component" ) )
return CancelComponentView( playerid, 0 );
}
return 1;
}
stock CancelComponentView( playerid, cancel = 1 )
{
if ( cancel )
CancelSelectTextDraw( playerid );
TextDrawHideForPlayer( playerid, g_VehiclePreviewBoxTD );
TextDrawHideForPlayer( playerid, g_VehiclePreviewTxtTD );
TextDrawHideForPlayer( playerid, p_VehiclePreviewCloseTD );
for( new i; i < sizeof p_VehiclePreviewTD; i++ )
PlayerTextDrawDestroy( playerid, p_VehiclePreviewTD[ i ] );
cmd_moviemode( playerid, "" ); // Show textdraws :3
DeletePVar( playerid, "viewing_component" );
SetPVarInt( playerid, "recently_previewed", GetTickCount( ) + 100 );
SendServerMessage( playerid, "You have finished looking at this vehicle modification preview." );
return ShowPlayerDialog(playerid, DIALOG_COMPONENTS_RESPONSE, DIALOG_STYLE_LIST, ""COL_WHITE"Pimp My Ride", "Purchase Component\nPreview Component", "Select", "Back" );
}