Witaj Go¶ciu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]modyfikacja skryptu
-yacko-
post
Post #1





Go¶cie







Witam. Z PHP styczno¶æ mam od nie dawna. Nie umiem wiele, a wrecz prawie nic. Ale do rzeczy.
Chce zedytowaæ pewien skrypt RPG. Nawet dobrze mi idzie, ale napotka³em problem.
To jest oryginalny kod:


  1. <?php
  2. /*
  3. MCCodes Lite
  4. itemuse.php Rev 1.0.0
  5. Copyright (C) 2006 Dabomstew
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Software
  19. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. */
  21. require "global_func.php";
  22. if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
  23. $userid=$_SESSION['userid'];
  24. require "header.php";
  25. $h = new headers;
  26. $h->startheaders();
  27. include "mysql.php";
  28. global $c;
  29. $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid W
    HERE u.userid=$userid"
    ,$c) or die(mysql_error());
  30. check_level();
  31. $fm=money_formatter($ir['money']);
  32. $lv=date('F j, Y, g:i a',$ir['laston']);
  33. $h->userdata($ir,$lv,$fm);
  34. $h->menuarea();
  35. $_GET['ID'] = abs((int) $_GET['ID']);
  36. //Medical
  37. if(!$_GET['ID'])
  38. {
  39. print "Invalid use of file";
  40. }
  41. else
  42. {
  43. $i=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i
    .itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid"
    ,$c);
  44. if(mysql_num_rows($i) == 0)
  45. {
  46. print "Invalid item ID";
  47. }
  48. else
  49. {
  50. if($r['itmtypename'] == 'Medical')
  51. {
  52. $f=mysql_query("SELECT * FROM medical WHERE item_id={$r['itmid']}",$c);
  53. mysql_query("UPDATE inventory SET inv_qty=inv_qty-1 WHERE inv_id={$_GET['ID']}",$c);
  54. mysql_query("DELETE FROM inventory WHERE inv_qty=0",$c);
  55. mysql_query("UPDATE users SET hp=hp+{$fr['hp']} WHERE userid=$userid");
  56. mysql_query("UPDATE users SET hp=maxhp WHERE hp > maxhp");
  57. print "You cram a {$r['itmname']} into your mouth. You feel a bit of energy coming back to you.";
  58. }
  59.  
  60.  
  61. else
  62. {
  63. print "You cannot use this item.";
  64. }
  65. }
  66. }
  67. $h->endpage();
  68. ?>

