disable happy hour configuration

This commit is contained in:
Lorenc Pekaj 2019-02-23 19:22:36 +11:00
parent 398f4c8ece
commit 5fe215beed
2 changed files with 66 additions and 53 deletions

View File

@ -13,15 +13,35 @@
#endinput #endinput
#endif #endif
/* ** Configuration ** */
#define DISABLE_HAPPY_HOUR
/* ** Variables ** */ /* ** Variables ** */
static stock #if !defined DISABLE_HAPPY_HOUR
static stock
bool: g_HappyHour = false, bool: g_HappyHour = false,
Float: g_HappyHourRate = 0.0 Float: g_HappyHourRate = 0.0,
; Text: g_NotManyPlayersTD = Text: INVALID_TEXT_DRAW
;
#endif
/* ** Hooks ** */ /* ** Hooks ** */
hook OnServerUpdate( ) #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;
}
hook OnServerUpdate( )
{
new Float: fLastRate; new Float: fLastRate;
new playersOnline = Iter_Count(Player); new playersOnline = Iter_Count(Player);
@ -47,7 +67,20 @@ hook OnServerUpdate( )
TextDrawHideForAll( g_NotManyPlayersTD ); TextDrawHideForAll( g_NotManyPlayersTD );
} }
return 1; 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 ) hook OnPlayerTickSecond( playerid )
{ {
@ -69,24 +102,14 @@ hook OnPlayerTickSecond( playerid )
else if ( p_VIPLevel[ playerid ] == VIP_PLATINUM ) else if ( p_VIPLevel[ playerid ] == VIP_PLATINUM )
iCoinGenRate *= 0.90; // Reduce by 10% if Diamond iCoinGenRate *= 0.90; // Reduce by 10% if Diamond
#if !defined DISABLE_HAPPY_HOUR
// Happy Hour // Happy Hour
if ( g_HappyHour && ( 0.0 <= g_HappyHourRate <= 0.25 ) ) if ( g_HappyHour && ( 0.0 <= g_HappyHourRate <= 0.25 ) )
iCoinGenRate *= 1.0 - g_HappyHourRate; iCoinGenRate *= 1.0 - g_HappyHourRate;
#endif
GivePlayerIrresistibleCoins( playerid, ( 1.0 / iCoinGenRate ) / 60.0 ); // Prev 25.92 GivePlayerIrresistibleCoins( playerid, ( 1.0 / iCoinGenRate ) / 60.0 ); // Prev 25.92
} }
} }
return 1; return 1;
} }
hook OnPlayerLoadTextdraws( playerid ) {
if ( g_HappyHour ) {
TextDrawShowForPlayer( playerid, g_NotManyPlayersTD );
}
return 1;
}
hook OnPlayerUnloadTextdraws( playerid ) {
TextDrawHideForPlayer( playerid, g_NotManyPlayersTD );
return 1;
}

View File

@ -21,7 +21,6 @@ new
Text: g_currentXPTD = Text: INVALID_TEXT_DRAW, Text: g_currentXPTD = Text: INVALID_TEXT_DRAW,
Text: g_CurrentRankTD = Text: INVALID_TEXT_DRAW, Text: g_CurrentRankTD = Text: INVALID_TEXT_DRAW,
Text: g_CurrentCoinsTD = Text: INVALID_TEXT_DRAW, Text: g_CurrentCoinsTD = Text: INVALID_TEXT_DRAW,
Text: g_NotManyPlayersTD = Text: INVALID_TEXT_DRAW,
// Player Textdraws // Player Textdraws
PlayerText: p_LocationTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... }, PlayerText: p_LocationTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
@ -44,15 +43,6 @@ new
/* ** Hooks ** */ /* ** Hooks ** */
hook OnScriptInit( ) 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"); g_currentXPTD = TextDrawCreate(529.000000, 405.000000, "Current XP");
TextDrawBackgroundColor(g_currentXPTD, 255); TextDrawBackgroundColor(g_currentXPTD, 255);
TextDrawFont(g_currentXPTD, 3); TextDrawFont(g_currentXPTD, 3);