fix issue with donation goal percentage not loading

This commit is contained in:
Lorenc Pekaj 2019-02-23 19:11:33 +11:00
parent 791fbfce12
commit 4e7d6f1906
3 changed files with 11 additions and 2 deletions

View File

@ -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
- Called when a player's money is changed
- `OnServerVariablesLoaded( )`
- Called when server variables are fully loaded

View File

@ -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 ) );

View File

@ -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;
}