如何修复脚本中出现的错误? [英] How to fix the bug that is occuring in the script?

查看:58
本文介绍了如何修复脚本中出现的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看到人们不能正确阅读并且必须报告我的最后一个问题尽管它肯定是清楚的。所以再次。这是一个游戏脚本我试图在大多数情况下修复It Works上的错误。脚本在用于从市场购买Gems时不会更新用户对战点的问题,也不会更新用户宝石统计数据。它唯一要做的就是从Stock.txt中取出,告诉用户有多少库存。我该如何解决这个问题。如果你报告这个说法不是一个问题有人需要正确阅读英语并且有一个常识,即问题框只允许输入这么多并没有给我足够的空间来提出完整的问题



Seeing as people cant properly read and have to report my last question Even though it was definately clear . So AGAIN. this is a game script im trying to fix the bug on It Works for the most part . The issue with the script its not updating the Users Battle points when its being used to buy the Gems from the Market nor is it updating the Users Gem stats. The only thing it is doing is taking away from the Stock.txt which tells the user how many are in Stock. How do i fix this issue. And if you report this saying its not a question Someone needs to properly read english and have common sense that the question box only allows so much to input which doesnt give me enough room to ask the full question

<?php
        if($_COOKIE['edited']) {
          session_start();
          }
        header("Cache-control: private"); //IE 6 Fix
        include "includes/lonconfig.php";
        $title = "Skill Trader Xur";
        include "includes/private_header.inc.php";
        if(!isset($_COOKIE['edited'])) {
          error("not_logged_in");
          return;
          }
/*       if($playerinfo[status]!=4) {
         echo "sorry we are closed for the moment<br> " ;
         return;
         }
*/
       $tendency=sin(date('j')*12)*.1;     //factor to affect prices to generate a ciclycal up/down tendency. I love this, jeje
       $stockdata=loaddata();
       $spread=.50;
       //echo "<br>$tendency";

switch ($action)
{
   case "buy";
      if ($amount!=1) { echo "What are you trying to do ? I didn't offer that deal!<br><br>"; echo "<center><a href=$PHP_SELF>Back</a><br></center>"; break; }
      if ($price!=ceil($stockdata[baseprice][$gem]*(1+$spread)))
      {
         echo "Gem Market prices have changed since last quote. New price is ".ceil($stockdata[baseprice][$gem]*(1+$spread))."<br>";
         echo "Do you want to continue the trade? (prices might change again till you decide)<br><Br>";
         echo "<a href=$PHP_SELF?action=buy&amount=$amount&gem=$gem&price=".ceil($stockdata[baseprice][$gem]*(1+$spread)).">Yes</a> / <a href=$PHP_SELF>No</a><br><br>";
         break;
      }

      if ($amount>$stockdata[amount][$gem]) { echo "Sorry, I don't have that much...<br>Come back later, maybe I can get some for you<br><br>"; echo "<center><a href=$PHP_SELF>Back</a><br></center>"; break; }

      if ($playerinfo[battle_points]>=$price*$amount)
      {
         echo "<br>You bought $amount ".$stockdata[gemname][$gem]."(s) for ".$price*$amount."<br><br>";
         echo "<center><a href=$PHP_SELF>Back</a><br></center>";
         mysql_query("update userdb set battle_points=battle_points-".$price*$amount.", ".$stockdata[gemname][$gem]."=".$stockdata[gemname][$gem]."+$amount where id=$playerinfo[id] limit 1");
         mysql_query("INSERT INTO `user_tradelogs` ( `fromid` , `type` , `itemdesc` , `amount` , `amount1` , `fecha` ) VALUES ( '$playerinfo[id]','13', '".$stockdata[gemname][$gem]."', '$amount', '".$price*$amount."', FROM_UNIXTIME(unix_timestamp())+0 )");

         $stockdata[baseprice][$gem]=1+ceil($stockdata[baseprice][$gem]*(1+$amount*.00005));
         $stockdata[amount][$gem]-=$amount;

         savedata($stockdata);
      } else echo "You don't have the required battle points to close that operation<br><br><center><a href=$PHP_SELF>Back</a><br></center>";
      break;

   default:

      echo "You enter the building and the amount of people screaming for buying and selling is amazing, You don't know where to go,";
      echo " Xur approaches you and tells you: \"Welcome to the Gem Market... Pretty busy, uh ?<br><br>What can I do for you?<br><br><br>";
      echo "<table width=100% border=1><tr><th>Item</th><th>Charging</th><th>Buy</th>";
      if ($playerinfo[status]==5) echo "<th>Stock</th>";
      echo "<th colspan=4>In Stock</th></tr>";

      for ($i=1;$i<=3;$i++)
      {
         $gemname=$stockdata[gemname][$i];
         $buyprice=ceil($stockdata[baseprice][$i]*(1-$spread));
         $amount=$stockdata[amount][$i];
         echo "<tr><td align=center>$gemname</td><td align=center>$buyprice</td>";
         if ($playerinfo[status]==5) echo "<td align=center>$amount</td>";
         echo "<td><a href=$PHP_SELF?action=buy&amount=1&gem=$i&price=$buyprice>Buy 1</a></td>";
         echo "<td>$amount</a></td>";
         echo "</tr>";
      }
      echo "</table>";

      echo "<center><font color=yellow>Battle Points: ($playerinfo[battle_points])</font></center>";
      echo "<br><br><center><a href=stxur.php>Exit Room</a><br></center>";

      break;
}


function loaddata()
{
   global $tendency;
   $filename='stocks.txt';
   $fp = @fopen($filename, "r");
   if($fp)
   {
      for ($i=1;$i<=3;$i++)
      {
         $stockdata[gemname][$i] =trim(fgets($fp));
          $stockdata[amount][$i] =(int)trim(fgets($fp));
          $stockdata[baseprice][$i] =(int)(trim(fgets($fp))*(1+$tendency));
          $stockdata[limit][$i] =(int)trim(fgets($fp));
       }
       fclose($fp);
       return $stockdata;
   }
}

function savedata($stockdata)
{
   global $tendency;
   $filename='stocks.txt';
   $fp = fopen($filename, "w+");
   if($fp)
   {
      for ($i=1;$i<=3;$i++)
      {
          fputs($fp,$stockdata[gemname][$i]."\n");
          fputs($fp,$stockdata[amount][$i]."\n");
          fputs($fp,round($stockdata[baseprice][$i]/(1+$tendency))."\n");
          fputs($fp,$stockdata[limit][$i]."\n");
       }
       fclose($fp);
   }
}
?>

推荐答案

_COOKIE [' edited']){
session_start();
}
header( Cache-control:private); // IE 6修复
包括 includes / lonconfig.php;
_COOKIE['edited']) { session_start(); } header("Cache-control: private"); //IE 6 Fix include "includes/lonconfig.php";


title = Skill Trader Xur;
包括 includes / private_header.inc.php;
if(!isset(
title = "Skill Trader Xur"; include "includes/private_header.inc.php"; if(!isset(


_COOKIE [' edited'])){
error( not_logged_in);
return ;
}
/ * if(
_COOKIE['edited'])) { error("not_logged_in"); return; } /* if(


这篇关于如何修复脚本中出现的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