Jump to content
MakeWebGames

Need Professional Opinion or Advice.


Joshua

Recommended Posts

Ok, so I'm trying to make a Stock Market intermingle with a Business mod.

I'm wanting the Stock to go UP or Down depending on Members in the Business mod. i.e the more members, the higher the stock goes, very few members the stock goes down. Thinking of sticking this in the Hour Cron and removing the old Stock Cron from the 5 minute for less queries.

My problem is, I think this will work, BUT i'd have to make an Individual Call to EACH business Class and Update Stock accordingly, and I see no way to shorten it :\

So, here's the code, you tell me what you think, if it'll work, if not why :P

 

 <?php
include "config.php";
global $_CONFIG;
if($_GET['code'] != $_CONFIG['code']) { die(""); }
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
global $c;

$db->query("UPDATE users SET hospital=hospital-1 WHERE hospital>0");
$db->query("UPDATE users SET fedjail=0 WHERE user_level=2");
$db->query("UPDATE settings SET conf_value='$jc' WHERE conf_name='jail_count'");
$db->query("UPDATE `users` SET jail=jail-1 WHERE `jail` > 0");
$db->query("UPDATE `users` SET `protection`=MAX('0', `protection`-'1') WHERE `protection` > '0'");
$db->query("UPDATE settings SET conf_value='$hc' WHERE conf_name='hospital_count'");
$hc=$db->num_rows($db->query("SELECT userid FROM users WHERE hospital > 0"));
$jc=$db->num_rows($db->query("SELECT userid FROM users WHERE jail > 0"));


$business = mysql_query("SELECT busId FROM `businesses`");
 while($bus = mysql_fetch_assoc($business))
{
if($bus['busCash'] > 5000000 && $bus['busClass'] == 4)
{
mysql_query("UPDATE `stock_stocks` SET `stockUD` = 1, `stockCHANGE` = 20, `stockNPRICE` = (`stockNPRICE` + 20) WHERE `stockID`= 3);
}
if($bus['busCash'] > 25000000 && $bus['busClass'] == 4)
{
mysql_query("UPDATE `stock_stocks` SET `stockUD` = 1, `stockCHANGE` = 30, `stockNPRICE` = (`stockNPRICE` + 30) WHERE `stockID`= 3);
}
else
{
mysql_query("UPDATE `stock_stocks` SET `stockUD` = 2, `stockCHANGE` = 10, `stockNPRICE` = (`stockNPRICE` - 10) WHERE `stockID`= 3);
}
}
include_once('global_func.php');
$sel = mysql_query("SELECT stockID,stockNAME FROM `stock_stocks` WHERE `stockNPRICE` < 0");
while($soc = mysql_fetch_assoc($sel)) 
 {
  if(mysql_num_rows(mysql_query("SELECT holdingID FROM `stock_holdings` WHERE `holdingSTOCK` = ".$soc['stockID']))) 
 {
     $user = mysql_query("SELECT holdingUSER FROM `stock_holdings` WHERE `holdingSTOCK` = ".$soc['stockID']);
     $user = mysql_fetch_assoc($user);
     event_add($user['holdingUSER'], 'Stock '.$soc['stockNAME'].' crashed, you lost all your shares.');
  }
  mysql_query("DELETE FROM `stock_holdings` WHERE `holdingSTOCK` = ".$soc['stockID']);
  mysql_query("UPDATE `stock_stocks` SET `stockUD` = 1,`stockCHANGE` = 0,`stockNPRICE` = `stockOPRICE` WHERE `stockID` = ".$soc['stockID']);
}



?>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...