diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 1b8599f..61af3fb 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -11,8 +11,8 @@ #include "irresistible\cnr\features\houses\_houses.pwn" #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\gangs\_gangs.pwn" #include "irresistible\cnr\features\robbery\_robbery.pwn" #include "irresistible\cnr\features\visage\_visage.pwn" #include "irresistible\cnr\features\minijobs\_minijobs.pwn" diff --git a/gamemodes/irresistible/cnr/features/gangs/facilities.pwn b/gamemodes/irresistible/cnr/features/gangs/facilities.pwn index 57129e7..c652c0d 100644 --- a/gamemodes/irresistible/cnr/features/gangs/facilities.pwn +++ b/gamemodes/irresistible/cnr/features/gangs/facilities.pwn @@ -264,6 +264,7 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) } GivePlayerCash( playerid, -price ); + StockMarket_UpdateEarnings( E_STOCK_AMMUNATION, price, .factor = 0.5 ); if ( g_AmmunationWeapons[ i ] [ E_WEPID ] == 101 ) SetPlayerArmour( playerid, float( g_AmmunationWeapons[ i ] [ E_AMMO ] ) ); else GivePlayerWeapon( playerid, g_AmmunationWeapons[ i ] [ E_WEPID ], g_AmmunationWeapons[ i ] [ E_AMMO ] ); diff --git a/gamemodes/irresistible/cnr/features/stocks/stocks.pwn b/gamemodes/irresistible/cnr/features/stocks/stocks.pwn index 6531c1e..c2d7d82 100644 --- a/gamemodes/irresistible/cnr/features/stocks/stocks.pwn +++ b/gamemodes/irresistible/cnr/features/stocks/stocks.pwn @@ -38,7 +38,8 @@ enum E_STOCK_MARKET_PRICE_DATA enum { - E_STOCK_MINING_COMPANY + E_STOCK_MINING_COMPANY, + E_STOCK_AMMUNATION }; static const Float: STOCK_MARKET_POOL_FACTOR = 100000.0; // for every STOCK_MARKET_POOL_FACTOR ... STOCK_MARKET_PRICE_FACTOR added to the price @@ -62,6 +63,7 @@ hook OnScriptInit( ) // create markets CreateStockMarket( E_STOCK_MINING_COMPANY, "The Mining Company", "MC", 100000.0, 25.0, 250.0 ); // 25m mcap max + CreateStockMarket( E_STOCK_AMMUNATION, "Ammu-Nation", "A", 100000.0, 25.0, 250.0 ); // 25m mcap max return 1; } @@ -499,16 +501,6 @@ thread StockMarket_OnCancelOrder( playerid ) } /* ** Command ** */ -CMD:increase( playerid, params[ ] ) { - StockMarket_UpdateEarnings( 0, strval( params ) ); - return 1; -} - -CMD:newreport( playerid, params[ ] ) { - StockMarket_ReleaseDividends( 0 ); - return 1; -} - CMD:stocks( playerid, params[ ] ) return cmd_stockmarkets( playerid, params ); CMD:stockmarkets( playerid, params[ ] ) { @@ -582,13 +574,17 @@ static stock StockMarket_ReleaseDividends( stockid ) return 1; } -stock StockMarket_UpdateEarnings( stockid, amount ) +stock StockMarket_UpdateEarnings( stockid, amount, Float: factor = 1.0 ) { if ( ! Iter_Contains( stockmarkets, stockid ) ) return 0; - g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ] += float( amount ); - //printf( "Current Pool: %f, Prior Pool: %f", g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ], g_stockMarketReportData[ stockid ] [ 1 ] [ E_POOL ] ); + // ensure that pool remains always above 0 dollars + if ( ( g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ] += float( amount ) * factor ) < 0.0 ) { + g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ] = 0.0; + } + + // save to database mysql_single_query( sprintf( "UPDATE `STOCK_REPORTS` SET `POOL`=%f WHERE `ID` = %d", g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ], g_stockMarketReportData[ stockid ] [ 0 ] [ E_SQL_ID ] ) ); return 1; } diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index ce6e60c..d99885b 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -9584,6 +9584,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) else GivePlayerWeapon( playerid, g_AmmunationWeapons[ i ] [ E_WEPID ], g_AmmunationWeapons[ i ] [ E_AMMO ] * ( g_AmmunationWeapons[ i ] [ E_WEPID ] == 35 ? 1 : 5 ) ); SetPlayerArmedWeapon( playerid, 0 ); GivePlayerCash( playerid, -( price ) ); + StockMarket_UpdateEarnings( E_STOCK_AMMUNATION, price, .factor = 0.5 ); RedirectAmmunation( playerid, p_WeaponDealMenu{ playerid }, "{FFFFFF}Weapon Deal - Purchase Weapons", DIALOG_WEAPON_DEAL_BUY, 0.75, 5 ); break; } @@ -9627,6 +9628,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) GivePlayerCash( playerid, -iCostPrice ); + StockMarket_UpdateEarnings( E_STOCK_AMMUNATION, iCostPrice, .factor = 0.5 ); RedirectAmmunation( playerid, p_AmmunationMenu{ playerid } ); if ( g_AmmunationWeapons[ i ] [ E_WEPID ] == 101 ) SetPlayerArmour( playerid, float( g_AmmunationWeapons[ i ] [ E_AMMO ] ) );