From 4e7d6f1906683a5e996a6fea0180e28b55d6f05d Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sat, 23 Feb 2019 19:11:33 +1100 Subject: [PATCH] fix issue with donation goal percentage not loading --- gamemodes/irresistible/README.md | 4 +++- gamemodes/irresistible/cnr/features/vip/redeem_code.pwn | 6 +++++- gamemodes/irresistible/servervars.pwn | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gamemodes/irresistible/README.md b/gamemodes/irresistible/README.md index b853d9c..fb67930 100644 --- a/gamemodes/irresistible/README.md +++ b/gamemodes/irresistible/README.md @@ -67,4 +67,6 @@ - `OnPlayerArrested( playerid, victimid, totalarrests, totalpeople )` - Called when a player is arrested - `OnPlayerMoneyChanged( playerid, amount )` - - Called when a player's money is changed \ No newline at end of file + - Called when a player's money is changed +- `OnServerVariablesLoaded( )` + - Called when server variables are fully loaded \ No newline at end of file diff --git a/gamemodes/irresistible/cnr/features/vip/redeem_code.pwn b/gamemodes/irresistible/cnr/features/vip/redeem_code.pwn index a29d3f9..f4f91cc 100644 --- a/gamemodes/irresistible/cnr/features/vip/redeem_code.pwn +++ b/gamemodes/irresistible/cnr/features/vip/redeem_code.pwn @@ -52,8 +52,11 @@ hook OnScriptInit( ) TextDrawColor(g_TopDonorTD, -2347265); TextDrawSetOutline(g_TopDonorTD, 1); TextDrawSetProportional(g_TopDonorTD, 1); + return 1; +} - /* ** Update Donation TD ** */ +hook OnServerVariablesLoaded( ) +{ UpdateGlobalDonated( ); return 1; } @@ -207,6 +210,7 @@ thread OnGrabLatestDonor( hidden ) new Float: total_donations = cache_get_field_content_float( 0, "TOTAL_DONATIONS", dbHandle ); new Float: funding_goal_percent = total_donations / GetServerVariableFloat( "donation_goal_amount" ) * 100.0; + printf( "%f", funding_goal_percent ); // Prevents total revenue for the month being disclosed mathematically if ( funding_goal_percent >= 100.0 ) { TextDrawSetString( g_TopDonorTD, sprintf( "Latest Donor %s - $%0.2f, ~g~Month Is Fully %0.2f%% Funded!", szName, last_donation, 100.0 ) ); diff --git a/gamemodes/irresistible/servervars.pwn b/gamemodes/irresistible/servervars.pwn index 134fe0c..0d2e71e 100644 --- a/gamemodes/irresistible/servervars.pwn +++ b/gamemodes/irresistible/servervars.pwn @@ -63,6 +63,9 @@ thread OnLoadServerVariables( ) case GLOBAL_VARTYPE_FLOAT: SetGVarFloat( variable_name, cache_get_field_content_float( i, "FLOAT_VAL", dbHandle ) ); } } + + // safe method for modules + CallLocalFunction( "OnServerVariablesLoaded", "" ); } return printf( "[SERVER] %d server variables have been loaded.", rows ), 1; }