jabbic

07-08-2007, 08:14 PM

<?php

require("config.php");

function customers_total($zone_customers, $other_shops) {

global $customers;

/* Randomize the ammount of customers to make it more realistic but still

keep it within 20% of average daily customers. */

$zone = $zone_customers/100*17;

$zoneb = $zone_customers+$zone;

$zonea = $zone_customers-$zone;

$zone_customers = rand($zonea, $zoneb);

/* Work out the ammount of customers the opposition is going to steal */

$other_shops = $other_shops+3;

$yay = $zone_customers/$other_shops;

/* Work out what fraction of the customers the players store is gonna get */

$int_one = $yay;

$int_two = $zone_customers;

$int_three = $int_two/100;

$int_one_s = $int_one/$int_three;

$int_one_s = round($int_one_s, 0);

$fract = $int_one_s;

/* Check if the players store has any marketing. If so increase the chance of the

store getting customers. */

if($marketing > 1) {

$fract = $marketing + $fract;

}

/* Work out the final ammount of customers for the store*/

$customers = $zone_customers/100*$fract;

$customers = round($customers, 0);

}

function customers_buy($price, $sell_price){

global $banter, $chance, $limit, $status,$billy;

$rrp = $price/100*18;

$rrp = $rrp+$price;

$limit = "10.5";

If ($price > 1000) {

$limit = $limit-9.5;

} else if($price > 900){

$limit = $limit-9;

} else if($price > 800){

$limit = $limit-8;

} else if($price > 700){

$limit = $limit-7;

} else if($price > 600){

$limit = $limit-6;

} else if($price > 500){

$limit = $limit-5;

} else if($price > 400){

$limit = $limit-4;

} else if($price > 300){

$limit = $limit-3;

} else if($price > 200){

$limit = $limit-2;

} else if($price > 100){

$limit = $limit-1;

} else if($price > 50){

$limit = $limit;

}

if($sell_price > $rrp) {

$chance = $sell_price-$rrp;

$chance = $chance/$rrp*100;

If ($chance > 100) {

$limit = "0";

} else if($chance > 90){

$limit = $limit-9;

} else if($chance > 80){

$limit = $limit-8;

} else if($chance > 70){

$limit = $limit-7;

} else if($chance > 60){

$limit = $limit-6;

} else if($chance > 50){

$limit = $limit-5;

} else if($chance > 40){

$limit = $limit-4;

} else if($chance > 30){

$limit = $limit-3;

} else if($chance > 20){

$limit = $limit-2;

} else if($chance > 10){

$limit = $limit-1;

} else if($chance > 5){

$limit = $limit;

}

}

if($sell_price < $rrp) {

$chance = $rrp-$sell_price;

$chance = $chance/$rrp*100;

If ($chance > 100) {

$limit = $limit+9.5;

} else if($chance > 90){

$limit = $limit+"9.3";

} else if($chance > 80){

$limit = $limit+9.2;

} else if($chance > 70){

$limit = $limit+8;

} else if($chance > 60){

$limit = $limit+7;

} else if($chance > 50){

$limit = $limit+6;

} else if($chance > 40){

$limit = $limit+5;

} else if($chance > 30){

$limit = $limit+4;

} else if($chance > 20){

$limit = $limit+3;

} else if($chance > 10){

$limit = $limit+2;

} else if($chance > 5){

$limit = $limit+1;

}

}

$pussy = rand(0, 20);

$x = "0";

$limit = round($limit, 0);

while($x < $limit) {

$tither = rand(0, 20);

if ($tither == $pussy) {

return "true";

} else {

return "false";

}

$x++;

}

}

////////Start/////////////

global $poo;

customers_total(1000, 2);

$id = "1";

$result = mysql_query("SELECT * FROM player_products WHERE store_id='$id'");

echo "$customers";

$bah = 0;

$y = 0;

while($bah < $customers)

{

while($row = mysql_fetch_array($result))

{

$price = $row['price'];

$m_price = $row['m_price'];

$id = $row['id'];

$names = $row['names'];

$banter = customers_buy($m_price, $price);

/*

echo "<hr>Chance : $chance<br> Limit: $limit<br> Status: $status<br>Customers: $customers<br>Billy:$y";

*/

if($banter == "true"){

$quan = $row['quantity'];

$quan = $quan-1;

mysql_query("UPDATE player_products SET quantity='$quan' WHERE id='$id'")

or die(mysql_error());

$bee++;

}

$boo++;

}

$bah++;

}

echo "<br>Bah:$bah<br>Bee:$bee<br>Boo:$boo";

?>

I've made this script but there is a problem with the while loops down the bottom. The loop while($row = mysql_fetch_array($result)) is only beeing carried out 15 times when I want it to be carried out 15 x 1000 times. Can anyone help?

