add model preview functionality ... makes previewing models before buying seamless

This commit is contained in:
Lorenc Pekaj 2018-10-09 10:04:42 +11:00
parent 066915d7fe
commit a4cf751cec
7 changed files with 219 additions and 294 deletions

View File

@ -32,5 +32,5 @@
- Called when player toggles movie mode
- `OnPlayerAccessEntrance( playerid, entranceid )`
- Called when a player accesses an entrance id
- `OnPlayerEndModelPreview( playerid, handleid )`
- Called when a player closes a model preview

View File

@ -25,6 +25,7 @@
#include "irresistible\cnr\ammunation.pwn"
#include "irresistible\cnr\irresistibleguard.pwn"
#include "irresistible\cnr\player_settings.pwn"
#include "irresistible\cnr\model_preview.pwn"
// static cnr features
#include "irresistible\cnr\static\_cnr_static.pwn"

View File

@ -23,6 +23,8 @@
#define BV_TYPE_BOATS ( 12 )
#define BV_TYPE_UNIQUE ( 13 )
#define PREVIEW_MODEL_VEHICLE ( 5 )
/* ** Variables ** */
enum E_BV_DATA
{
@ -364,108 +366,7 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
}
case 1:
{
new model = g_BuyableVehicleData[ GetPVarInt( playerid, "buying_vehicle" ) ] [ E_MODEL ];
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 );
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_vehicle", 1 );
return ShowPlayerModelPreview( playerid, PREVIEW_MODEL_VEHICLE, "Vehicle Preview", g_BuyableVehicleData[ GetPVarInt( playerid, "buying_vehicle" ) ] [ E_MODEL ] );
}
}
}
@ -482,6 +383,17 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
return 1;
}
hook OnPlayerEndModelPreview( playerid, handleid )
{
if ( handleid == PREVIEW_MODEL_VEHICLE )
{
SendServerMessage( playerid, "You have finished looking at the vehicle's preview." );
ShowPlayerDialog( playerid, DIALOG_VEHDEALER_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Vehicle Dealership", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
return Y_HOOKS_BREAK_RETURN_1;
}
return 1;
}
/* ** Functions ** */
stock ShowBuyableVehiclesList( playerid )
{

View File

@ -28,6 +28,8 @@
#define CATEGORY_MILITARY_ITEMS ( 11 )
#define CATEGORY_MISCELLANEOUS ( 12 )
#define PREVIEW_MODEL_COMPONENT ( 10 ) // some random number
enum E_CAR_MODS
{
E_CATEGORY, E_LIMIT, E_MODEL_ID,
@ -428,117 +430,14 @@ 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 ];
return ShowPlayerModelPreview( playerid, PREVIEW_MODEL_COMPONENT, "Component Preview", g_vehicleComponentsData[ i ] [ E_MODEL_ID ], .bgcolor = 0xFFFFFF70 );
}
}
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 );
}
}
}
@ -825,35 +724,13 @@ stock ShowVehicleComponentCategories( playerid )
return ShowPlayerDialog( playerid, DIALOG_COMPONENTS_CATEGORY, DIALOG_STYLE_LIST, "Pimp My Ride - Categories", szCategory, "Select", "Cancel" );
}
hook OnPlayerClickTextDraw(playerid, Text: clickedid)
hook OnPlayerEndModelPreview( playerid, handleid )
{
// Pressed ESC
if ( clickedid == Text: INVALID_TEXT_DRAW ) {
if ( GetPVarInt( playerid, "recently_previewed" ) < GetTickCount( ) && GetPVarInt( playerid, "viewing_component" ) )
return CancelComponentView( playerid, 0 );
if ( handleid == PREVIEW_MODEL_COMPONENT )
{
SendServerMessage( playerid, "You have finished looking at this vehicle modification preview." );
ShowPlayerDialog(playerid, DIALOG_COMPONENTS_RESPONSE, DIALOG_STYLE_LIST, ""COL_WHITE"Pimp My Ride", "Purchase Component\nPreview Component", "Select", "Back" );
return Y_HOOKS_BREAK_RETURN_1;
}
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" );
}

View File

@ -0,0 +1,191 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj
* Module: cnr\model_preview.pwn
* Purpose: handy module to preview object models
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Variables ** */
static stock
PlayerText: p_ModelPreviewTD [ MAX_PLAYERS ] [ 8 ],
Text: g_ModelPreviewBoxTD = Text: INVALID_TEXT_DRAW,
Text: p_ModelPreviewCloseTD = Text: INVALID_TEXT_DRAW
;
/* ** Hooks ** */
hook OnScriptInit( )
{
// init textdraws
for ( new i = 0; i < sizeof( p_ModelPreviewTD ); i ++ ) {
for ( new x = 0; x < sizeof( p_ModelPreviewTD[ ] ); x ++ ) {
p_ModelPreviewTD[ i ] [ x ] = PlayerText: INVALID_TEXT_DRAW;
}
}
// global ones
p_ModelPreviewCloseTD = TextDrawCreate( 191.000000, 319.000000, "Press your ESCAPE KEY to close the preview." );
TextDrawBackgroundColor( p_ModelPreviewCloseTD, 255 );
TextDrawFont( p_ModelPreviewCloseTD, 2 );
TextDrawLetterSize( p_ModelPreviewCloseTD, 0.259999, 1.399999 );
TextDrawColor( p_ModelPreviewCloseTD, -1 );
TextDrawSetOutline( p_ModelPreviewCloseTD, 1 );
TextDrawSetProportional( p_ModelPreviewCloseTD, 1 );
g_ModelPreviewBoxTD = TextDrawCreate( 500.000000, 150.000000, "__" );
TextDrawBackgroundColor( g_ModelPreviewBoxTD, 255 );
TextDrawLetterSize( g_ModelPreviewBoxTD, 0.500000, 17.000000 );
TextDrawColor( g_ModelPreviewBoxTD, -1 );
TextDrawUseBox( g_ModelPreviewBoxTD, 1 );
TextDrawBoxColor( g_ModelPreviewBoxTD, 112 );
TextDrawTextSize( g_ModelPreviewBoxTD, 139.000000, 50.000000 );
return 1;
}
hook OnPlayerConnect( playerid )
{
p_ModelPreviewTD[ playerid ] [ 0 ] = CreatePlayerTextDraw( playerid,289.000000, 230.000000, "preview 2" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], 112 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], 5 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], 0.500000, 4.400000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], -1 );
PlayerTextDrawUseBox( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], 1 );
PlayerTextDrawBoxColor( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], 0 );
PlayerTextDrawTextSize( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], 60.000000, 60.000000 );
PlayerTextDrawSetPreviewRot( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], -16.000000, 0.000000, 0.000000, 1.000000 );
// PlayerTextDrawSetSelectable( playerid, p_ModelPreviewTD[ playerid ] [ 0 ], 1 );
p_ModelPreviewTD[ playerid ] [ 1 ] = CreatePlayerTextDraw( playerid,358.000000, 160.000000, "preview 3" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], 112 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], 5 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], 0.500000, 4.400000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], -1 );
PlayerTextDrawUseBox( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], 1 );
PlayerTextDrawBoxColor( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], 0 );
PlayerTextDrawTextSize( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], 60.000000, 60.000000 );
PlayerTextDrawSetPreviewRot( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], -16.000000, 0.000000, 270.000000, 1.000000 );
// PlayerTextDrawSetSelectable( playerid, p_ModelPreviewTD[ playerid ] [ 1 ], 1 );
p_ModelPreviewTD[ playerid ] [ 2 ] = CreatePlayerTextDraw( playerid,358.000000, 230.000000, "preview 4" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], 112 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], 5 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], 0.500000, 4.400000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], -1 );
PlayerTextDrawUseBox( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], 1 );
PlayerTextDrawBoxColor( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], 0 );
PlayerTextDrawTextSize( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], 60.000000, 60.000000 );
PlayerTextDrawSetPreviewRot( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], -16.000000, 0.000000, 90.000000, 1.000000 );
// PlayerTextDrawSetSelectable( playerid, p_ModelPreviewTD[ playerid ] [ 2 ], 1 );
p_ModelPreviewTD[ playerid ] [ 3 ] = CreatePlayerTextDraw( playerid,428.000000, 160.000000, "preview 4" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 112 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 5 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 0.500000, 4.400000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], -1 );
PlayerTextDrawUseBox( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 1 );
PlayerTextDrawBoxColor( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 0 );
PlayerTextDrawTextSize( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 60.000000, 60.000000 );
PlayerTextDrawSetPreviewRot( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 270.000000, 0.000000, 0.000000, 1.000000 );
// PlayerTextDrawSetSelectable( playerid, p_ModelPreviewTD[ playerid ] [ 3 ], 1 );
p_ModelPreviewTD[ playerid ] [ 4 ] = CreatePlayerTextDraw( playerid,428.000000, 230.000000, "preview 5" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 112 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 5 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 0.500000, 4.400000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], -1 );
PlayerTextDrawUseBox( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 1 );
PlayerTextDrawBoxColor( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 0 );
PlayerTextDrawTextSize( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 60.000000, 60.000000 );
PlayerTextDrawSetPreviewRot( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 90.000000, 0.000000, 0.000000, 1.000000 );
// PlayerTextDrawSetSelectable( playerid, p_ModelPreviewTD[ playerid ] [ 4 ], 1 );
p_ModelPreviewTD[ playerid ] [ 5 ] = CreatePlayerTextDraw( playerid,150.000000, 160.000000, "big preview" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], 112 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], 5 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], 0.500000, 1.000000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], -1 );
PlayerTextDrawUseBox( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], 1 );
PlayerTextDrawBoxColor( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], 0 );
PlayerTextDrawTextSize( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], 130.000000, 130.000000 );
PlayerTextDrawSetPreviewRot( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], -16.000000, 0.000000, 45.000000, 1.000000 );
// PlayerTextDrawSetSelectable( playerid, p_ModelPreviewTD[ playerid ] [ 5 ], 1 );
p_ModelPreviewTD[ playerid ] [ 6 ] = CreatePlayerTextDraw( playerid,289.000000, 160.000000, "preview 6" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], 112 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], 5 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], 0.500000, 4.400000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], -1 );
PlayerTextDrawUseBox( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], 1 );
PlayerTextDrawBoxColor( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], 0 );
PlayerTextDrawTextSize( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], 60.000000, 60.000000 );
PlayerTextDrawSetPreviewRot( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], -16.000000, 0.000000, 180.000000, 1.000000 );
// PlayerTextDrawSetSelectable( playerid, p_ModelPreviewTD[ playerid ] [ 6 ], 1 );
p_ModelPreviewTD[ playerid ] [ 7 ] = CreatePlayerTextDraw( playerid, 130.000000, 135.000000, "Vehicle Preview" );
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ 7 ], 255 );
PlayerTextDrawFont( playerid, p_ModelPreviewTD[ playerid ] [ 7 ], 0 );
PlayerTextDrawLetterSize( playerid, p_ModelPreviewTD[ playerid ] [ 7 ], 0.720000, 2.000000 );
PlayerTextDrawColor( playerid, p_ModelPreviewTD[ playerid ] [ 7 ], -1 );
PlayerTextDrawSetOutline( playerid, p_ModelPreviewTD[ playerid ] [ 7 ], 1 );
PlayerTextDrawSetProportional( playerid, p_ModelPreviewTD[ playerid ] [ 7 ], 1 );
return 1;
}
hook OnPlayerClickTextDraw( playerid, Text: clickedid)
{
// Pressed ESC
if ( clickedid == Text: INVALID_TEXT_DRAW ) {
if ( GetPVarInt( playerid, "preview_model_delay" ) < GetTickCount( ) && GetPVarInt( playerid, "preview_model_handle" ) ) {
return HidePlayerModelPreview( playerid, 0 );
}
}
return 1;
}
/* ** Functions ** */
stock ShowPlayerModelPreview( playerid, handleid, title[ ], model, bgcolor = 0x00000070 )
{
PlayerTextDrawSetString( playerid, p_ModelPreviewTD[ playerid ] [ 7 ], title );
TextDrawShowForPlayer( playerid, g_ModelPreviewBoxTD );
TextDrawShowForPlayer( playerid, p_ModelPreviewCloseTD );
for ( new i = 0; i < sizeof( p_ModelPreviewTD[ ] ); i ++ ) {
if ( i != 7 ) {
PlayerTextDrawBackgroundColor( playerid, p_ModelPreviewTD[ playerid ] [ i ], bgcolor );
PlayerTextDrawSetPreviewModel( playerid, p_ModelPreviewTD[ playerid ] [ i ], model );
}
PlayerTextDrawShow( playerid, p_ModelPreviewTD[ playerid ] [ i ] );
}
p_inMovieMode{ playerid } = false;
cmd_moviemode( playerid, "" ); // Hide textdraws
SetPVarInt( playerid, "preview_model_handle", handleid );
SelectTextDraw( playerid, COLOR_RED );
return 1;
}
stock HidePlayerModelPreview( playerid, cancel = 1 )
{
if ( cancel ) {
CancelSelectTextDraw( playerid );
}
TextDrawHideForPlayer( playerid, g_ModelPreviewBoxTD );
TextDrawHideForPlayer( playerid, p_ModelPreviewCloseTD );
for( new i; i < sizeof( p_ModelPreviewTD [ ] ); i++ ) {
PlayerTextDrawHide( playerid, p_ModelPreviewTD[ playerid ] [ i ] );
}
cmd_moviemode( playerid, "" ); // Show textdraws
CallLocalFunction( "OnPlayerEndModelPreview", "dd", playerid, GetPVarInt( playerid, "preview_model_handle" ) );
SetPVarInt( playerid, "preview_model_delay", GetTickCount( ) + 100 );
DeletePVar( playerid, "preview_model_handle" );
return 1;
}

