Nach langem grübeln und einigen Fehlschlägen tut nun endlich der Börsencrash funktionieren. Für Interessierte hier der entsprechende Code:
Man suche in der funktion_vault.php:
Code: Alles auswählen
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_vault.'.$phpEx);
Code: Alles auswählen
// --- Berechnung von Index und Vergleichswert --- Start ---
$sql = "SELECT avg(stock_price) FROM " . VAULT_EXCHANGE_TABLE . "";
if( !$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain avarade stock_price information', "", __LINE__, __FILE__, $sql);
}
$query = mysql_query($sql);
$array = mysql_fetch_array($query);
$stock_price_avg = $array[0];
$stock_price_avg = round($stock_price_avg * pi(),2);
$sql = "SELECT avg(stock_best_price) FROM " . VAULT_EXCHANGE_TABLE . "";
if( !$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain avarade stock_best_price information', "", __LINE__, __FILE__, $sql);
}
$query = mysql_query($sql);
$array = mysql_fetch_array($query);
$stock_best_price_avg = $array[0];
$stock_best_price_avg = round($stock_best_price_avg * pi(),2);
$sql = "SELECT avg(stock_worst_price) FROM " . VAULT_EXCHANGE_TABLE . "";
if( !$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain avarade stock_worst_price information', "", __LINE__, __FILE__, $sql);
}
$query = mysql_query($sql);
$array = mysql_fetch_array($query);
$stock_worst_price_avg = $array[0];
$stock_wost_price_avg = round($stock_worst_price_avg * pi(),2);
$stock_avg = round($stock_best_price_avg/$stock_worst_price_avg * pi(),2);
// --- Berechnung von Index und Vergleichswert --- Ende ---
suche nach:
Code: Alles auswählen
$sql = "UPDATE " . VAULT_EXCHANGE_TABLE ."
SET stock_price = $new_price ,
stock_previous_price = $old_price ,
stock_best_price = $best_price ,
stock_worst_price = $worst_price
WHERE stock_id = ".$exchange[$i]['stock_id'];
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't update stock exchange", "", __LINE__, __FILE__, $sql);
}
Code: Alles auswählen
// --- Börsencrash - Start ---
if ( $stock_price_avg >= $stock_avg )
{
$variation = mt_rand($vault_general['stock_max_change'] , (2 * $vault_general['stock_max_change']));
$variation = 0 - $variation ;
$new_price = round(($exchange[$i]['stock_price'] * ( 1 + ( $variation / 100 ))), 2);
$old_price = $exchange[$i]['stock_price'];
$best_price = ( $new_price > $exchange[$i]['stock_best_price'] ) ? $new_price : $exchange[$i]['stock_best_price'];
$worst_price = ( $new_price < $exchange[$i]['stock_worst_price'] ) ? $new_price : $exchange[$i]['stock_worst_price'];
$sql = "UPDATE " . VAULT_EXCHANGE_TABLE ."
SET stock_price = $new_price ,
stock_previous_price = $old_price ,
stock_best_price = $best_price ,
stock_worst_price = $worst_price
WHERE stock_id = ".$exchange[$i]['stock_id'];
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't update stock exchange", "", __LINE__, __FILE__, $sql);
}
}
// --- Börsencrash - Ende ---
Code: Alles auswählen
$variation = mt_rand($vault_general['stock_max_change'] , (2 * $vault_general['stock_max_change']));
Bye