add veh dealership, trucking company, cluckin bell stocks

This commit is contained in:
Lorenc Pekaj 2018-11-03 16:06:58 +11:00
parent 89bc99d7d5
commit 6e54f16ed6
9 changed files with 30 additions and 17 deletions

View File

@ -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"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@
*/
#pragma compat 1
#pragma option -d3
//#pragma option -d3
#pragma dynamic 7200000
//#define DEBUG_MODE