From 68fc7ad263ad5822872a65f3ca6d9e8e8decc647 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 28 Oct 2018 22:34:48 +1100 Subject: [PATCH] add mining stock --- gamemodes/irresistible/cnr/features/_features.pwn | 2 +- gamemodes/irresistible/cnr/features/minijobs/mining.pwn | 1 + gamemodes/irresistible/cnr/features/stocks/stocks.pwn | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 350cb81..1b8599f 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -12,10 +12,10 @@ #include "irresistible\cnr\features\vehicles\_vehicles.pwn" #include "irresistible\cnr\features\business\_business.pwn" #include "irresistible\cnr\features\gangs\_gangs.pwn" +#include "irresistible\cnr\features\stocks\_stocks.pwn" #include "irresistible\cnr\features\robbery\_robbery.pwn" #include "irresistible\cnr\features\visage\_visage.pwn" #include "irresistible\cnr\features\minijobs\_minijobs.pwn" -#include "irresistible\cnr\features\stocks\_stocks.pwn" // other #include "irresistible\cnr\features\shop.pwn" diff --git a/gamemodes/irresistible/cnr/features/minijobs/mining.pwn b/gamemodes/irresistible/cnr/features/minijobs/mining.pwn index 9d78fd4..887e9f5 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/mining.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/mining.pwn @@ -378,6 +378,7 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) DestroyDynamicRaceCP( p_MiningExport[ playerid ] ); p_MiningExport[ playerid ] = 0xFFFF; GivePlayerCash( playerid, cashEarned ); + StockMarket_UpdateEarnings( E_STOCK_MINING_COMPANY, cashEarned ); GivePlayerScore( playerid, floatround( oresExported / 2 ) ); // 16 score is a bit too much for ore... so half that = 8 //GivePlayerExperience( playerid, E_MINING, float( oresExported ) * 0.2 ); SendServerMessage( playerid, "You have exported %d rock ore(s) to an industry, earning you "COL_GOLD"%s"COL_WHITE".", oresExported, cash_format( cashEarned ) ); diff --git a/gamemodes/irresistible/cnr/features/stocks/stocks.pwn b/gamemodes/irresistible/cnr/features/stocks/stocks.pwn index 31211cb..409dbf5 100644 --- a/gamemodes/irresistible/cnr/features/stocks/stocks.pwn +++ b/gamemodes/irresistible/cnr/features/stocks/stocks.pwn @@ -11,7 +11,7 @@ /* ** Definitions ** */ #define MAX_STOCKS ( 32 ) -#define STOCK_REPORTING_PERIOD ( 500 ) // 1 day +#define STOCK_REPORTING_PERIOD ( 600 ) // 1 day #define STOCK_REPORTING_PERIODS ( 30 ) // last 30 periods (days) @@ -35,6 +35,11 @@ enum E_STOCK_MARKET_PRICE_DATA Float: E_EARNINGS }; +enum +{ + E_STOCK_MINING_COMPANY +}; + static stock g_stockMarketData [ MAX_STOCKS ] [ E_STOCK_MARKET_DATA ], g_stockMarketPriceData [ MAX_STOCKS ] [ STOCK_REPORTING_PERIODS ] [ E_STOCK_MARKET_PRICE_DATA ], @@ -378,7 +383,7 @@ stock StockMarket_UpdateEarnings( stockid, amount ) return 0; printf( "Current Earnings: %f, Prior Earnings: %f", g_stockMarketPriceData[ stockid ] [ 0 ] [ E_EARNINGS ], g_stockMarketPriceData[ stockid ] [ 1 ] [ E_EARNINGS ] ); - g_stockMarketPriceData[ stockid ] [ 0 ] [ E_EARNINGS ] += amount; + g_stockMarketPriceData[ stockid ] [ 0 ] [ E_EARNINGS ] += float( amount ); mysql_single_query( sprintf( "UPDATE `STOCK_REPORTS` SET `CURRENT_EARNINGS` = `CURRENT_EARNINGS` + %d WHERE `ID` = %d", g_stockMarketPriceData[ stockid ] [ 0 ] [ E_EARNINGS ], g_stockMarketPriceData[ stockid ] [ 0 ] [ E_SQL_ID ] ) ); return 1; }