add pilot stock
This commit is contained in:
parent
5ed2066e42
commit
ec431ad43a
@ -172,9 +172,8 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid )
|
||||
|
||||
else if ( p_PilotRoute[ playerid ] { 1 } != INVALID_PILOT_ROUTE )
|
||||
{
|
||||
|
||||
new
|
||||
cash_earned = floatround( ( p_PilotDistance[ playerid ] + PILOT_BONUS ) * Pilot_GetPlaneModelBonus( p_PilotVehicle[ playerid ] ) );
|
||||
new Float: stock_dividend_allocation = 0.25;
|
||||
new cash_earned = floatround( ( p_PilotDistance[ playerid ] + PILOT_BONUS ) * Pilot_GetPlaneModelBonus( p_PilotVehicle[ playerid ] ) * ( 1.0 - stock_dividend_allocation ) );
|
||||
|
||||
if ( p_PilotDifficulty[ playerid ] != RISK_FACTOR_EASY ) {
|
||||
cash_earned *= 2;
|
||||
@ -184,6 +183,7 @@ hook OnPlayerEnterDynRaceCP( playerid, checkpointid )
|
||||
ach_HandlePilotMissions( playerid );
|
||||
|
||||
GivePlayerScore( playerid, 1 + floatround( p_PilotDistance[ playerid ] / 1000.0 ) );
|
||||
StockMarket_UpdateEarnings( E_STOCK_AVIATION, cash_earned, stock_dividend_allocation );
|
||||
GivePlayerCash( playerid, cash_earned );
|
||||
|
||||
ShowPlayerHelpDialog( playerid, 5000, "You have earned ~y~%s ~w~for exporting %s!", cash_format( cash_earned ), g_CargoName[ p_PilotCargo[ playerid ] ] );
|
||||
@ -329,13 +329,13 @@ CMD:pilot( playerid, params[ ] )
|
||||
if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "You must be an ordinary civilian to use this command." );
|
||||
else if ( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendError( playerid, "You must be a driver of a vehicle to work." );
|
||||
else if ( !iVehicle ) return SendError( playerid, "You are not in any vehicle." );
|
||||
else if ( sscanf( params, "S(normal)[7]", szDifficulty ) ) return SendUsage( playerid, "/pilot [NORMAL/HARDER/STOP]" );
|
||||
else if ( sscanf( params, "s[7]", szDifficulty ) ) return SendUsage( playerid, "/pilot [NORMAL/HARD/STOP]" );
|
||||
else if ( strmatch( szDifficulty, "stop" ))
|
||||
{
|
||||
StopPlayerPilotWork( playerid );
|
||||
return SendServerMessage( playerid, "Your pilot mission has been stopped." );
|
||||
}
|
||||
else if ( strmatch( szDifficulty, "normal" ) || strmatch( szDifficulty, "harder" ))
|
||||
else if ( strmatch( szDifficulty, "normal" ) || strmatch( szDifficulty, "hard" ))
|
||||
{
|
||||
if ( Pilot_IsExportableVehicle( iVehicle ) )
|
||||
{
|
||||
@ -350,7 +350,7 @@ CMD:pilot( playerid, params[ ] )
|
||||
p_hasPilotJob { playerid } = true;
|
||||
p_WorkCooldown [ playerid ] = g_iTime + 60;
|
||||
p_PilotVehicle [ playerid ] = GetPlayerVehicleID( playerid );
|
||||
p_PilotDifficulty [ playerid ] = ( strmatch( szDifficulty, "harder" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY );
|
||||
p_PilotDifficulty [ playerid ] = ( strmatch( szDifficulty, "hard" ) ? RISK_FACTOR_HARD : RISK_FACTOR_EASY );
|
||||
|
||||
p_PilotCargo [ playerid ] = random( sizeof( g_CargoName ) );
|
||||
p_PilotRoute [ playerid ] { 0 } = random ( sizeof ( g_AirportLocations ) );
|
||||
|
@ -62,7 +62,8 @@ enum
|
||||
E_STOCK_CLUCKIN_BELL,
|
||||
E_STOCK_PAWN_STORE,
|
||||
E_STOCK_CASINO,
|
||||
E_STOCK_GOVERNMENT
|
||||
E_STOCK_GOVERNMENT,
|
||||
E_STOCK_AVIATION
|
||||
};
|
||||
|
||||
static stock
|
||||
@ -86,11 +87,12 @@ hook OnScriptInit( )
|
||||
CreateStockMarket( E_STOCK_AMMUNATION, "Ammu-Nation", "A", 100000.0, 25.0, 250.0, 100000.0, 10.0, "Purchases at Ammu-Nation/Weapon Dealers/Facilities" );
|
||||
CreateStockMarket( E_STOCK_VEHICLE_DEALERSHIP, "Vehicle Dealership", "VD", 100000.0, 25.0, 250.0, 100000.0, 20.0, "Car jacker exports, vehicle and component sales" );
|
||||
CreateStockMarket( E_STOCK_SUPA_SAVE, "Supa-Save", "SS", 100000.0, 25.0, 250.0, 100000.0, 10.0, "Purchases at Supa-Save and 24/7" );
|
||||
CreateStockMarket( E_STOCK_TRUCKING_COMPANY, "The Trucking Company", "TC", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Completed trucking transits" );
|
||||
CreateStockMarket( E_STOCK_TRUCKING_COMPANY, "The Trucking Company", "TC", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Completed trucking missions" );
|
||||
CreateStockMarket( E_STOCK_CLUCKIN_BELL, "Cluckin' Bell", "CB", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Exporting meth bags" );
|
||||
CreateStockMarket( E_STOCK_PAWN_STORE, "Pawn Store", "PS", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Exported stolen furniture and toy sales" );
|
||||
CreateStockMarket( E_STOCK_CASINO, "Casino", "CAS", 100000.0, 990.0, 5000.0, 100000.0, 150.0, "Money lost by players gambling" );
|
||||
CreateStockMarket( E_STOCK_GOVERNMENT, "Government", "GOV", 100000.0, 750.0, 5000.0, 100000.0, 150.0, "Fireman and LEO activities" );
|
||||
CreateStockMarket( E_STOCK_AVIATION, "Elitas Travel", "ET", 100000.0, 50.0, 250.0, 100000.0, 20.0, "Completed pilot missions" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -342,12 +344,9 @@ thread Stock_UpdateReportingPeriods( stockid )
|
||||
}
|
||||
else // no historical reporting data, restock the market maker
|
||||
{
|
||||
// set current stock market prices to IPO
|
||||
g_stockMarketReportData[ stockid ] [ 1 ] [ E_PRICE ] = g_stockMarketData[ stockid ] [ E_IPO_PRICE ];
|
||||
|
||||
// create 2 reports for the company using the IPO price ... this way the price is not $0
|
||||
// create 3 reports for the company using the IPO price ... this way the price is not $0
|
||||
for ( new i = 0; i < 3; i ++ ) {
|
||||
StockMarket_ReleaseDividends( stockid );
|
||||
StockMarket_ReleaseDividends( stockid, .is_ipo = true );
|
||||
}
|
||||
|
||||
// put market maker shares on the market
|
||||
@ -356,7 +355,7 @@ thread Stock_UpdateReportingPeriods( stockid )
|
||||
return 1;
|
||||
}
|
||||
|
||||
thread StockMarket_InsertReport( stockid, Float: default_start_pool, Float: default_start_price, Float: default_donation_pool )
|
||||
thread StockMarket_InsertReport( stockid, Float: default_start_pool, Float: default_start_price, Float: default_donation_pool, bool: is_ipo )
|
||||
{
|
||||
// set the new price of the company [TODO: use parabola for factor difficulty?]
|
||||
new Float: new_price = ( g_stockMarketReportData[ stockid ] [ 0 ] [ E_POOL ] / g_stockMarketData[ stockid ] [ E_POOL_FACTOR ] ) * g_stockMarketData[ stockid ] [ E_PRICE_FACTOR ] + STOCK_MARKET_PRICE_FLOOR;
|
||||
@ -374,6 +373,11 @@ thread StockMarket_InsertReport( stockid, Float: default_start_pool, Float: defa
|
||||
new_price = STOCK_MARKET_PRICE_FLOOR;
|
||||
}
|
||||
|
||||
// check if its an ipo... if it is then set to ipo price
|
||||
if ( is_ipo ) {
|
||||
new_price = g_stockMarketData[ stockid ] [ E_IPO_PRICE ];
|
||||
}
|
||||
|
||||
// set the new price of the asset
|
||||
g_stockMarketReportData[ stockid ] [ 0 ] [ E_PRICE ] = new_price;
|
||||
mysql_single_query( sprintf( "UPDATE `STOCK_REPORTS` SET `PRICE` = %f WHERE `ID` = %d", g_stockMarketReportData[ stockid ] [ 0 ] [ E_PRICE ], g_stockMarketReportData[ stockid ] [ 0 ] [ E_SQL_ID ] ) );
|
||||
@ -562,7 +566,7 @@ thread StockMarket_OnShowShares( playerid )
|
||||
return ShowPlayerDialog( playerid, DIALOG_PLAYER_STOCKS, DIALOG_STYLE_TABLIST_HEADERS, ""COL_WHITE"Stock Market", szLargeString, "Select", "Close" ), 1;
|
||||
}
|
||||
|
||||
thread Stock_OnDividendPayout( stockid )
|
||||
thread Stock_OnDividendPayout( stockid, bool: is_ipo )
|
||||
{
|
||||
new
|
||||
rows = cache_get_row_count( );
|
||||
@ -599,7 +603,7 @@ thread Stock_OnDividendPayout( stockid )
|
||||
|
||||
// insert to database a new report
|
||||
mysql_format( dbHandle, szBigString, sizeof ( szBigString ), "INSERT INTO `STOCK_REPORTS` (`STOCK_ID`, `POOL`, `DONATIONS`, `PRICE`) VALUES (%d, %f, %f, %f)", stockid, STOCK_DEFAULT_START_POOL, STOCK_DEFAULT_START_DONATIONS, STOCK_DEFAULT_START_PRICE );
|
||||
mysql_tquery( dbHandle, szBigString, "StockMarket_InsertReport", "dfff", stockid, STOCK_DEFAULT_START_POOL, STOCK_DEFAULT_START_DONATIONS, STOCK_DEFAULT_START_PRICE );
|
||||
mysql_tquery( dbHandle, szBigString, "StockMarket_InsertReport", "dfffd", stockid, STOCK_DEFAULT_START_POOL, STOCK_DEFAULT_START_DONATIONS, STOCK_DEFAULT_START_PRICE, bool: is_ipo );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -764,10 +768,10 @@ static stock CreateStockMarket( stockid, const name[ 64 ], const symbol[ 4 ], Fl
|
||||
return stockid;
|
||||
}
|
||||
|
||||
static stock StockMarket_ReleaseDividends( stockid )
|
||||
static stock StockMarket_ReleaseDividends( stockid, bool: is_ipo = false )
|
||||
{
|
||||
mysql_format( dbHandle, szBigString, sizeof ( szBigString ), "SELECT * FROM `STOCK_OWNERS` WHERE `STOCK_ID`=%d", stockid );
|
||||
mysql_tquery( dbHandle, szBigString, "Stock_OnDividendPayout", "d", stockid );
|
||||
mysql_tquery( dbHandle, szBigString, "Stock_OnDividendPayout", "dd", stockid, is_ipo );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
//#pragma option -d3
|
||||
#pragma dynamic 7200000
|
||||
|
||||
//#define DEBUG_MODE
|
||||
#define DEBUG_MODE
|
||||
|
||||
#if defined DEBUG_MODE
|
||||
#pragma option -d3
|
||||
@ -9819,9 +9819,12 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
}
|
||||
if ( dialogid == DIALOG_AIRPORT && response )
|
||||
{
|
||||
static const
|
||||
AIR_TRAVEL_COST = 2000;
|
||||
|
||||
if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot travel while you're in jail." );
|
||||
if ( p_WantedLevel[ playerid ] ) return SendError( playerid, "You cannot travel while you are wanted." );
|
||||
if ( GetPlayerCash( playerid ) < 2000 ) return SendError( playerid, "You need $2,000 to travel between cities." );
|
||||
if ( GetPlayerCash( playerid ) < AIR_TRAVEL_COST ) return SendError( playerid, "You need %s to travel between cities.", cash_format( AIR_TRAVEL_COST ) );
|
||||
|
||||
new bool: using_rewards = p_CasinoRewardsPoints[ playerid ] > 5.0;
|
||||
|
||||
@ -9830,17 +9833,17 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
{
|
||||
case 0: {
|
||||
if ( IsPlayerInDynamicCP( playerid, g_Checkpoints[ CP_AIRPORT_SF ] ) ) return SendError( playerid, "You're already in San Fierro." );
|
||||
SendServerMessage( playerid, "It has cost you "COL_GOLD"%s"COL_WHITE" to travel. Welcome to San Fierro!", using_rewards ? ( "5 casino reward points" ) : ( "$2,000" ) );
|
||||
SendServerMessage( playerid, "It has cost you "COL_GOLD"%s"COL_WHITE" to travel. Welcome to San Fierro!", using_rewards ? ( "5 casino reward points" ) : ( cash_format( AIR_TRAVEL_COST ) ) );
|
||||
SetPlayerPos( playerid, -1422.4063, -286.5081, 14.1484 );
|
||||
}
|
||||
case 1: {
|
||||
if ( IsPlayerInDynamicCP( playerid, g_Checkpoints[ CP_AIRPORT_LV ] ) ) return SendError( playerid, "You're already in Las Venturas." );
|
||||
SendServerMessage( playerid, "It has cost you "COL_GOLD"%s"COL_WHITE" to travel. Welcome to Las Venturas!", using_rewards ? ( "5 casino reward points" ) : ( "$2,000" ) );
|
||||
SendServerMessage( playerid, "It has cost you "COL_GOLD"%s"COL_WHITE" to travel. Welcome to Las Venturas!", using_rewards ? ( "5 casino reward points" ) : ( cash_format( AIR_TRAVEL_COST ) ) );
|
||||
SetPlayerPos( playerid, 1672.5364, 1447.8616, 10.7881 );
|
||||
}
|
||||
case 2: {
|
||||
if ( IsPlayerInDynamicCP( playerid, g_Checkpoints[ CP_AIRPORT_LS ] ) ) return SendError( playerid, "You're already in Los Santos." );
|
||||
SendServerMessage( playerid, "It has cost you "COL_GOLD"%s"COL_WHITE" to travel. Welcome to Los Santos!", using_rewards ? ( "5 casino reward points" ) : ( "$2,000" ) );
|
||||
SendServerMessage( playerid, "It has cost you "COL_GOLD"%s"COL_WHITE" to travel. Welcome to Los Santos!", using_rewards ? ( "5 casino reward points" ) : ( cash_format( AIR_TRAVEL_COST ) ) );
|
||||
SetPlayerPos( playerid, 1642.2274, -2335.4978, 13.5469 );
|
||||
}
|
||||
}
|
||||
@ -9850,7 +9853,11 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
p_CasinoRewardsPoints[ playerid ] -= 5.0;
|
||||
mysql_single_query( sprintf( "UPDATE `USERS` SET `CASINO_REWARDS`=%f WHERE `ID`=%d", p_CasinoRewardsPoints[ playerid ], p_AccountID[ playerid ] ) );
|
||||
}
|
||||
else GivePlayerCash( playerid, -2000 );
|
||||
else
|
||||
{
|
||||
StockMarket_UpdateEarnings( E_STOCK_AVIATION, AIR_TRAVEL_COST, 0.5 );
|
||||
GivePlayerCash( playerid, -AIR_TRAVEL_COST );
|
||||
}
|
||||
|
||||
// set interior/world
|
||||
SetPlayerVirtualWorld( playerid, 0 );
|
||||
|
Loading…
Reference in New Issue
Block a user