Jump to content

Recommended Posts

OK I have a market game, what I want to try to do is. set it so that depending on how many players are playing a how many factories there are the amount the market can fluctuate.

 

IE. if i have 10 players with 10 steak houses making 100 steaks. the price would start at 50 but go down every time someone sells.

 

but to increase "boost the market" there are drugs factorys which have a static price ie 10. so if someone sold 10000 that would boost the market depending on the ammount of steaks and people making them.

 

the code i have is

 


<?php
print "<form method=post action=cmarket.php?view=sell&step=sell>Sell <input name=amount><select name=seller><option value=drugs>Drugs</option><option value=steak>Steaks</option></select>. <input type=submit value=Sell></form>";
if (isset($_POST)){
switch($_POST['seller'])
{
	case "drugs":
		if ($stat['drugs'] < $amount) {
			print "Sorry mate, you don't have the drugs.";
		} else {
			mysql_query("update players set drugs=(drugs-$amount) where id=".$stat[id]);
			mysql_query("update players set credits=credits+($amount*".$stat['drugprice'].") where id=".$stat['id']);
			print "You sold $amount of drugs."; 
			}
			break;
					case "steak":
		if ($stat['steaks'] < $amount) {
			print "Sorry mate, you don't have the steaks.";
		} else {
			mysql_query("update players set steaks=(steaks-$amount) where id=".$stat[id]);
			mysql_query("update players set credits=credits+($amount*".$stat['steakprice'].") where id=".$stat['id']);
			print "You sold $amount of steaks."; 
			}

}
}
?></div></td>
  </tr>
</table>
<table width=100% cellpadding=2 cellspacing=0 style="width:100%;height:95%;margin-top:10px;border:1px solid #5B84A4;">
<tr height=25 bgcolor=#0F354C><td width=25%><b>Rank </td>
  <td width=24%><b>Stock</td> 
<td width=14%><b>Last Payout</td> 
<td width=21%><b>Selling Price </td>
</tr>

<tr height=20 bgcolor=#0F354C>
  <td>Drugs</td>
  <td><? print"$stat[drugs]"; ?></td>
  <td><? print"$stat[dpayout]"; ?></td>
  <td><? print"$stat[drugprice]"; ?></td>
</tr>
<tr height=20 bgcolor=#0F354C>
  <td>Steaks</td>
  <td><? print"$stat[steaks]"; ?></td>
  <td><? print"$stat[spayout]"; ?></td>
  <td><? print"$stat[steakprice]"; ?></td>
</tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/74846-fluctuation/
Share on other sites

Why would the price of steak go down as people sell? Surely the principle of suppy and demand would suggest that the less steaks there are, the more they are worth (assuming, of course, demand remains constant?)

 

Anyways, aside from that, this can be as simple or as complex as you like. At a basic level, you could 'count up' the amount of steaks available, and base the price on this, making adjustments if certain criteria are met with regard to drug availablity.

 

P.S. I'd love to know what drugs and steak have got to do with each other!

Link to comment
https://forums.phpfreaks.com/topic/74846-fluctuation/#findComment-378454
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.