From 50bd48b688fd7518cbd64e2e6f6e67202a37ddc6 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 23 Dec 2018 11:14:28 +1100 Subject: [PATCH] moviemode in its own module --- .../irresistible/cnr/features/_features.pwn | 1 + .../irresistible/cnr/features/animations.pwn | 2 +- .../irresistible/cnr/features/movie_mode.pwn | 111 ++++++++++++++++++ gamemodes/irresistible/cnr/model_preview.pwn | 7 +- gamemodes/irresistible/cnr/player.pwn | 3 - gamemodes/irresistible/cnr/textdraws.pwn | 61 ---------- gamemodes/sf-cnr.pwn | 70 +++++------ 7 files changed, 144 insertions(+), 111 deletions(-) create mode 100644 gamemodes/irresistible/cnr/features/movie_mode.pwn diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 1e629a7..0613e94 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -24,6 +24,7 @@ // #include "irresistible\cnr\features\eastereggs.pwn" // other +#include "irresistible\cnr\features\movie_mode.pwn" #include "irresistible\cnr\features\passive_mode.pwn" #include "irresistible\cnr\features\server_rules.pwn" #include "irresistible\cnr\features\toys.pwn" diff --git a/gamemodes/irresistible/cnr/features/animations.pwn b/gamemodes/irresistible/cnr/features/animations.pwn index 8bb8dda..b8d4151 100644 --- a/gamemodes/irresistible/cnr/features/animations.pwn +++ b/gamemodes/irresistible/cnr/features/animations.pwn @@ -375,7 +375,7 @@ stock CreateLoopingAnimation( playerid, animlib[ ], animname[ ], Float:Speed, lo if ( looping ) // Animations that must be played once. { p_InAnimation{ playerid } = true; - if ( !p_inMovieMode{ playerid } ) TextDrawShowForPlayer( playerid, g_AnimationTD ); + if ( ! IsPlayerMovieMode( playerid ) ) TextDrawShowForPlayer( playerid, g_AnimationTD ); } } return 1; diff --git a/gamemodes/irresistible/cnr/features/movie_mode.pwn b/gamemodes/irresistible/cnr/features/movie_mode.pwn new file mode 100644 index 0000000..08b8a72 --- /dev/null +++ b/gamemodes/irresistible/cnr/features/movie_mode.pwn @@ -0,0 +1,111 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc + * Module: cnr\features\movie_mode.pwn + * Purpose: movie mode feature that hides textdraws for the purpose of a movie + */ + +/* ** Includes ** */ +#include < YSI\y_hooks > + +/* ** Variables ** */ +static stock Text: g_MovieModeTD [ 6 ] = { Text: INVALID_TEXT_DRAW, ... }; +static stock bool: p_inMovieMode [ MAX_PLAYERS char ]; + +/* ** Hooks ** */ +hook OnScriptInit( ) +{ + g_MovieModeTD[ 0 ] = TextDrawCreate(507.000000, 386.000000, "_"); + TextDrawBackgroundColor(g_MovieModeTD[ 0 ], 255); + TextDrawFont(g_MovieModeTD[ 0 ], 1); + TextDrawLetterSize(g_MovieModeTD[ 0 ], 0.500000, 4.799999); + TextDrawColor(g_MovieModeTD[ 0 ], -1); + TextDrawSetOutline(g_MovieModeTD[ 0 ], 0); + TextDrawSetProportional(g_MovieModeTD[ 0 ], 1); + TextDrawSetShadow(g_MovieModeTD[ 0 ], 1); + TextDrawUseBox(g_MovieModeTD[ 0 ], 1); + TextDrawBoxColor(g_MovieModeTD[ 0 ], 80); + TextDrawTextSize(g_MovieModeTD[ 0 ], 620.000000, 0.000000); + + g_MovieModeTD[ 1 ] = TextDrawCreate(516.000000, 398.000000, "San Fierro"); + TextDrawBackgroundColor(g_MovieModeTD[ 1 ], 255); + TextDrawFont(g_MovieModeTD[ 1 ], 3); + TextDrawLetterSize(g_MovieModeTD[ 1 ], 0.529999, 2.299999); + TextDrawColor(g_MovieModeTD[ 1 ], -2347265); + TextDrawSetOutline(g_MovieModeTD[ 1 ], 1); + TextDrawSetProportional(g_MovieModeTD[ 1 ], 1); + + g_MovieModeTD[ 2 ] = TextDrawCreate(530.000000, 414.000000, "Cops and Robbers"); + TextDrawBackgroundColor(g_MovieModeTD[ 2 ], 255); + TextDrawFont(g_MovieModeTD[ 2 ], 0); + TextDrawLetterSize(g_MovieModeTD[ 2 ], 0.310000, 1.100000); + TextDrawColor(g_MovieModeTD[ 2 ], -1); + TextDrawSetOutline(g_MovieModeTD[ 2 ], 1); + TextDrawSetProportional(g_MovieModeTD[ 2 ], 1); + + g_MovieModeTD[ 3 ] = TextDrawCreate(507.000000, 398.000000, "_"); + TextDrawBackgroundColor(g_MovieModeTD[ 3 ], 255); + TextDrawFont(g_MovieModeTD[ 3 ], 1); + TextDrawLetterSize(g_MovieModeTD[ 3 ], 0.500000, -0.400000); + TextDrawColor(g_MovieModeTD[ 3 ], -1); + TextDrawSetOutline(g_MovieModeTD[ 3 ], 0); + TextDrawSetProportional(g_MovieModeTD[ 3 ], 1); + TextDrawSetShadow(g_MovieModeTD[ 3 ], 1); + TextDrawUseBox(g_MovieModeTD[ 3 ], 1); + TextDrawBoxColor(g_MovieModeTD[ 3 ], 255); + TextDrawTextSize(g_MovieModeTD[ 3 ], 620.000000, 0.000000); + + g_MovieModeTD[ 4 ] = TextDrawCreate(530.000000, 385.000000, "www.SFCNR.com"); + TextDrawBackgroundColor(g_MovieModeTD[ 4 ], 255); + TextDrawFont(g_MovieModeTD[ 4 ], 1); + TextDrawLetterSize(g_MovieModeTD[ 4 ], 0.200000, 1.000000); + TextDrawColor(g_MovieModeTD[ 4 ], 0xfa4d4cff); + TextDrawSetOutline(g_MovieModeTD[ 4 ], 1); + TextDrawSetProportional(g_MovieModeTD[ 4 ], 1); + + g_MovieModeTD[ 5 ] = TextDrawCreate(507.000000, 386.000000, "_"); + TextDrawBackgroundColor(g_MovieModeTD[ 5 ], 255); + TextDrawFont(g_MovieModeTD[ 5 ], 1); + TextDrawLetterSize(g_MovieModeTD[ 5 ], 0.500000, 0.799999); + TextDrawColor(g_MovieModeTD[ 5 ], -1); + TextDrawSetOutline(g_MovieModeTD[ 5 ], 0); + TextDrawSetProportional(g_MovieModeTD[ 5 ], 1); + TextDrawSetShadow(g_MovieModeTD[ 5 ], 1); + TextDrawUseBox(g_MovieModeTD[ 5 ], 1); + TextDrawBoxColor(g_MovieModeTD[ 5 ], 128); + TextDrawTextSize(g_MovieModeTD[ 5 ], 620.000000, 0.000000); + return 1; +} +hook OnPlayerDisconnect( playerid, reason ) { + p_inMovieMode{ playerid } = false; + return 1; +} + +/* ** Commands ** */ +CMD:moviemode( playerid, params[ ] ) +{ + switch ( p_inMovieMode{ playerid } ) + { + case true: + { + p_inMovieMode{ playerid } = false; + SendServerMessage( playerid, "Movie mode has been un-toggled." ); + CallLocalFunction( "OnPlayerLoadTextdraws", "d", playerid ); + for ( new i = 0; i < sizeof( g_MovieModeTD ); i ++ ) TextDrawHideForPlayer( playerid, g_MovieModeTD[ i ] ); + } + case false: + { + p_inMovieMode{ playerid } = true; + SendServerMessage( playerid, "Movie mode has been toggled." ); + CallLocalFunction( "OnPlayerUnloadTextdraws", "d", playerid ); + for ( new i = 0; i < sizeof( g_MovieModeTD ); i ++ ) TextDrawShowForPlayer( playerid, g_MovieModeTD[ i ] ); + } + } + CallLocalFunction( "OnPlayerMovieMode", "dd", playerid, p_inMovieMode{ playerid } ); + return 1; +} + +/* ** Functions ** */ +stock IsPlayerMovieMode( playerid ) { + return p_inMovieMode{ playerid }; +} \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/model_preview.pwn b/gamemodes/irresistible/cnr/model_preview.pwn index 32a7bb1..eb7ba50 100644 --- a/gamemodes/irresistible/cnr/model_preview.pwn +++ b/gamemodes/irresistible/cnr/model_preview.pwn @@ -160,9 +160,7 @@ stock ShowPlayerModelPreview( playerid, handleid, title[ ], model, bgcolor = 0x0 PlayerTextDrawShow( playerid, p_ModelPreviewTD[ playerid ] [ i ] ); } - p_inMovieMode{ playerid } = false; - cmd_moviemode( playerid, "" ); // Hide textdraws - + CallLocalFunction( "OnPlayerUnloadTextdraws", "d", playerid ); SetPVarInt( playerid, "preview_model_handle", handleid ); SelectTextDraw( playerid, COLOR_RED ); return 1; @@ -181,8 +179,7 @@ stock HidePlayerModelPreview( playerid, cancel = 1 ) PlayerTextDrawHide( playerid, p_ModelPreviewTD[ playerid ] [ i ] ); } - cmd_moviemode( playerid, "" ); // Show textdraws - + CallLocalFunction( "OnPlayerLoadTextdraws", "d", playerid ); CallLocalFunction( "OnPlayerEndModelPreview", "dd", playerid, GetPVarInt( playerid, "preview_model_handle" ) ); SetPVarInt( playerid, "preview_model_delay", GetTickCount( ) + 100 ); diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index e59b421..d57c94b 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -70,7 +70,6 @@ new p_BailOfferer [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... }, Text3D: p_InfoLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID, ... }, p_InfoLabelString [ MAX_PLAYERS ] [ 32 ], - bool: p_inMovieMode [ MAX_PLAYERS char ], bool: p_inCIA [ MAX_PLAYERS char ], p_AntiEmpSpam [ MAX_PLAYERS ], bool: p_inPaintBall [ MAX_PLAYERS char ], @@ -228,8 +227,6 @@ stock GetPlayerVIPLevel( playerid ) return p_VIPLevel[ playerid ]; stock IsPlayerInPaintBall( playerid ) return p_inPaintBall{ playerid }; -stock IsPlayerMovieMode( playerid ) return p_inMovieMode{ playerid }; - stock GetPlayerAdminLevel( playerid ) return p_AdminLevel[ playerid ]; stock IsPlayerSpawned( playerid ) return p_Spawned{ playerid }; diff --git a/gamemodes/irresistible/cnr/textdraws.pwn b/gamemodes/irresistible/cnr/textdraws.pwn index 345d501..51b0b79 100644 --- a/gamemodes/irresistible/cnr/textdraws.pwn +++ b/gamemodes/irresistible/cnr/textdraws.pwn @@ -13,7 +13,6 @@ new Text: g_ObjectLoadTD = Text: INVALID_TEXT_DRAW, Text: g_WebsiteTD = Text: INVALID_TEXT_DRAW, Text: g_MotdTD = Text: INVALID_TEXT_DRAW, - Text: g_MovieModeTD [ 6 ] = { Text: INVALID_TEXT_DRAW, ... }, Text: g_WorldDayTD = Text: INVALID_TEXT_DRAW, Text: g_AchievementTD [ 4 ] = { Text: INVALID_TEXT_DRAW, ... }, Text: g_AdminLogTD = Text: INVALID_TEXT_DRAW, @@ -177,66 +176,6 @@ hook OnScriptInit( ) TextDrawSetOutline(g_WebsiteTD, 1); TextDrawSetProportional(g_WebsiteTD, 1); - g_MovieModeTD[ 0 ] = TextDrawCreate(507.000000, 386.000000, "_"); - TextDrawBackgroundColor(g_MovieModeTD[ 0 ], 255); - TextDrawFont(g_MovieModeTD[ 0 ], 1); - TextDrawLetterSize(g_MovieModeTD[ 0 ], 0.500000, 4.799999); - TextDrawColor(g_MovieModeTD[ 0 ], -1); - TextDrawSetOutline(g_MovieModeTD[ 0 ], 0); - TextDrawSetProportional(g_MovieModeTD[ 0 ], 1); - TextDrawSetShadow(g_MovieModeTD[ 0 ], 1); - TextDrawUseBox(g_MovieModeTD[ 0 ], 1); - TextDrawBoxColor(g_MovieModeTD[ 0 ], 80); - TextDrawTextSize(g_MovieModeTD[ 0 ], 620.000000, 0.000000); - - g_MovieModeTD[ 1 ] = TextDrawCreate(516.000000, 398.000000, "San Fierro"); - TextDrawBackgroundColor(g_MovieModeTD[ 1 ], 255); - TextDrawFont(g_MovieModeTD[ 1 ], 3); - TextDrawLetterSize(g_MovieModeTD[ 1 ], 0.529999, 2.299999); - TextDrawColor(g_MovieModeTD[ 1 ], -2347265); - TextDrawSetOutline(g_MovieModeTD[ 1 ], 1); - TextDrawSetProportional(g_MovieModeTD[ 1 ], 1); - - g_MovieModeTD[ 2 ] = TextDrawCreate(530.000000, 414.000000, "Cops and Robbers"); - TextDrawBackgroundColor(g_MovieModeTD[ 2 ], 255); - TextDrawFont(g_MovieModeTD[ 2 ], 0); - TextDrawLetterSize(g_MovieModeTD[ 2 ], 0.310000, 1.100000); - TextDrawColor(g_MovieModeTD[ 2 ], -1); - TextDrawSetOutline(g_MovieModeTD[ 2 ], 1); - TextDrawSetProportional(g_MovieModeTD[ 2 ], 1); - - g_MovieModeTD[ 3 ] = TextDrawCreate(507.000000, 398.000000, "_"); - TextDrawBackgroundColor(g_MovieModeTD[ 3 ], 255); - TextDrawFont(g_MovieModeTD[ 3 ], 1); - TextDrawLetterSize(g_MovieModeTD[ 3 ], 0.500000, -0.400000); - TextDrawColor(g_MovieModeTD[ 3 ], -1); - TextDrawSetOutline(g_MovieModeTD[ 3 ], 0); - TextDrawSetProportional(g_MovieModeTD[ 3 ], 1); - TextDrawSetShadow(g_MovieModeTD[ 3 ], 1); - TextDrawUseBox(g_MovieModeTD[ 3 ], 1); - TextDrawBoxColor(g_MovieModeTD[ 3 ], 255); - TextDrawTextSize(g_MovieModeTD[ 3 ], 620.000000, 0.000000); - - g_MovieModeTD[ 4 ] = TextDrawCreate(530.000000, 385.000000, "www.SFCNR.com"); - TextDrawBackgroundColor(g_MovieModeTD[ 4 ], 255); - TextDrawFont(g_MovieModeTD[ 4 ], 1); - TextDrawLetterSize(g_MovieModeTD[ 4 ], 0.200000, 1.000000); - TextDrawColor(g_MovieModeTD[ 4 ], 0xfa4d4cff); - TextDrawSetOutline(g_MovieModeTD[ 4 ], 1); - TextDrawSetProportional(g_MovieModeTD[ 4 ], 1); - - g_MovieModeTD[ 5 ] = TextDrawCreate(507.000000, 386.000000, "_"); - TextDrawBackgroundColor(g_MovieModeTD[ 5 ], 255); - TextDrawFont(g_MovieModeTD[ 5 ], 1); - TextDrawLetterSize(g_MovieModeTD[ 5 ], 0.500000, 0.799999); - TextDrawColor(g_MovieModeTD[ 5 ], -1); - TextDrawSetOutline(g_MovieModeTD[ 5 ], 0); - TextDrawSetProportional(g_MovieModeTD[ 5 ], 1); - TextDrawSetShadow(g_MovieModeTD[ 5 ], 1); - TextDrawUseBox(g_MovieModeTD[ 5 ], 1); - TextDrawBoxColor(g_MovieModeTD[ 5 ], 128); - TextDrawTextSize(g_MovieModeTD[ 5 ], 620.000000, 0.000000); - g_AdminOnDutyTD = TextDrawCreate(552.000000, 66.500000, "ADMIN ON DUTY"); TextDrawBackgroundColor(g_AdminOnDutyTD, 255); TextDrawFont(g_AdminOnDutyTD, 1); diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index e00f1d2..f46f1a1 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -88,6 +88,8 @@ public OnServerUpdateTimer( ); public OnServerSecondTick( ); public OnHelpHTTPResponse( index, response_code, data[ ] ); public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ); +public OnPlayerLoadTextdraws( playerid ); +public OnPlayerUnloadTextdraws( playerid ); main() { @@ -879,7 +881,6 @@ public OnPlayerDisconnect( playerid, reason ) // p_XP [ playerid ] = 0; p_InHouse [ playerid ] = -1; p_InGarage [ playerid ] = -1; - p_inMovieMode { playerid } = false; p_CantUseAsk { playerid } = false; p_LastSkin [ playerid ] = 0; p_SecureWallet { playerid } = false; @@ -990,7 +991,7 @@ public OnPlayerSpawn( playerid ) TextDrawHideForPlayer( playerid, g_CurrentRankTD ); TextDrawHideForPlayer( playerid, g_currentXPTD ); - if ( p_inMovieMode{ playerid } == false ) + if ( ! IsPlayerMovieMode( playerid ) ) { ShowPlayerTogglableTextdraws( playerid ); ShowPlayerIrresistibleRank( playerid ); @@ -3241,46 +3242,33 @@ CMD:emp( playerid, params[ ] ) return 1; } -CMD:moviemode( playerid, params[ ] ) +public OnPlayerLoadTextdraws( playerid ) { - switch( p_inMovieMode{ playerid } ) - { - case true: - { - ShowPlayerTogglableTextdraws( playerid ); - PlayerTextDrawShow( playerid, p_LocationTD[ playerid ] ); - if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD ); - TextDrawShowForPlayer( playerid, g_WebsiteTD ); - if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] ); - TextDrawShowForPlayer( playerid, g_MotdTD ); - if ( p_FPSCounter{ playerid } ) TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] ); - if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD ); - TextDrawShowForPlayer( playerid, g_WorldDayTD ); - PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] ); - for( new i; i < sizeof( g_MovieModeTD ); i ++ ) TextDrawHideForPlayer( playerid, g_MovieModeTD[ i ] ); - p_inMovieMode{ playerid } = false; - SendServerMessage( playerid, "Movie mode has been un-toggled." ); - CallLocalFunction( "OnPlayerLoadTextdraws", "d", playerid ); - } - case false: - { - PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] ); - HidePlayerTogglableTextdraws( playerid ); - PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] ); - PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); - TextDrawHideForPlayer( playerid, g_WebsiteTD ); - TextDrawHideForPlayer( playerid, g_AdminOnDutyTD ); - TextDrawHideForPlayer( playerid, g_DoubleXPTD ); - TextDrawHideForPlayer( playerid, g_MotdTD ); - TextDrawHideForPlayer( playerid, g_WorldDayTD ); - TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] ); - for( new i; i < sizeof( g_MovieModeTD ); i ++ ) TextDrawShowForPlayer( playerid, g_MovieModeTD[ i ] ); - p_inMovieMode{ playerid } = true; - SendServerMessage( playerid, "Movie mode has been toggled." ); - CallLocalFunction( "OnPlayerUnloadTextdraws", "d", playerid ); - } - } - CallLocalFunction( "OnPlayerMovieMode", "dd", playerid, p_inMovieMode{ playerid } ); + ShowPlayerTogglableTextdraws( playerid ); + PlayerTextDrawShow( playerid, p_LocationTD[ playerid ] ); + if ( IsDoubleXP( ) ) TextDrawShowForPlayer( playerid, g_DoubleXPTD ); + TextDrawShowForPlayer( playerid, g_WebsiteTD ); + if ( p_WantedLevel[ playerid ] ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] ); + TextDrawShowForPlayer( playerid, g_MotdTD ); + if ( p_FPSCounter{ playerid } ) TextDrawShowForPlayer( playerid, p_FPSCounterTD[ playerid ] ); + if ( p_AdminOnDuty{ playerid } ) TextDrawShowForPlayer( playerid, g_AdminOnDutyTD ); + TextDrawShowForPlayer( playerid, g_WorldDayTD ); + PlayerTextDrawShow( playerid, g_ZoneOwnerTD[ playerid ] ); + return 1; +} + +public OnPlayerUnloadTextdraws( playerid ) +{ + PlayerTextDrawHide( playerid, g_ZoneOwnerTD[ playerid ] ); + HidePlayerTogglableTextdraws( playerid ); + PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] ); + PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] ); + TextDrawHideForPlayer( playerid, g_WebsiteTD ); + TextDrawHideForPlayer( playerid, g_AdminOnDutyTD ); + TextDrawHideForPlayer( playerid, g_DoubleXPTD ); + TextDrawHideForPlayer( playerid, g_MotdTD ); + TextDrawHideForPlayer( playerid, g_WorldDayTD ); + TextDrawHideForPlayer( playerid, p_FPSCounterTD[ playerid ] ); return 1; }