add toy model preview

This commit is contained in:
Lorenc Pekaj 2018-10-09 10:33:04 +11:00
parent b755e6ffa1
commit 8c2dd222d2
3 changed files with 70 additions and 29 deletions

View File

@ -47,7 +47,7 @@
#define DIALOG_GARAGE_INTERIORS 1035 #define DIALOG_GARAGE_INTERIORS 1035
#define DIALOG_GARAGE_INT_CONFIRM 1036 #define DIALOG_GARAGE_INT_CONFIRM 1036
#define DIALOG_GANG_LIST 1037 #define DIALOG_GANG_LIST 1037
//#define DIALOG_LUMBERJACK 1038 #define DIALOG_TOY_PREVIEW 1038
#define DIALOG_FIGHTSTYLE 1039 #define DIALOG_FIGHTSTYLE 1039
#define DIALOG_TOYS_MAIN 1040 #define DIALOG_TOYS_MAIN 1040
#define DIALOG_TOYS 1041 #define DIALOG_TOYS 1041

View File

@ -25,6 +25,8 @@
#define CATEGORY_MISC ( 10 ) #define CATEGORY_MISC ( 10 )
#define CATEGORY_VIP ( 11 ) #define CATEGORY_VIP ( 11 )
#define MODEL_PREVIEW_TOY ( 15 )
/* ** Variables ** */ /* ** Variables ** */
enum E_ATTACHED_DATA enum E_ATTACHED_DATA
{ {
@ -381,6 +383,30 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
if ( g_ToyData[ id ] [ E_CATEGORY ] == p_ToyCategorySelected{ playerid } ) if ( g_ToyData[ id ] [ E_CATEGORY ] == p_ToyCategorySelected{ playerid } )
{ {
if ( x == listitem ) if ( x == listitem )
{
SetPVarInt( playerid, "toy_item", id );
ShowPlayerDialog( playerid, DIALOG_TOY_PREVIEW, DIALOG_STYLE_TABLIST, "{FFFFFF}Purchase Toys", sprintf( "Purchase Toy\t"COL_GOLD"%s\nPreview Toy\t ", cash_format( g_ToyData[ id ] [ E_PRICE ] ) ), "Select", "Back" );
break;
}
x ++;
}
}
}
else if ( dialogid == DIALOG_TOY_PREVIEW )
{
if ( ! response )
return showToyCategoryItems( playerid, p_ToyCategorySelected{ playerid }, .pawnshop = true );
new
id = GetPVarInt( playerid, "toy_item" );
if ( ! ( 0 <= id < sizeof( g_ToyData ) ) )
return SendError( playerid, "An error has occurred, please try again." );
switch ( listitem )
{
// bought
case 0:
{ {
if ( p_ToyUnlocked[ playerid ] { g_ToyData[ id ] [ E_ID ] } ) if ( p_ToyUnlocked[ playerid ] { g_ToyData[ id ] [ E_ID ] } )
{ {
@ -398,9 +424,12 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
GivePlayerCash( playerid, -g_ToyData[ id ] [ E_PRICE ] ); GivePlayerCash( playerid, -g_ToyData[ id ] [ E_PRICE ] );
showToyCategoryItems( playerid, p_ToyCategorySelected{ playerid }, .pawnshop = true ); showToyCategoryItems( playerid, p_ToyCategorySelected{ playerid }, .pawnshop = true );
SendServerMessage( playerid, "You have bought a "COL_GREY"%s"COL_WHITE" for "COL_GOLD"%s"COL_WHITE".", g_ToyData[ id ] [ E_NAME ], cash_format( g_ToyData[ id ] [ E_PRICE ] ) ); SendServerMessage( playerid, "You have bought a "COL_GREY"%s"COL_WHITE" for "COL_GOLD"%s"COL_WHITE".", g_ToyData[ id ] [ E_NAME ], cash_format( g_ToyData[ id ] [ E_PRICE ] ) );
break;
} }
x ++;
// preview
case 1:
{
return ShowPlayerModelPreview( playerid, MODEL_PREVIEW_TOY, "Toy Preview", g_ToyData[ id ] [ E_MODEL ] );
} }
} }
} }
@ -569,6 +598,19 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
return 1; return 1;
} }
hook OnPlayerEndModelPreview( playerid, handleid )
{
if ( handleid == MODEL_PREVIEW_TOY )
{
new
id = GetPVarInt( playerid, "toy_item" );
SendServerMessage( playerid, "You have finished looking at this toy preview." );
return ShowPlayerDialog( playerid, DIALOG_TOY_PREVIEW, DIALOG_STYLE_TABLIST, "{FFFFFF}Purchase Toys", sprintf( "Purchase Toy\t"COL_GOLD"%s\nPreview Toy\t ", cash_format( g_ToyData[ id ] [ E_PRICE ] ) ), "Select", "Back" ), Y_HOOKS_BREAK_RETURN_1;
}
return 1;
}
/* ** Commands ** */ /* ** Commands ** */
CMD:toys( playerid, params[ ] ) CMD:toys( playerid, params[ ] )
{ {

View File

@ -6840,18 +6840,17 @@ CMD:job( playerid, params[ ] )
CMD:jaillist( playerid, params[ ] ) CMD:jaillist( playerid, params[ ] )
{ {
new count = 0; szBigString[ 0 ] = '\0';
SendClientMessage( playerid, COLOR_GOLD, ".: Jail List :." );
foreach(new i : Player) foreach( new i : Player ) if ( IsPlayerJailed( i ) ) {
{ format( szBigString, sizeof( szBigString ), "%s%s%s(%d)\t%d seconds", szBigString, p_AdminJailed{ i } ? ( COL_RED ) : ( COL_WHITE ), ReturnPlayerName( i ), i, p_JailTime[ i ] );
if ( p_Jailed{ i } == true )
{
SendClientMessageFormatted( playerid, -1, "%s (%d seconds)", ReturnPlayerName( i ), p_JailTime[ i ] );
count++;
} }
if ( szBigString[ 0 ] == '\0' ) {
return SendError( playerid, "There are no players in jail." );
} else {
return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_TABLIST, ""COL_WHITE"Jail List", szBigString, "Close", "" );
} }
if ( count == 0 ) SendClientMessage( playerid, -1, "There are no players in jail." );
return 1;
} }
CMD:lastlogged( playerid, params[ ] ) CMD:lastlogged( playerid, params[ ] )