好的,所以这个文件每 15 分钟运行一次,在这些阶段你会获得收入、农业和能源奖励,但我不希望他们超过 $storagecap,但他们不会停止,他们会继续添加越来越多的食物、黄金、能量到您的帐户,永不停止。
我想要做的是增加你的收入,然后如果你的收入超过 $storagecap 把你的黄金放到 $storagecap 但它在这里不起作用是我的代码
<?php
include("functions.php");
connect();
include("user_stats.php");
?>
<?php
if(isset($_SESSION['uid'])){
include("safe.php");
include("storagecap.php");?>
<?php
$get_users = mysql_query("SELECT * FROM `stats`") or die(mysql_error());
while($user = mysql_fetch_assoc($get_users)) {
//Get
$gold = $user["gold"];
$food = $user["food"];
$energy = $user["energy"];
//Increment
$gold += $user["income"];
$food += $user["farming"];
$energy += 5;
//Verify and correct
if($energy > 100)
$energy = 100;
if($gold > $storagecap)
$gold = $storagecap;
if($food > $storagecap)
$food = $storagecap;
//Submit
$update = mysql_query("UPDATE `stats` SET
`gold`= '".$gold."',
`food`= '".$food."',
`energy`= '".$energy."' WHERE `id`='".$user['id']."'") or die(mysql_error());
}
?>