Merge pull request #74 from ItsStev/business-production

Business production
This commit is contained in:
Lorenc Pekaj 2019-09-16 12:00:42 +10:00 committed by GitHub
commit 142d75a759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -220,40 +220,32 @@ hook OnServerUpdate( )
// Replenish product // Replenish product
foreach ( new businessid : business ) if ( g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] ) foreach ( new businessid : business ) if ( g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] )
{ {
new // reduce business production time by a second
members = 0; g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] --;
GetOnlineBusinessAssociates( businessid, members ); // if the production timestamp is less than 0 ... refuel
if ( g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] <= 0 )
if ( members )
{ {
// reduce business production time by a second // update the timestamps and switch stock for product
g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] --; g_businessData[ businessid ] [ E_PRODUCT ] += g_businessData[ businessid ] [ E_SUPPLIES ];
g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] = 0;
g_businessData[ businessid ] [ E_SUPPLIES ] = 0;
// if the production timestamp is less than 0 ... refuel // alert any associates
if ( g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] <= 0 ) foreach ( new p : Player ) if ( IsBusinessAssociate( p, businessid ) ) {
{ SendClientMessageFormatted( p, -1, ""COL_GREY"[BUSINESS]"COL_WHITE" Production has completed for "COL_GREY"%s"COL_WHITE".", g_businessData[ businessid ] [ E_NAME ] );
// update the timestamps and switch stock for product
g_businessData[ businessid ] [ E_PRODUCT ] += g_businessData[ businessid ] [ E_SUPPLIES ];
g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] = 0;
g_businessData[ businessid ] [ E_SUPPLIES ] = 0;
// alert any associates
foreach ( new p : Player ) if ( IsBusinessAssociate( p, businessid ) ) {
SendClientMessageFormatted( p, -1, ""COL_GREY"[BUSINESS]"COL_WHITE" Production has completed for "COL_GREY"%s"COL_WHITE".", g_businessData[ businessid ] [ E_NAME ] );
}
// update db
UpdateBusinessData( businessid );
}
else if ( g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] % 60 == 0 ) // every minute that passes, update in the sql
{
mysql_single_query( sprintf( "UPDATE `BUSINESSES` SET `PROD_TIMESTAMP` = %d WHERE `ID` = %d", g_businessData[ businessid ] [ E_PROD_TIMESTAMP ], businessid ) );
} }
// update label anyway // update db
UpdateBusinessProductionLabel( businessid ); UpdateBusinessData( businessid );
} }
else if ( g_businessData[ businessid ] [ E_PROD_TIMESTAMP ] % 60 == 0 ) // every minute that passes, update in the sql
{
mysql_single_query( sprintf( "UPDATE `BUSINESSES` SET `PROD_TIMESTAMP` = %d WHERE `ID` = %d", g_businessData[ businessid ] [ E_PROD_TIMESTAMP ], businessid ) );
}
// update label anyway
UpdateBusinessProductionLabel( businessid );
} }
return 1; return 1;
} }