Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Smarty i Gamers fusion
Vanx
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 3.07.2005

Ostrzeżenie: (0%)
-----


Mam skrypt z gamers fusion i zmieniłem go aby działał ze smartym i zrobiłem to :
plik php:
  1. <?
  2. global $stat;
  3. global $enemy;
  4. global $myarm;
  5. global $mywep;
  6. global $earm;
  7. global $ewep;
  8.  
  9.  
  10. ?>
  11.  
  12. <?php
  13. function attack() {
  14. global $stat;
  15. global $enemy;
  16. global $myarm;
  17. global $mywep;
  18. global $earm;
  19. global $ewep;
  20.  
  21. $repeat = ($stat[agility] / $enemy[agility]);
  22. $attackstr = ceil($repeat);
  23. if ($attackstr <= 0) {
  24. $attackstr = 1;
  25. }
  26. $mypower = ($mywep[power] + $stat[strength]);
  27. $epower = ($enemy[strength] + $earm[power]);
  28.  
  29. $attackdmg = ($mypower - $epower);
  30. if ($attackdmg <= 0) {
  31. $attackdmg = 1;
  32. }
  33. $round = 1;
  34. $rzut = rand(1,$enemy[speed]);
  35. while ($round <= $attackstr && $enemy[hp] >= 0) {
  36. if ($enemy[unik] > $rzut) {
  37. $smarty->assign('fight', '<b>$enemy[user]</b> uniknoł twojego ciosu.');
  38. $smarty->display('abattle.tpl');
  39. } else {
  40.  
  41. $smarty->assign(&#092;"fight\", \"<b>\".$stat[user].\"</b> zadał \".atackdmg.\" <b>\".$enemy[user].\"</b>\");
  42. $smarty->display('abattle.tpl');
  43.  
  44. $enemy[hp] = ($enemy[hp] - $attackdmg);
  45. $round = ($round + 1);
  46. }
  47. }
  48.  
  49. if ($enemy[hp] <= 0) {
  50. $enemy[hp] = 0;
  51. $smarty->assign(&#092;"fight\", \"<br><b>\".$stat[user].\"</b> Wygrywa!<br>\");
  52. $smarty->display('abattle.tpl');
  53. $expgain = (rand(5,10) * $enemy[level]);
  54. $creditgain = ($enemy[credits] / 10);
  55. $smarty->assign(&#092;"fight\", \"<b>\".$stat[user].\"</b> zdobywa \".$expgain.\" doświadczenia i \".$creditgain.\" sztuk złota.\");
  56. $smarty->display('abattle.tpl');
  57. mysql_query(&#092;"update players set hp=$stat[hp] where id=$stat[id]\");
  58. mysql_query(&#092;"update players set hp=0 where id=$enemy[id]\");
  59. mysql_query(&#092;"update players set exp=exp+$expgain where id=$stat[id]\");
  60. mysql_query(&#092;"update players set credits=credits+$creditgain where id=$stat[id]\");
  61. mysql_query(&#092;"update players set wins=wins+1 where id=$stat[id]\");
  62. mysql_query(&#092;"update players set losses=losses+1 where id=$enemy[id]\");
  63. mysql_query(&#092;"update players set lastkilled='$enemy[user]' where id=$stat[id]\");
  64. mysql_query(&#092;"update players set lastkilledby='$stat[user]' where id=$enemy[id]\");
  65. $texp = ($stat[exp] + $expgain);
  66. $expn = (($stat[level] * 50) + ($stat[level] * 15));
  67. $tlevel = $stat[level] +1;
  68. if ($texp >= $expn) {
  69. $smarty->assign(&#092;"fight\", \"<b>\".$stat[user].\"</b> awansuje na \".$tlevel.\" poziom.\");
  70. $smarty->display('abattle.tpl');
  71. mysql_query(&#092;"update players set ap=ap+4 where id=$stat[id]\");
  72. mysql_query(&#092;"update players set level=level+1 where id=$stat[id]\");
  73. mysql_query(&#092;"update players set exp=0 where id=$stat[id]\");
  74. mysql_query(&#092;"insert into log (owner, log) values($stat[id],'Pokonałeś <b>$enemy[user]</b> i zdobyłeś poziom.')\");
  75. }
  76.  
  77. mysql_query(&#092;"insert into log (owner, log) values($stat[id],'Zostałeś zaatakowany przez <b>$enemy[user]</b>. zdobywasz $expgain EXP i $creditgain sztuk złota.')\");
  78. mysql_query(&#092;"insert into log (owner, log) values($enemy[id],'Zostałeś zaatakowany i pokonany przez <b>$stat[user]</b>.')\");
  79. } else {
  80. attackback();
  81. }
  82. }
  83.  
  84.  
  85. if ($stat[hp] <= 0) {
  86. $smarty->assign(&#092;"fight\", \"<b>\".$enemy[user].\"</b> Wygrywa.\");
  87. $smarty->display('abattle.tpl');
  88. $expgain = (rand(5,10) * $stat[level]);
  89. $creditgain = ($enemy[credits] / 10);
  90. $smarty->assign(&#092;"fight\", \"<b>\".$enemy[user].\"</b> zdobywa \".$expgain.\" doświadcznia i \".$creditgain.\" sztuk złota.\");
  91. $smarty->display('abattle.tpl');
  92. mysql_query(&#092;"update players set hp=$enemy[hp] where id=$enemy[id]\");
  93. mysql_query(&#092;"update players set hp=0 where id=$stat[id]\");
  94. mysql_query(&#092;"update players set exp=exp+$expgain where id=$enemy[id]\");
  95. mysql_query(&#092;"update players set credits=credits+$creditgain where id=$enemy[id]\");
  96. mysql_query(&#092;"update players set wins=wins+1 where id=$enemy[id]\");
  97. mysql_query(&#092;"update players set losses=losses+1 where id=$stat[id]\");
  98. mysql_query(&#092;"update players set lastkilled='$stat[user]' where id=$enemy[id]\");
  99. mysql_query(&#092;"update players set lastkilledby='$enemy[user]' where id=$stat[id]\");
  100. $texp = ($enemy[exp] + $expgain);
  101. $expn = (($enemy[level] * 50) + ($enemy[level] * 15));
  102. $tlevel = $enemy[level] + 1;
  103. if ($texp >= $expn) {
  104. $smarty->assign(&#092;"fight\", \"<b>\".$enemy[user].\"</b> awansuje na \".$tlevel.\" poziom.\");
  105. $smarty->display('abattle.tpl');
  106. mysql_query(&#092;"update players set ap=ap+4 where id=$enemy[id]\");
  107. mysql_query(&#092;"update players set level=level+1 where id=$enemy[id]\");
  108. mysql_query(&#092;"update players set exp=0 where id=$enemy[id]\");
  109. mysql_query(&#092;"insert into log (owner, log) values($enemy[id],'Pokonałeś <b>$stat[user]</b> i zdobyłeś poziom.')\");
  110. }
  111. mysql_query(&#092;"insert into log (owner, log) values($enemy[id],'You have defeated <b>$stat[user]</b>. Gained <b>$expgain</b> EXP and <b>$creditgain</b> credits.')\");
  112. mysql_query(&#092;"insert into log (owner, log) values($stat[id],'You were defeated by <b>$enemy[user]</b>.')\");
  113. } else {
  114. attack();
  115. }
  116.  
  117. function attackback() {
  118. global $stat;
  119. global $enemy;
  120. global $myarm;
  121. global $mywep;
  122. global $earm;
  123. global $ewep;
  124.  
  125. $repeat = ($enemy[agility] / $stat[agility]);
  126. $attackstr = ceil($repeat);
  127. if ($attackstr <= 0) {
  128. $attackstr = 1;
  129. }
  130. $mypower = ($mywep[power] + $stat[strength]);
  131. $epower = ($enemy[strength] + $ewep[power]);
  132.  
  133. $attackdmg = ($epower - $mypower);
  134. if ($attackdmg <= 0) {
  135. $attackdmg = 1;
  136. }
  137.  
  138. $round = 1;
  139. $rzut = rand(1,$stat[speed]);
  140. while ($round <= $attackstr && $stat[hp] >= 0) {
  141. if ($stat[unik] > $rzut) {
  142. $smarty->assign(&#092;"fight\", \"<b>\".$enemy[user].\"</b> uniknoł ciosu.\");
  143. $smarty->display('abattle.tpl');
  144. $stat[hp] = ($stat[hp] - $attackdmg);
  145. $round = ($round + 1);
  146. }
  147. }
  148. ?>
  149.  
  150. <?php
  151. if ($battle) {
  152. global $stat;
  153. global $enemy;
  154. global $myarm;
  155. global $mywep;
  156. global $earm;
  157. global $ewep;
  158.  
  159. $enemy = mysql_fetch_array(mysql_query(&#092;"select * from players where id=$battle\"));
  160. $mywep = mysql_fetch_array(mysql_query(&#092;"select * from equipment where owner=$stat[id] and type='W' and status='E'\"));
  161. $myarm = mysql_fetch_array(mysql_query(&#092;"select * from equipment where owner=$stat[id] and type='A' and status='E'\"));
  162. $ewep = mysql_fetch_array(mysql_query(&#092;"select * from equipment where owner=$enemy[id] and type='W' and status='E'\"));
  163. $earm = mysql_fetch_array(mysql_query(&#092;"select * from equipment where owner=$enemy[id] and type='A' and status='E'\"));
  164.  
  165. if (!$enemy[id]) {
  166. $smarty->assign('Error', 'Nie ma takiego gracza <a href=battle.php>Wróć</a>');
  167. $smarty->display('failed3.tpl');
  168. }
  169. if ($enemy[id] == $stat[id]) {
  170. $smarty->assign('Error', 'Nie możesz atakować samego siebie <a href=battle.php>Wróć</a>');
  171. $smarty->display('failed3.tpl');
  172. }
  173. if ($enemy[hp] <= 0) {
  174. $smarty->assign('Error', '$enemy[user] aktualnie jest martwy <a href=battle.php>Wróć</a>');
  175. $smarty->display('failed3.tpl');
  176. }
  177. if ($stat[energy] < 1) {
  178. $smarty->assign('Error', 'Masz zbyt mało energi aby walczyć <a href=battle.php>Wróć</a>');
  179. $smarty->display('failed3.tpl');
  180. }
  181. if ($stat[hp] <= 0) {
  182. $smarty->assign('Error', 'Jesteś martwy <a href=battle.php>Wróć</a>');
  183. $smarty->display('failed3.tpl');
  184. }
  185.  
  186. if ($enemy[tribe] == $stat[tribe] && $enemy[tribe] > 0) {
  187. $smarty->assign('Error', 'Nie możesz atakować członka swojego klanu <a href=battle.php>Wróć</a>');
  188. $smarty->display('failed3.tpl');
  189. }
  190. $span = ($stat['level'] > $enemy['level']);
  191. if ($span > 2) {
  192. $smarty->assign('Error', 'Nie możesz atakowac słabszych od siebie <a href=battle.php>Wróć</a>');
  193. $smarty->display('failed3.tpl');
  194. }
  195. mysql_query(&#092;"update players set energy=energy-1 where id=$stat[id]\");
  196. if ($stat[agility] >= $enemy[agility]) {
  197. attack();
  198. } else {
  199. attackback();
  200. }
  201. }
  202. }
  203. ?>
  204.  
  205. <?php
  206. $smarty->assign('fight', '$fight');
  207. $smarty->display('abattle.tpl'); ?>

jest to skypt walki i jak klikam na kogoś aby walczyć wyskakuje mi to:
Fatal error: Call to a member function on a non-object in /home/vanx/domains/public_html/gamersfusion/abattle.php on line 43
i plik tpl wygląda tak:
  1. <?php
  2.  
  3. {include file=&#092;"header.php\"}
  4. <table width=&#092;"100%\">
  5. <tr>
  6. <td><center><u><b>TURA: {$round}</b></u></center></td></tr>
  7. <br>
  8. <tr><td><center>{$who}</center></td></tr>
  9. <tr>
  10. <td>
  11. <br><br>
  12. {$fight}
  13. </td>
  14. </tr>
  15. <tr>
  16. <td>
  17. <br><br>
  18. <b><u>{$stat.user}:<br> </u></b>
  19. HP: {$stat.hp}<br>
  20. MP: {$stat.mana}<br>
  21. <b><u>{$enemy.user}: </u></b>
  22. HP: {$enemy.hp}<br>
  23. MP: {$enemy.mana}<br>
  24. </td>
  25. </tr>
  26. <tr>
  27. <td>
  28. <br><br><br>
  29. {$atack}<br>
  30. {if $stat.klasa == &#092;"barbarzyńca\"}
  31. {$aatack}<br>
  32. {/if}
  33. {$potion}
  34. {$losthim}
  35.  
  36. </td>
  37. </tr>
  38. </table>
  39.  
  40. ?>

błąd występuje tutaj
  1. <?php
  2. $smarty->assign(&#092;"fight\", \"<b>\".$stat[user].\"</b> zadał \".atackdmg.\" <b>\".$enemy[user].\"</b>\");
  3. ?>
Wiele razy nad tym siedziałem i nic nie zrobiłem (IMG:http://forum.php.pl/style_emoticons/default/angrysmiley.gif) jesli ktoś znajdzie gdzie zrobiłem błąd to bede wdzięczny (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post

Posty w temacie


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: 15.09.2025 - 05:04