From 6e54f16ed6f3245ebfb0d404097990e8efef2c42 Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sat, 3 Nov 2018 16:06:58 +1100 Subject: [PATCH] add veh dealership, trucking company, cluckin bell stocks --- .../irresistible/cnr/features/_features.pwn | 2 +- .../cnr/features/minijobs/meth.pwn | 1 + .../cnr/features/minijobs/mining.pwn | 4 ++-- .../cnr/features/minijobs/trucking.pwn | 9 +++++---- gamemodes/irresistible/cnr/features/shop.pwn | 6 ++++-- .../cnr/features/stocks/stocks.pwn | 20 ++++++++++++------- .../cnr/features/vehicles/vdealership.pwn | 2 ++ .../cnr/features/vehicles/vmodifications.pwn | 1 + gamemodes/sf-cnr.pwn | 2 +- 9 files changed, 30 insertions(+), 17 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 61af3fb..0907f5e 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -9,9 +9,9 @@ #include "irresistible\cnr\features\player\_player.pwn" #include "irresistible\cnr\features\houses\_houses.pwn" +#include "irresistible\cnr\features\stocks\_stocks.pwn" #include "irresistible\cnr\features\vehicles\_vehicles.pwn" #include "irresistible\cnr\features\business\_business.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" diff --git a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn index d5c62b3..d8ab908 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/meth.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/meth.pwn @@ -401,6 +401,7 @@ CMD:meth( playerid, params[ ] ) cashEarned = p_Methamphetamine{ playerid } * ( 5000 + random( 1000 ) ); GivePlayerCash( playerid, cashEarned ); + StockMarket_UpdateEarnings( E_STOCK_CLUCKIN_BELL, cashEarned, .factor = 0.3 ); SendServerMessage( playerid, "You have exported %d bags of meth, earning you "COL_GOLD"%s"COL_WHITE".", p_Methamphetamine{ playerid }, cash_format( cashEarned ) ); p_Methamphetamine{ playerid } = 0; } diff --git a/gamemodes/irresistible/cnr/features/minijobs/mining.pwn b/gamemodes/irresistible/cnr/features/minijobs/mining.pwn index b163574..d044016 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/mining.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/mining.pwn @@ -208,7 +208,7 @@ hook OnPlayerEnterDynamicCP( playerid, checkpointid ) new earned_money = floatround( float( g_orePrices[ g_miningData[ ore ] [ E_ORE ] ] ) * 0.5 ); GivePlayerCash( playerid, earned_money ); - StockMarket_UpdateEarnings( E_STOCK_MINING_COMPANY, earned_money ); + StockMarket_UpdateEarnings( E_STOCK_MINING_COMPANY, earned_money, 0.5 ); SendServerMessage( playerid, "You have crushed a "COL_GREY"%s"COL_WHITE" Ore and earned "COL_GOLD"%s"COL_WHITE".", getOreName( g_miningData[ ore ] [ E_ORE ] ), cash_format( earned_money ) ); RemoveEquippedOre( playerid ); } @@ -379,7 +379,7 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) DestroyDynamicRaceCP( p_MiningExport[ playerid ] ); p_MiningExport[ playerid ] = 0xFFFF; GivePlayerCash( playerid, cashEarned ); - StockMarket_UpdateEarnings( E_STOCK_MINING_COMPANY, cashEarned ); + StockMarket_UpdateEarnings( E_STOCK_MINING_COMPANY, cashEarned, 0.5 ); 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/minijobs/trucking.pwn b/gamemodes/irresistible/cnr/features/minijobs/trucking.pwn index 8e4b1ad..18d7185 100644 --- a/gamemodes/irresistible/cnr/features/minijobs/trucking.pwn +++ b/gamemodes/irresistible/cnr/features/minijobs/trucking.pwn @@ -173,12 +173,13 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid ) } new - iCashEarned = floatround( p_TruckingDistance[ playerid ] * 2.0 + g_aTrailerData[ p_TruckingTrailerModel{ playerid } ] [ p_TruckingTrailer{ playerid } ] [ E_BONUS ] ); + iCashEarned = floatround( p_TruckingDistance[ playerid ] * 3.0 + g_aTrailerData[ p_TruckingTrailerModel{ playerid } ] [ p_TruckingTrailer{ playerid } ] [ E_BONUS ] ); ach_HandleTruckingCouriers( playerid ); PlayerTextDrawHide( playerid, p_TruckingTD[ playerid ] ); GivePlayerScore( playerid, 1 + floatround( p_TruckingDistance[ playerid ] / 1000.0 ) ); + StockMarket_UpdateEarnings( E_STOCK_TRUCKING_COMPANY, iCashEarned, .factor = 1.0 ); GivePlayerCash( playerid, iCashEarned ); p_TruckingDistance [ playerid ] = 0.0; @@ -253,13 +254,13 @@ CMD:work( playerid, params[ ] ) ; if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "You must be an ordinary civilian to use this command." ); - else if ( sscanf( params, "S(NORMAL)[7]", szDifficulty ) ) return SendUsage( playerid, "/work [NORMAL/HARDER]" ); + else if ( sscanf( params, "s[7]", szDifficulty ) ) return SendUsage( playerid, "/work [NORMAL/HARD]" ); else if ( strmatch( szDifficulty, "STOP" ) ) { StopPlayerTruckingCourier( playerid ); return SendServerMessage( playerid, "Your trucking mission has been stopped." ); } - else if ( !strmatch( szDifficulty, "NORMAL" ) && !strmatch( szDifficulty, "HARDER" ) ) return SendUsage( playerid, "/work [NORMAL/HARDER/STOP]" ); + else if ( !strmatch( szDifficulty, "NORMAL" ) && !strmatch( szDifficulty, "HARD" ) ) return SendUsage( playerid, "/work [NORMAL/HARD/STOP]" ); else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You must be a driver of a vehicle to work." ); else if ( !iModel ) return SendError( playerid, "You are not in any vehicle." ); else @@ -281,7 +282,7 @@ CMD:work( playerid, params[ ] ) p_WorkCooldown [ playerid ] = g_iTime + 60; p_TruckingTrailerModel { playerid } = getTrailerType( iTrailer ); - p_TruckingTrailer { playerid } = getRandomTrailerLoad( p_TruckingTrailerModel{ playerid }, strmatch( szDifficulty, "HARDER" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY ); + p_TruckingTrailer { playerid } = getRandomTrailerLoad( p_TruckingTrailerModel{ playerid }, strmatch( szDifficulty, "HARD" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY ); p_TruckingRoute[ playerid ] { 0 } = getClosestTruckingRoute( playerid ); diff --git a/gamemodes/irresistible/cnr/features/shop.pwn b/gamemodes/irresistible/cnr/features/shop.pwn index 09016d6..638326e 100644 --- a/gamemodes/irresistible/cnr/features/shop.pwn +++ b/gamemodes/irresistible/cnr/features/shop.pwn @@ -140,9 +140,11 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) if ( GetPlayerCash( playerid ) < ( g_shopItemData[ i ] [ E_PRICE ] * iAmount ) ) SendError( playerid, "You cannot afford the price of the item(s)." ); else if ( iAmount <= 0 ) SendError( playerid, "You cannot buy anymore of this item." ); else { + new total_cost = g_shopItemData[ i ] [ E_PRICE ] * iAmount; SetPlayerShopItemAmount( playerid, i, iCurrentQuantity + iAmount ); - GivePlayerCash( playerid, -( g_shopItemData[ i ] [ E_PRICE ] * iAmount ) ); - SendServerMessage( playerid, "You have bought %dx "COL_GREY"%s"COL_WHITE" for "COL_GOLD"%s"COL_WHITE".", iAmount, g_shopItemData[ i ] [ E_NAME ], cash_format( g_shopItemData[ i ] [ E_PRICE ] * iAmount ) ); + GivePlayerCash( playerid, -total_cost ); + StockMarket_UpdateEarnings( E_STOCK_SUPA_SAVE, total_cost, 0.25 ); + SendServerMessage( playerid, "You have bought %dx "COL_GREY"%s"COL_WHITE" for "COL_GOLD"%s"COL_WHITE".", iAmount, g_shopItemData[ i ] [ E_NAME ], cash_format( total_cost ) ); } ShowPlayerDialog( playerid, DIALOG_SHOP_AMOUNT, DIALOG_STYLE_LIST, "{FFFFFF}Shop Items - Buy Quantity", "Buy 1\nBuy 5\nBuy Max", "Select", "Back" ); diff --git a/gamemodes/irresistible/cnr/features/stocks/stocks.pwn b/gamemodes/irresistible/cnr/features/stocks/stocks.pwn index e6716be..9a8065f 100644 --- a/gamemodes/irresistible/cnr/features/stocks/stocks.pwn +++ b/gamemodes/irresistible/cnr/features/stocks/stocks.pwn @@ -24,7 +24,8 @@ /* ** Constants ** */ static const Float: STOCK_MARKET_POOL_FACTOR = 100000.0; // for every STOCK_MARKET_POOL_FACTOR ... STOCK_MARKET_PRICE_FACTOR added to the price -static const Float: STOCK_MARKET_PRICE_FACTOR = 3.5; // for every STOCK_MARKET_POOL_FACTOR ... STOCK_MARKET_PRICE_FACTOR added to the price +static const Float: STOCK_MARKET_PRICE_FACTOR = 3.0; // for every STOCK_MARKET_POOL_FACTOR ... STOCK_MARKET_PRICE_FACTOR added to the price +//static const Float: STOCK_MARKET_PRICE_FLOOR = 20.0; // the price in which the price will always be above or equal to static const Float: STOCK_MARKET_TRADING_FEE = 0.01; // trading fee (buy/sell) percentage as decimal @@ -48,7 +49,11 @@ enum E_STOCK_MARKET_PRICE_DATA enum { E_STOCK_MINING_COMPANY, - E_STOCK_AMMUNATION + E_STOCK_AMMUNATION, + E_STOCK_VEHICLE_DEALERSHIP, + E_STOCK_SUPA_SAVE, + E_STOCK_TRUCKING_COMPANY, + E_STOCK_CLUCKIN_BELL }; static stock @@ -67,8 +72,11 @@ hook OnScriptInit( ) AddServerVariable( "stock_trading_fees", "0.0", GLOBAL_VARTYPE_FLOAT ); // create markets - CreateStockMarket( E_STOCK_MINING_COMPANY, "The Mining Company", "MC", 100000.0, 25.0, 250.0 ); // 25m mcap max + CreateStockMarket( E_STOCK_MINING_COMPANY, "The Mining Company", "MC", 100000.0, 25.0, 500.0 ); // 50m mcap max CreateStockMarket( E_STOCK_AMMUNATION, "Ammu-Nation", "A", 100000.0, 25.0, 250.0 ); // 25m mcap max + CreateStockMarket( E_STOCK_VEHICLE_DEALERSHIP, "Vehicle Dealership", "VD", 100000.0, 100.0, 250.0 ); // 25m mcap max + CreateStockMarket( E_STOCK_TRUCKING_COMPANY, "The Trucking Company", "TC", 100000.0, 50.0, 250.0 ); // 25m mcap max + CreateStockMarket( E_STOCK_CLUCKIN_BELL, "Cluckin' Bell", "CB", 100000.0, 50.0, 250.0 ); // 25m mcap max return 1; } @@ -184,7 +192,7 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) shares; if ( sscanf( inputtext, "d", shares ) ) SendError( playerid, "You must use a valid value." ); - else if ( shares < 10 ) SendError( playerid, "The minimum number of shares you can buy is 10." ); + else if ( shares < 1 ) SendError( playerid, "The minimum number of shares you can buy is 1." ); else { mysql_tquery( dbHandle, sprintf( "SELECT * FROM `STOCK_SELL_ORDERS` WHERE `STOCK_ID`=%d ORDER BY `LIST_DATE` ASC", stockid ), "StockMarket_OnPurchaseOrder", "ddf", playerid, stockid, float( shares ) ); @@ -213,8 +221,6 @@ thread Stock_UpdateReportingPeriods( stockid ) g_stockMarketReportData[ stockid ] [ row ] [ E_SQL_ID ] = cache_get_field_content_int( row, "ID" ); g_stockMarketReportData[ stockid ] [ row ] [ E_POOL ] = cache_get_field_content_float( row, "POOL" ); g_stockMarketReportData[ stockid ] [ row ] [ E_PRICE ] = cache_get_field_content_float( row, "PRICE" ); - - printf("%d %0.0f %0.2f {%d}", stockid, g_stockMarketReportData[ stockid ] [ row ] [ E_POOL ], g_stockMarketReportData[ stockid ] [ row ] [ E_PRICE ], row ); } } else // no historical reporting data, restock the market maker @@ -237,7 +243,7 @@ thread StockMarket_InsertReport( stockid, Float: default_start_pool, Float: defa { // set the new price of the company new // TODO: use parabola for factor difficulty? - Float: new_price = ( g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ] / STOCK_MARKET_POOL_FACTOR) * STOCK_MARKET_PRICE_FACTOR + g_stockMarketData[ stockid ] [ E_IPO_PRICE ]; + Float: new_price = ( g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ] / STOCK_MARKET_POOL_FACTOR) * STOCK_MARKET_PRICE_FACTOR + g_stockMarketData[ stockid ] [ E_IPO_PRICE ]; // STOCK_MARKET_PRICE_FLOOR; if ( new_price > g_stockMarketData[ stockid ] [ E_MAX_PRICE ] ) { // dont want wild market caps new_price = g_stockMarketData[ stockid ] [ E_MAX_PRICE ]; diff --git a/gamemodes/irresistible/cnr/features/vehicles/vdealership.pwn b/gamemodes/irresistible/cnr/features/vehicles/vdealership.pwn index a4000fb..c889355 100644 --- a/gamemodes/irresistible/cnr/features/vehicles/vdealership.pwn +++ b/gamemodes/irresistible/cnr/features/vehicles/vdealership.pwn @@ -360,6 +360,8 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) SetVehicleParamsEx( g_vehicleData[ playerid ] [ bID ] [ E_VEHICLE_ID ], VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective ); PutPlayerInVehicle( playerid, g_vehicleData[ playerid ] [ bID ] [ E_VEHICLE_ID ], 0 ); + StockMarket_UpdateEarnings( E_STOCK_VEHICLE_DEALERSHIP, g_BuyableVehicleData[ data_id ] [ E_PRICE ], 0.05 ); + SendServerMessage( playerid, "You have bought an "COL_GREY"%s"COL_WHITE" for "COL_GOLD"%s"COL_WHITE"!", g_BuyableVehicleData[ data_id ] [ E_NAME ], cash_format( g_BuyableVehicleData[ data_id ] [ E_PRICE ] ) ); ShowPlayerDialog( playerid, DIALOG_BOUGHT_VEH, DIALOG_STYLE_MSGBOX, "{FFFFFF}You've purchased a vehicle!", "{FFFFFF}Glad to see you've purchased a vehicle. Please ensure you read:\n\n* Vehicles are kept until you sell them or go two months inactive. This is not refundable.\n* Do not mispark your vehicle or it can be removed/impounded.\n* Check out /v for vehicle commands.\n* Find an acceptable place to park your new vehicle such as your house or a parking lot.", "Okay", "" ); SetPVarInt( playerid, "bought_veh_ts", g_iTime + 30 ); diff --git a/gamemodes/irresistible/cnr/features/vehicles/vmodifications.pwn b/gamemodes/irresistible/cnr/features/vehicles/vmodifications.pwn index 5c90766..53e2560 100644 --- a/gamemodes/irresistible/cnr/features/vehicles/vmodifications.pwn +++ b/gamemodes/irresistible/cnr/features/vehicles/vmodifications.pwn @@ -405,6 +405,7 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) Float: X, Float: Y, Float: Z; GivePlayerCash( playerid, -g_vehicleComponentsData[ i ] [ E_PRICE ] ); + StockMarket_UpdateEarnings( E_STOCK_VEHICLE_DEALERSHIP, g_vehicleComponentsData[ i ] [ E_PRICE ], 0.05 ); g_vehiclePimpData[ ownerid ] [ vehicleid ] [ E_CREATED ] [ slotid ] = true; g_vehiclePimpData[ ownerid ] [ vehicleid ] [ E_DISABLED ] [ slotid ] = false; diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index 55555f0..9f95f62 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -13,7 +13,7 @@ */ #pragma compat 1 -#pragma option -d3 +//#pragma option -d3 #pragma dynamic 7200000 //#define DEBUG_MODE