require("config.php");

function customers_total($zone_customers, $other_shops) {

global $customers;

/* Randomize the ammount of customers to make it more realistic but still

keep it within 20% of average daily customers. */

$zone = $zone_customers/100*17;

$zoneb = $zone_customers+$zone;

$zonea = $zone_customers-$zone;

$zone_customers = rand($zonea, $zoneb);

/* Work out the ammount of customers the opposition is going to steal */

$other_shops = $other_shops+3;

$yay = $zone_customers/$other_shops;

/* Work out what fraction of the customers the players store is gonna get */

$int_one = $yay;

$int_two = $zone_customers;

$int_three = $int_two/100;

$int_one_s = $int_one/$int_three;

$int_one_s = round($int_one_s, 0);

$fract = $int_one_s;

/* Check if the players store has any marketing. If so increase the chance of the

store getting customers. */

if($marketing > 1) {

$fract = $marketing + $fract;

}

/* Work out the final ammount of customers for the store*/

$customers = $zone_customers/100*$fract;

$customers = round($customers, 0);

}

function customers_buy($price, $sell_price){

global $banter, $chance, $limit, $status,$billy;

$rrp = $price/100*18;

$rrp = $rrp+$price;

$limit = "10.5";

If ($price > 1000) {

$limit = $limit-9.5;

} else if($price > 900){

$limit = $limit-9;

} else if($price > 800){

$limit = $limit-8;

} else if($price > 700){

$limit = $limit-7;

} else if($price > 600){

$limit = $limit-6;

} else if($price > 500){

$limit = $limit-5;

} else if($price > 400){

$limit = $limit-4;

} else if($price > 300){

$limit = $limit-3;

} else if($price > 200){

$limit = $limit-2;

} else if($price > 100){

$limit = $limit-1;

} else if($price > 50){

$limit = $limit;

}

if($sell_price > $rrp) {

$chance = $sell_price-$rrp;

$chance = $chance/$rrp*100;

If ($chance > 100) {

$limit = "0";

} else if($chance > 90){

$limit = $limit-9;

} else if($chance > 80){

$limit = $limit-8;

} else if($chance > 70){

$limit = $limit-7;

} else if($chance > 60){

$limit = $limit-6;

} else if($chance > 50){

$limit = $limit-5;

} else if($chance > 40){

$limit = $limit-4;

} else if($chance > 30){

$limit = $limit-3;

} else if($chance > 20){

$limit = $limit-2;

} else if($chance > 10){

$limit = $limit-1;

} else if($chance > 5){

$limit = $limit;

}

}

if($sell_price < $rrp) {

$chance = $rrp-$sell_price;

$chance = $chance/$rrp*100;

If ($chance > 100) {

$limit = $limit+9.5;

} else if($chance > 90){

$limit = $limit+"9.3";

} else if($chance > 80){

$limit = $limit+9.2;

} else if($chance > 70){

$limit = $limit+8;

} else if($chance > 60){

$limit = $limit+7;

} else if($chance > 50){

$limit = $limit+6;

} else if($chance > 40){

$limit = $limit+5;

} else if($chance > 30){

$limit = $limit+4;

} else if($chance > 20){

$limit = $limit+3;

} else if($chance > 10){

$limit = $limit+2;

} else if($chance > 5){

$limit = $limit+1;

}

}

$pussy = rand(0, 20);

$x = "0";

$limit = round($limit, 0);

while($x < $limit) {

$tither = rand(0, 20);

if ($tither == $pussy) {

return "true";

} else {

return "false";

}

$x++;

}

}

////////Start/////////////

global $poo;

customers_total(1000, 2);

$id = "1";

$result = mysql_query("SELECT * FROM player_products WHERE store_id='$id'");

echo "$customers";

$bah = 0;

$y = 0;

while($bah < $customers)

{

while($row = mysql_fetch_array($result))

{

$price = $row['price'];

$m_price = $row['m_price'];

$id = $row['id'];

$names = $row['names'];

$banter = customers_buy($m_price, $price);

/*

echo "<hr>Chance : $chance<br> Limit: $limit<br> Status: $status<br>Customers: $customers<br>Billy:$y";

*/

if($banter == "true"){

$quan = $row['quantity'];

$quan = $quan-1;

mysql_query("UPDATE player_products SET quantity='$quan' WHERE id='$id'")

or die(mysql_error());

$bee++;

}

$boo++;

}

$bah++;

}

echo "<br>Bah:$bah<br>Bee:$bee<br>Boo:$boo";

?>

I've made this script but there is a problem with the while loops down the bottom. The loop while($row = mysql_fetch_array($result)) is only beeing carried out 15 times when I want it to be carried out 15 x 1000 times. Can anyone help?