I can share ideas with you, I've already developed a system like that but with a marketplace interaction built-in. I mean that the script try to find out the marketplace max price of the server and divide it by the number of items present in the players inventory, the code exclude too the staff members, finaly this give a price in credits and gold bars too.
Code:
<?php
$sql = "SELECT id,furni_id,furni_name,release_date,start_price,image_name,category,in_sale FROM actions WHERE category = 'Catalog Actions'";
$marketplace_price = mysql_query("SELECT MaxMarketPlacePrice FROM server_settings");
$max_price = mysql_fetch_assoc($marketplace_price);
$result = mysql_query($sql) OR die(mysql_error());
if (mysql_num_rows($result)) {
$oe = 1;
while ($row = mysql_fetch_assoc($result)) {
$actionid = $row['id'];
if ($row['category'] = "Catalog Actions")
if ($oe == 2) {
$oe = 1;
} else {
$oe = 2;
}
$furni_number = mysql_evaluate("SELECT COUNT(*) FROM items WHERE base_item = " . $row['furni_id'] . " AND user_id NOT IN (1)");
if ($furni_number == 0) {
$furni_number = '0';
$final_value = '0';
$gb_value = '0';
} else {
$value = $max_price/$furni_number;
$final_value = number_format($value);
$pre_gb_value = $value/500;
$gb_value = number_format($pre_gb_value);
}
(I've replaced the * in the first sql query by all tables number to give you the table structure for the script)
You need to add this function to global.php in order to get the mysql_evaluate function working:
Code:
function mysql_evaluate($query, $default_value="undefined")
{
$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result) < 1){
return $default_value;
} else {
return mysql_result($result, 0);
}
}