本帖最后由 我是来注册的啊 于 2009-11-3 14:03 编辑
说明:买草放入背包,实时扣钱加草,实时显示扣钱,但是不实时显示背包里的草。
刷新出背包里新买的草的方法:给自己或好友的食物筐加草一次即可(几颗都行)
最后更新:2009.11.2 19:57
找到:
if ( $_REQUEST['mod'] == "cgi_feed_food" )
{
接下来应该是:
if ( $_REQUEST['type'] == "1" )
{
echo "{\"errorContent\":\"\\u8D2D\\u4E70\\u7267\\u8349\\u7684\\u529F\\u80FD\\u6682\\u65F6\\u4E0D\\u5F00\\u653E\\uFF0C\\u8BF7\\u53BB\\u519C\\u573A\\u79CD\\u690D\\u7267\\u8349\\uFF01\",\"errorType\":\"1011\"}";
exit( );
}
如果你打过所谓的买草补丁,则是这样的:
/*if ( $_REQUEST['type'] == "1" )
{
echo "{\"errorContent\":\"\\u8D2D\\u4E70\\u7267\\u8349\\u7684\\u529F\\u80FD\\u6682\\u65F6\\u4E0D\\u5F00\\u653E\\uFF0C\\u8BF7\\u53BB\\u519C\\u573A\\u79CD\\u690D\\u7267\\u8349\\uFF01\",\"errorType\":\"1011\"}";
exit( );
}*/
这哪是打补丁?这是连买草的代码直接注释掉了。
================================================
将找到的上面这段代码(IF那个过程),替换为能用的买草代码如下:
if ( $_REQUEST['type'] == "1" )
{
//echo "{\"errorContent\":\"\\u8D2D\\u4E70\\u7267\\u8349\\u7684\\u529F\\u80FD\\u6682\\u65F6\\u4E0D\\u5F00\\u653E\\uFF0C\\u8BF7\\u53BB\\u519C\\u573A\\u79CD\\u690D\\u7267\\u8349\\uFF01\",\"errorType\":\"1011\"}";
$mc_price = 60;
$mc_id = 40;
$fruit = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT fruit FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] ), 0 );
$fruit = json_decode( $fruit );
$money = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT money FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] ), 0 );
if ( $money < $mc_price * $_REQUEST['foodnum'] ){
echo "{\"errorContent\":\"\\u4F60\\u7684\\u91D1\\u5E01\\u4E0D\\u8DB3\\uFF0C\\u8D2D\\u4E70".$_REQUEST['foodnum']."\\u68F5\\u7267\\u8349\\uFF0C\\u5171\\u9700\\u8981".($mc_price * $_REQUEST['foodnum'])."\\u4E2A\\u91D1\\u5E01\\u3002\",\"errorType\":\"1011\"}";
exit();
}
$fruit->$mc_id = $fruit->$mc_id + $_REQUEST['foodnum'];
$fruit = json_encode( $fruit );
$money = $money - ($mc_price * $_REQUEST['foodnum']);
$money < 0 && $money = 0;
$mc_exps = $_REQUEST['foodnum'] / 5;
$mc_exps > 5 && $mc_exps = 5;
$_SGLOBAL['db']->query("UPDATE ".tname( "plug_newfarm" )." set fruit='".$fruit."',money=".$money.",mc_exp=mc_exp+'".$mc_exps."' where uid=".$_SGLOBAL['supe_uid'] );
$query = $_SGLOBAL['db']->query( "SELECT animal FROM ".tname( "plug_newfarm" )." where uid=".intval( $_SGLOBAL['supe_uid'] ) );
while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
{
$list[] = $value;
}
$animal = ( array )json_decode( $list[0]['animal'] );
foreach ( $animal['animal'] as $key => $value )
{
if ( 0 < $value->cId ) {
if ( $value->postTime == 0 )
{
$time = $_SGLOBAL['timestamp'] - $value->buyTime;
if ( $animaltime[$value->cId][0] + $animaltime[$value->cId][1] <= $time )
{
$status = 3;
$growTimeNext = 12993;
$statusNext = 6;
}
if ( $animaltime[$value->cId][0] <= $time && $time < $animaltime[$value->cId][0] + $animaltime[$value->cId][1] )
{
$status = 2;
$growTimeNext = $animaltime[$value->cId][0] + $animaltime[$value->cId][1] - $time;
$statusNext = 3;
}
if ( $time < $animaltime[$value->cId][0] )
{
$status = 1;
$growTimeNext = $animaltime[$value->cId][0] - $time;
$statusNext = 2;
}
if ( $animaltime[$value->cId][5] < $time )
{
$status = 6;
$growTimeNext = 0;
$statusNext = 6;
}
$newanimal[] = "{\"buyTime\":".$value->buyTime.",\"cId\":".$value->cId.",\"growTime\":".$time.",\"growTimeNext\":".$growTimeNext.",\"hungry\":0,\"serial\":".$key.",\"status\":".$status.",\"statusNext\":".$statusNext.",\"totalCome\":".$value->totalCome."}";
}
else
{
$totalCome = $value->totalCome;
$time = $_SGLOBAL['timestamp'] - $value->buyTime;
if ( $animaltime[$value->cId][5] < $time )
{
$status = 6;
$statusNext = 6;
$growTimeNext = 0;
}
if ( $animaltime[$value->cId][4] < $_SGLOBAL['timestamp'] - $value->postTime )
{
$status = 3;
$statusNext = 6;
$growTimeNext = 12993;
}
if ( $_SGLOBAL['timestamp'] - $value->postTime <= $animaltime[$value->cId][4] )
{
$status = 5;
$statusNext = 3;
$growTimeNext = $animaltime[$value->cId][4] - ( $_SGLOBAL['timestamp'] - $value->postTime );
}
if ( $_SGLOBAL['timestamp'] - $value->postTime <= $animaltime[$value->cId][3] )
{
$status = 4;
$statusNext = 5;
$growTimeNext = $animaltime[$value->cId][3] - ( $_SGLOBAL['timestamp'] - $value->postTime );
$totalCome -= $shop[$value->cId][output];
}
if ( $value->buyTime + $animaltime[$value->cId][5] - $animaltime[$value->cId][3] - $animaltime[$value->cId][4] < $_SGLOBAL['timestamp'] )
{
$status = 5;
$statusNext = 6;
$growTimeNext = $animaltime[$value->cId][5] - $time;
}
$newanimal[] = "{\"buyTime\":".$value->buyTime.",\"cId\":".$value->cId.",\"growTime\":".$time.",\"growTimeNext\":".$growTimeNext.",\"hungry\":0,\"serial\":".$key.",\"status\":".$status.",\"statusNext\":".$statusNext.",\"totalCome\":".$totalCome."}";
}
}
}
$newanimal = json_encode( $newanimal );
$newanimal = str_replace( "\"{", "{", $newanimal );
$newanimal = str_replace( "}\"", "}", $newanimal );
$newanimal = str_replace( "null", "[]", $newanimal );
echo stripslashes("{\"added\":0,\"animal\":".$newanimal.",\"direction\":\"\\\\u6210\\\\u529f\\\\u8d2d\\\\u4e70".$_REQUEST['foodnum']."\\\\u68f5\\\\u7267\\\\u8349\\\\uff0c\\\\u5171\\\\u82b1\\\\u8d39\\\\u91d1\\\\u5e01".($mc_price * $_REQUEST['foodnum'])."\\\\uff0c\\\\u5df2\\\\u653e\\\\u5165\\\\u60a8\\\\u7684\\\\u80CC\\\\u5305\\\\u5185\\\\u3002\",\"money\":".($mc_price * $_REQUEST['foodnum']).",\"total\":".floor($animal[animalfood])."}");
exit();
}
本代码来自一个网友,我改动不大,我没测试过。据说是 “肠清茶版” 里的。
现在,改动很大!!!仍有点小缺陷。
还有一个地方,牧草购买说明内容(不改也无所谓)
找到:
if ( $_REQUEST['mod'] == "cgi_get_food" )
{
echo "[{\"FBPrice\":0,\"depict\":\"\\u52A8\\u7269\\u6328\\u997F\\u4F1A\\u505C\\u6B62\\u751F\\u957F\\u6216\\u751F\\u4EA7\\u3002\\u7267\\u8349\\u53EF\\u4EE5\\u5728\\u519C\\u573A\\u79CD\\u690D\\uFF0C\\u5546\\u5E97\\u8D2D\\u4E70\\u7267\\u8349\\u7684\\u529F\\u80FD\\u6682\\u65F6\\u4E0D\\u5F00\\u653E\\u3002\",\"effect\":0,\"price\":60,\"tId\":1,\"tName\":\"\\u7267\\u8349\",\"timeLimit\":0,\"type\":25}]";
}
改为:
if ( $_REQUEST['mod'] == "cgi_get_food" )
{
echo "[{\"FBPrice\":0,\"depict\":\"\\u4EF7\\u683C60\\u5143\\u6BCF\\u68F5\\u3002\\u52A8\\u7269\\u6328\\u997F\\u4F1A\\u505C\\u6B62\\u751F\\u957F\\u6216\\u751F\\u4EA7\\u3002\\u7267\\u8349\\u53EF\\u4EE5\\u5728\\u519C\\u573A\\u79CD\\u690D\\uFF0C\\u4E5F\\u53EF\\u4EE5\\u5728\\u5546\\u5E97\\u8D2D\\u4E70\\u3002\\u4F46\\u662F\\u7531\\u4E8E\\u7267\\u8349\\u662F\\u7D27\\u4FCF\\u8D27\\uFF0C\\u4E70\\u4E0D\\u5982\\u79CD\\u54E6\\u3002\",\"effect\":0,\"price\":60,\"tId\":1,\"tName\":\"\\u7267\\u8349\",\"timeLimit\":0,\"type\":25}]";
} |