View File

@ -24,9 +24,6 @@ new
Text: g_AdminLogTD = Text: INVALID_TEXT_DRAW,
Text: g_AdminOnDutyTD = Text: INVALID_TEXT_DRAW,
Text: g_PassiveModeTD = Text: INVALID_TEXT_DRAW,
Text: g_VehiclePreviewBoxTD = Text: INVALID_TEXT_DRAW,
Text: g_VehiclePreviewTxtTD = Text: INVALID_TEXT_DRAW,
Text: p_VehiclePreviewCloseTD = Text: INVALID_TEXT_DRAW,
Text: g_DoubleXPTD = Text: INVALID_TEXT_DRAW,
Text: g_currentXPTD = Text: INVALID_TEXT_DRAW,
Text: g_CurrentRankTD = Text: INVALID_TEXT_DRAW,
@ -52,9 +49,7 @@ new
PlayerText: p_GPSInformation [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
PlayerText: p_AchievementTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
PlayerText: p_FireDistance1 [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
PlayerText: p_FireDistance2 [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
PlayerText: p_VehiclePreviewTD [ 7 ] = { PlayerText: INVALID_TEXT_DRAW, ... }
PlayerText: p_FireDistance2 [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }
;
/* ** Hooks ** */
@ -210,31 +205,6 @@ hook OnScriptInit( )
TextDrawSetOutline(g_DoubleXPTD, 1);
TextDrawSetProportional(g_DoubleXPTD, 1);
p_VehiclePreviewCloseTD = TextDrawCreate(191.000000, 319.000000, "Press your ESCAPE KEY to close the preview.");
TextDrawBackgroundColor(p_VehiclePreviewCloseTD, 255);
TextDrawFont(p_VehiclePreviewCloseTD, 2);
TextDrawLetterSize(p_VehiclePreviewCloseTD, 0.259999, 1.399999);
TextDrawColor(p_VehiclePreviewCloseTD, -1);
TextDrawSetOutline(p_VehiclePreviewCloseTD, 1);
TextDrawSetProportional(p_VehiclePreviewCloseTD, 1);
g_VehiclePreviewBoxTD = TextDrawCreate(500.000000, 150.000000, "__");
TextDrawBackgroundColor(g_VehiclePreviewBoxTD, 255);
TextDrawLetterSize(g_VehiclePreviewBoxTD, 0.500000, 17.000000);
TextDrawColor(g_VehiclePreviewBoxTD, -1);
TextDrawUseBox(g_VehiclePreviewBoxTD, 1);
TextDrawBoxColor(g_VehiclePreviewBoxTD, 112);
TextDrawTextSize(g_VehiclePreviewBoxTD, 139.000000, 50.000000);
g_VehiclePreviewTxtTD = TextDrawCreate(130.000000, 135.000000, "Vehicle Preview");
TextDrawBackgroundColor(g_VehiclePreviewTxtTD, 255);
TextDrawFont(g_VehiclePreviewTxtTD, 0);
TextDrawLetterSize(g_VehiclePreviewTxtTD, 0.720000, 2.000000);
TextDrawColor(g_VehiclePreviewTxtTD, -1);
TextDrawSetOutline(g_VehiclePreviewTxtTD, 1);
TextDrawSetProportional(g_VehiclePreviewTxtTD, 1);
TextDrawSetSelectable(g_VehiclePreviewTxtTD, 0);
g_AdminLogTD = TextDrawCreate(150.000000, 360.000000, "_");
TextDrawBackgroundColor(g_AdminLogTD, 255);
TextDrawFont(g_AdminLogTD, 1);

View File

@ -10667,14 +10667,8 @@ public OnPlayerObjectMoved(playerid, objectid)
return 1;
}
public OnPlayerClickTextDraw(playerid, Text: clickedid)
{
// Pressed ESC
if ( clickedid == Text: INVALID_TEXT_DRAW ) {
if ( GetPVarInt( playerid, "recently_previewed" ) < GetTickCount( ) && GetPVarInt( playerid, "viewing_vehicle" ) )
return CancelVehicleView( playerid, 0 );
}
return 1;
}
@ -10683,26 +10677,6 @@ public OnPlayerClickPlayerTextDraw(playerid, PlayerText: playertextid)
return 1;
}
stock CancelVehicleView( 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_vehicle" );
SetPVarInt( playerid, "recently_previewed", GetTickCount( ) + 100 );
SendServerMessage( playerid, "You have finished looking at the vehicle's preview." );
return ShowPlayerDialog( playerid, DIALOG_VEHDEALER_OPTIONS, DIALOG_STYLE_LIST, "{FFFFFF}Vehicle Dealership", "Purchase This Vehicle\nPreview Vehicle", "Select", "Back" );
}
public OnPlayerPickUpDynamicPickup( playerid, pickupid )
{
new