Tutaj chodzi o regeneracje hp przez medicine. I dodam, ze tutaj wszystko dziala bez problemów. Ja chcia³bym dodaæ regenracje energii przez jedzenie (food). Na podstawie urywku tego kodu stworzy³em cos takiego:

  1. <?php
  2. //Food
  3. if(!$_GET['ID'])
  4. {
  5. print "Invalid use of file";
  6. }
  7. else
  8. {
  9. $i=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i
    .itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid"
    ,$c);
  10. if(mysql_num_rows($i) == 0)
  11. {
  12. print "Invalid item ID";
  13. }
  14. else
  15. {
  16. if($r['itmtypename'] == 'Food')
  17. {
  18. $f=mysql_query("SELECT * FROM food WHERE item_id={$r['itmid']}",$c);
  19. mysql_query("UPDATE inventory SET inv_qty=inv_qty-1 WHERE inv_id={$_GET['ID']}",$c);
  20. mysql_query("DELETE FROM inventory WHERE inv_qty=0",$c);
  21. mysql_query("UPDATE users SET energy=energy+{$fr['energy']} WHERE userid=$userid");
  22. mysql_query("UPDATE users SET energy=maxenergy WHERE energy > maxenergy");
  23. print "You cram a {$r['itmname']} into your mouth. You feel a bit of energy coming back to you.";
  24. }
  25. ?>

Po prostu wszystkie Medical pozmienia³em na food i wszystkie hp na energy. To równiez dzia³a jezeli zamienie ten urywek z tamtym. Ale jezeli po³±cze ten drugi pod ten pierwszy w jedym kodzie nie dzia³a. Tak to wyglada po moim po³aczeniu:



  1. <?php
  2. /*
  3. MCCodes Lite
  4. itemuse.php Rev 1.0.0
  5. Copyright (C) 2006 Dabomstew
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Software
  19. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. */
  21. require "global_func.php";
  22. if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
  23. $userid=$_SESSION['userid'];
  24. require "header.php";
  25. $h = new headers;
  26. $h->startheaders();
  27. include "mysql.php";
  28. global $c;
  29. $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid W
    HERE u.userid=$userid"
    ,$c) or die(mysql_error());
  30. check_level();
  31. $fm=money_formatter($ir['money']);
  32. $lv=date('F j, Y, g:i a',$ir['laston']);
  33. $h->userdata($ir,$lv,$fm);
  34. $h->menuarea();
  35. $_GET['ID'] = abs((int) $_GET['ID']);
  36. //Medical
  37. if(!$_GET['ID'])
  38. {
  39. print "Invalid use of file";
  40. }
  41. else
  42. {
  43. $i=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i
    .itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid"
    ,$c);
  44. if(mysql_num_rows($i) == 0)
  45. {
  46. print "Invalid item ID";
  47. }
  48. else
  49. {
  50. if($r['itmtypename'] == 'Medical')
  51. {
  52. $f=mysql_query("SELECT * FROM medical WHERE item_id={$r['itmid']}",$c);
  53. mysql_query("UPDATE inventory SET inv_qty=inv_qty-1 WHERE inv_id={$_GET['ID']}",$c);
  54. mysql_query("DELETE FROM inventory WHERE inv_qty=0",$c);
  55. mysql_query("UPDATE users SET hp=hp+{$fr['hp']} WHERE userid=$userid");
  56. mysql_query("UPDATE users SET hp=maxhp WHERE hp > maxhp");
  57. print "You cram a {$r['itmname']} into your mouth. You feel a bit of energy coming back to you.";
  58. }
  59.  
  60. //Food
  61. if(!$_GET['ID'])
  62. {
  63. print "Invalid use of file";
  64. }
  65. else
  66. {
  67. $i=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i
    .itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid"
    ,$c);
  68. if(mysql_num_rows($i) == 0)
  69. {
  70. print "Invalid item ID";
  71. }
  72. else
  73. {
  74. if($r['itmtypename'] == 'Food')
  75. {
  76. $f=mysql_query("SELECT * FROM food WHERE item_id={$r['itmid']}",$c);
  77. mysql_query("UPDATE inventory SET inv_qty=inv_qty-1 WHERE inv_id={$_GET['ID']}",$c);
  78. mysql_query("DELETE FROM inventory WHERE inv_qty=0",$c);
  79. mysql_query("UPDATE users SET energy=energy+{$fr['energy']} WHERE userid=$userid");
  80. mysql_query("UPDATE users SET energy=maxenergy WHERE energy > maxenergy");
  81. print "You cram a {$r['itmname']} into your mouth. You feel a bit of energy coming back to you.";
  82. }
  83.  
  84. else
  85. {
  86. print "You cannot use this item.";
  87. }
  88. }
  89. }
  90. $h->endpage();
  91. ?>


Wyskakuje cos tam z unexpected $end. Moze mi ktos pomóc to dobrze po³±czyc?
Go to the top of the page
+Quote Post

Posty w temacie
- yacko   [PHP]modyfikacja skryptu   17.08.2008, 16:19:17
- - Maxik   Na której linii, zobacz czy masz domkniête wszystk...   17.08.2008, 18:10:11
- - Go¶æ   Nie mozliwe ze jakakolwiek linia jest otwarta poni...   17.08.2008, 19:58:36


Reply to this topicStart new topic
2 U¿ytkowników czyta ten temat (2 Go¶ci i 0 Anonimowych u¿ytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.12.2025 - 14:29