Jump to content
MakeWebGames

Please help...


War_Hero
 Share

Recommended Posts

Hi all.

I'm creating a mod for my brother's game and I'm having a bit of trouble with it.

Brief Description: The mod will allow the Donation Fund President to buy medical equipment and chemicals to cure a disease. The cost of each item will be deducted from the donation fund.

My Problem: I've tried to code it so that the President can't buy more than one of the same item at a time and they have to buy medical equipment before they can produce medicine. However, I can buy multiple Chemical 1's (one of the medical items). And even if I buy the Medical Equipment (another item), I can't access the Produce Medicine bit.

I'll post the two functions that contain these problems. I'm not experiencing any errors, just what I explained above.

President Page function:

function pres_itemsbuy()
{
global $db,$ir,$h,$c,$userid;

$_GET['ID'] = abs((int) $_GET['ID']);
$q = ("SELECT * FROM `items` WHERE `itmid` = {$_GET['ID']}");
$itemd = ($db->query($q));

$sql1 = ("SELECT * FROM `researchitems`");
$query1 = $db->query($sql1);
$row1 = $db->fetch_row($query1);

$qq = $db->query(sprintf("SELECT * FROM `items` WHERE `itmid` = '%d'",
						 $_GET['ID']));

while($r = $db->fetch_row($itemd))
{
	$price = ($r['itmbuyprice']);

	if($ir['fundpres'] == 0)
	{
		die("You need to be President of the Research Fund to buy items. <a href = 'index.php' />Go Home</a>");
	}

	if(mysql_num_rows($qq) == 0)
	{
		die("Invalid item ID");
	}

	elseif($_GET['ID'] == $row1['itemID'])
	{
		print "You have already purchased this item. <a href = 'researchfund.php?action=prespage' />Go Back</a>";
		$h->endpage();
		exit;
	}

	elseif($row1['totalfund'] < $r['itmbuyprice'])
	{
		print "There is not enough money in the Research Fund to buy this item. <a href = 'researchfund.php?action=prespage' />Go Back</a>";
		$h->endpage();
		exit;
	}

	else
	{
		$u = sprintf("UPDATE `researchitems` SET `totalfund` = `totalfund` - '%d'",
					   $price);

		$db->query($u);

		$u2 = sprintf("INSERT INTO `researchitems` (ID, itemID, itemPRICE) VALUES (%d, %d, %d)",
					  '', $_GET['ID'], $r['itmbuyprice']);

		$db->query($u2);

		print "You purchased {$r['itmname']} for £".money_formatter($price,'').". <a href = 'researchfund.php?action=prespage' />Click here to return</a>";
	}
}
}

 

And the Produce Medicine function:

function med_create()
{
global $db,$ir,$userid;

$select = ("SELECT * FROM `researchitems`");
$qselect = $db->query($select);
$rowselect = $db->fetch_row($qselect);

if($rowselect['itemID'] != 105)
{
	die("You don't have the correct medical equipment to produce medicine. You need to buy the equipment first. <a href = 'researchfund.php' />Return to Research Fund</a>");
}

elseif($rowselect['itemID'] != 96 OR $rowselect['itemID'] != 97 OR $rowselect['itemID'] != 98 OR $rowselect['itemID'] != 99 OR $rowselect['itemID'] != 100 OR $rowselect['itemID'] != 101)
{
	die("You don't have any chemicals or substances to produce any medicine. <a href = 'researchfund.php' />Return to Research Fund</a>");
}

elseif($rowselect['itemID'] == 96 AND $rowselect['itemID'] == 97)
{
	print "<form action = 'researchfund.php?action=medcreate1' />
	<input type = 'submit' value = 'Produce Medicine 1' /> </form>";
}

elseif($rowselect['itemID'] == 98 AND $rowselect['itemID'] == 99)
{
	print "<form action = 'researchfund.php?action=medcreate2' />
	<input type = 'submit' value = 'Produce Medicine 2' /> </form>";
}

elseif($rowselect['itemID'] == 100 AND $rowselect['itemID'] == 101)
{
	print "<form action = researchfund.php?action=medcreate3' />
	<input type = 'submit' value = 'Produce Medicine 3' /> </form>";
}

else
{
	print "Either you've produced all of the medicine or you don't have the correct chemicals or substances. <a href = 'research.php' />Return to Research Fund</a>";
}
}

 

I also have functions to create 3 types of medicine, but I can't test them until I fix this, so I may experience some problems with those too.

Please note that I am still a newbie coder and any help will be highly appreciated. :)

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.

 Share

×
×
  • Create New...