Jump to content
MakeWebGames

Recommended Posts

Posted

hi ive made the cron for my drugs mod but it doesnt seem to be doing what i want it todo

if you could point me in the right direction if its wrong id be most gratful

<?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;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}

#used to produce the drugs
$q=$db->query("SELECT grow,druglab FROM drugs");

while($r=$db->fetch_row($q))
{
$lab = $r['druglab'];
$amnt = 10;
$gained = ($lab * $amnt);

$inv=$db->query(sprintf("SELECT * FROM drugs_inv WHERE dinv_userid = %d AND (dinv_drugid = %d)", $ir['userid'], $r['grow']));
if($db->num_rows($inv) == 0)
{
$db->query("INSERT INTO drugs_inv (dinv_id, dinv_userid, dinv_drugis, dinv_qty) VALUES ('', $ir['userid'], $r['grow'], {$gained})");
}
else
{
$db->query("UPDATE drugs_inv SET dinv_qty = dinv_qty + {$gained} WHERE dinv_drugid = {$r['grow=']}");
}
}

#This is for the streets
$drug=$db->query("SELECT drug_id FROM drugs_drugs");
$d=$db->fetch_row($drug);
$price=$db->query(sprintf("SELECT buy,stock_price FROM drugs_streets WHERE (drug_id = %d)", $d['drug_id']));
$b=$db->fetch_row($price);

if($b['buy'] <= 0)
{
$db->query(sprintf("UPDATE drugs_streets SET buy = %d WHERE (drug_id = %d)", $b['stock_price'], $d['drug_id']));
}
else
{
	$buy = $db->query("SELECT drug_id FROM `drugs_drugs`");
while($price = $db->fetch_row($buy))	
{
$rand = mt_rand(1,2);
if($rand == 2)
{
   	$mr = mt_rand(1,50);
	$db->query(sprintf("UPDATE drugs_streets SET buy = buy + %d WHERE (drug_id = %d)", $mr, $price['drug_id']));

}
else
{
   	$mr = mt_rand(50,100);
	$db->query(sprintf("UPDATE drugs_streets SET buy = buy + %d WHERE (drug_id = %d)", $mr, $price['drug_id']));
}
}
}
?>

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...