From 5fe215beed907158e366e30e657915ecace3b0de Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sat, 23 Feb 2019 19:22:36 +1100 Subject: [PATCH] disable happy hour configuration --- .../cnr/features/vip/coin_generation.pwn | 109 +++++++++++------- gamemodes/irresistible/cnr/textdraws.pwn | 10 -- 2 files changed, 66 insertions(+), 53 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn b/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn index 8fb37f6..c0b93a1 100644 --- a/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn +++ b/gamemodes/irresistible/cnr/features/vip/coin_generation.pwn @@ -13,41 +13,74 @@ #endinput #endif +/* ** Configuration ** */ +#define DISABLE_HAPPY_HOUR + /* ** Variables ** */ -static stock - bool: g_HappyHour = false, - Float: g_HappyHourRate = 0.0 -; +#if !defined DISABLE_HAPPY_HOUR + static stock + bool: g_HappyHour = false, + Float: g_HappyHourRate = 0.0, + Text: g_NotManyPlayersTD = Text: INVALID_TEXT_DRAW + ; +#endif /* ** Hooks ** */ -hook OnServerUpdate( ) -{ - new Float: fLastRate; - new playersOnline = Iter_Count(Player); - - // Happy Hour - if ( ( g_HappyHour = playersOnline <= 20 ) == true ) { - // Maximum of 25% decrease - g_HappyHourRate = 0.25 - ( playersOnline / 80.0 ); - - // Only update colors if neccessary - if ( fLastRate != g_HappyHourRate ) - { - TextDrawSetString( g_NotManyPlayersTD, sprintf( "Coin generation increased by %0.1f%% as there aren't many players online!", g_HappyHourRate * 100.0 ) ); - TextDrawColor( g_NotManyPlayersTD, setAlpha( COLOR_RED, floatround( 200.0 - 10.0 * float( playersOnline ) ) ) ); - TextDrawShowForAllSpawned( g_NotManyPlayersTD ); - } - - // Update last rate - fLastRate = g_HappyHourRate; - } else { - // Disable Color - g_HappyHourRate = 0.0; - TextDrawColor( g_NotManyPlayersTD, 0 ); - TextDrawHideForAll( g_NotManyPlayersTD ); +#if !defined DISABLE_HAPPY_HOUR + hook OnScriptInit( ) + { + g_NotManyPlayersTD = TextDrawCreate(322.000000, 12.000000, "Coin generation increased by 5x as there aren't many players online!"); + TextDrawAlignment(g_NotManyPlayersTD, 2); + TextDrawBackgroundColor(g_NotManyPlayersTD, 0); + TextDrawFont(g_NotManyPlayersTD, 1); + TextDrawLetterSize(g_NotManyPlayersTD, 0.149999, 0.799999); + TextDrawColor(g_NotManyPlayersTD, -16776961); + TextDrawSetOutline(g_NotManyPlayersTD, 1); + TextDrawSetProportional(g_NotManyPlayersTD, 1); + return 1; } - return 1; -} + + hook OnServerUpdate( ) + { + new Float: fLastRate; + new playersOnline = Iter_Count(Player); + + // Happy Hour + if ( ( g_HappyHour = playersOnline <= 20 ) == true ) { + // Maximum of 25% decrease + g_HappyHourRate = 0.25 - ( playersOnline / 80.0 ); + + // Only update colors if neccessary + if ( fLastRate != g_HappyHourRate ) + { + TextDrawSetString( g_NotManyPlayersTD, sprintf( "Coin generation increased by %0.1f%% as there aren't many players online!", g_HappyHourRate * 100.0 ) ); + TextDrawColor( g_NotManyPlayersTD, setAlpha( COLOR_RED, floatround( 200.0 - 10.0 * float( playersOnline ) ) ) ); + TextDrawShowForAllSpawned( g_NotManyPlayersTD ); + } + + // Update last rate + fLastRate = g_HappyHourRate; + } else { + // Disable Color + g_HappyHourRate = 0.0; + TextDrawColor( g_NotManyPlayersTD, 0 ); + TextDrawHideForAll( g_NotManyPlayersTD ); + } + return 1; + } + + hook OnPlayerLoadTextdraws( playerid ){ + if ( g_HappyHour ) { + TextDrawShowForPlayer( playerid, g_NotManyPlayersTD ); + } + return 1; + } + + hook OnPlayerUnloadTextdraws( playerid ) { + TextDrawHideForPlayer( playerid, g_NotManyPlayersTD ); + return 1; + } +#endif hook OnPlayerTickSecond( playerid ) { @@ -69,24 +102,14 @@ hook OnPlayerTickSecond( playerid ) else if ( p_VIPLevel[ playerid ] == VIP_PLATINUM ) iCoinGenRate *= 0.90; // Reduce by 10% if Diamond + #if !defined DISABLE_HAPPY_HOUR // Happy Hour if ( g_HappyHour && ( 0.0 <= g_HappyHourRate <= 0.25 ) ) iCoinGenRate *= 1.0 - g_HappyHourRate; + #endif GivePlayerIrresistibleCoins( playerid, ( 1.0 / iCoinGenRate ) / 60.0 ); // Prev 25.92 } } return 1; -} - -hook OnPlayerLoadTextdraws( playerid ) { - if ( g_HappyHour ) { - TextDrawShowForPlayer( playerid, g_NotManyPlayersTD ); - } - return 1; -} - -hook OnPlayerUnloadTextdraws( playerid ) { - TextDrawHideForPlayer( playerid, g_NotManyPlayersTD ); - return 1; } \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/textdraws.pwn b/gamemodes/irresistible/cnr/textdraws.pwn index 0261294..0072f8d 100644 --- a/gamemodes/irresistible/cnr/textdraws.pwn +++ b/gamemodes/irresistible/cnr/textdraws.pwn @@ -21,7 +21,6 @@ new Text: g_currentXPTD = Text: INVALID_TEXT_DRAW, Text: g_CurrentRankTD = Text: INVALID_TEXT_DRAW, Text: g_CurrentCoinsTD = Text: INVALID_TEXT_DRAW, - Text: g_NotManyPlayersTD = Text: INVALID_TEXT_DRAW, // Player Textdraws PlayerText: p_LocationTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, @@ -44,15 +43,6 @@ new /* ** Hooks ** */ hook OnScriptInit( ) { - g_NotManyPlayersTD = TextDrawCreate(322.000000, 12.000000, "Coin generation increased by 5x as there aren't many players online!"); - TextDrawAlignment(g_NotManyPlayersTD, 2); - TextDrawBackgroundColor(g_NotManyPlayersTD, 0); - TextDrawFont(g_NotManyPlayersTD, 1); - TextDrawLetterSize(g_NotManyPlayersTD, 0.149999, 0.799999); - TextDrawColor(g_NotManyPlayersTD, -16776961); - TextDrawSetOutline(g_NotManyPlayersTD, 1); - TextDrawSetProportional(g_NotManyPlayersTD, 1); - g_currentXPTD = TextDrawCreate(529.000000, 405.000000, "Current XP"); TextDrawBackgroundColor(g_currentXPTD, 255); TextDrawFont(g_currentXPTD, 3);