Mam skrypt z gamers fusion i zmieniłem go aby działał ze smartym i zrobiłem to :
plik php:
<?
?>
<?php
function attack() {
$repeat = ($stat[agility] / $enemy[agility]);
$attackstr = ceil($repeat); if ($attackstr <= 0) {
$attackstr = 1;
}
$mypower = ($mywep[power] + $stat[strength]);
$epower = ($enemy[strength] + $earm[power]);
$attackdmg = ($mypower - $epower);
if ($attackdmg <= 0) {
$attackdmg = 1;
}
$round = 1;
$rzut = rand(1
,$enemy[speed
]); while ($round <= $attackstr && $enemy[hp] >= 0) {
if ($enemy[unik] > $rzut) {
$smarty->assign('fight', '<b>$enemy[user]</b> uniknoł twojego ciosu.');
$smarty->display('abattle.tpl');
} else {
$smarty->assign(\"fight\", \"<b>\".$stat[user].\"</b> zadał \".atackdmg.\" <b>\".$enemy[user].\"</b>\");
$smarty->display('abattle.tpl');
$enemy[hp] = ($enemy[hp] - $attackdmg);
$round = ($round + 1);
}
}
if ($enemy[hp] <= 0) {
$enemy[hp] = 0;
$smarty->assign(\"fight\", \"<br><b>\".$stat[user].\"</b> Wygrywa!<br>\");
$smarty->display('abattle.tpl');
$expgain = (rand(5
,10
) * $enemy[level
]); $creditgain = ($enemy[credits] / 10);
$smarty->assign(\"fight\", \"<b>\".$stat[user].\"</b> zdobywa \".$expgain.\" doświadczenia i \".$creditgain.\" sztuk złota.\");
$smarty->display('abattle.tpl');
mysql_query(\"update players set hp=$stat[hp] where id=$stat[id]\"); mysql_query(\"update players set hp=0 where id=$enemy[id]\"); mysql_query(\"update players set exp=exp+$expgain where id=$stat[id]\"); mysql_query(\"update players set credits=credits+$creditgain where id=$stat[id]\"); mysql_query(\"update players set wins=wins+1 where id=$stat[id]\"); mysql_query(\"update players set losses=losses+1 where id=$enemy[id]\"); mysql_query(\"update players set lastkilled='$enemy[user]' where id=$stat[id]\"); mysql_query(\"update players set lastkilledby='$stat[user]' where id=$enemy[id]\"); $texp = ($stat[exp] + $expgain);
$expn = (($stat[level] * 50) + ($stat[level] * 15));
$tlevel = $stat[level] +1;
if ($texp >= $expn) {
$smarty->assign(\"fight\", \"<b>\".$stat[user].\"</b> awansuje na \".$tlevel.\" poziom.\");
$smarty->display('abattle.tpl');
mysql_query(\"update players set ap=ap+4 where id=$stat[id]\"); mysql_query(\"update players set level=level+1 where id=$stat[id]\"); mysql_query(\"update players set exp=0 where id=$stat[id]\"); mysql_query(\"insert into log (owner, log) values($stat[id],'Pokonałeś <b>$enemy[user]</b> i zdobyłeś poziom.')\"); }
mysql_query(\"insert into log (owner, log) values($stat[id],'Zostałeś zaatakowany przez <b>$enemy[user]</b>. zdobywasz $expgain EXP i $creditgain sztuk złota.')\"); mysql_query(\"insert into log (owner, log) values($enemy[id],'Zostałeś zaatakowany i pokonany przez <b>$stat[user]</b>.')\"); } else {
attackback();
}
}
if ($stat[hp] <= 0) {
$smarty->assign(\"fight\", \"<b>\".$enemy[user].\"</b> Wygrywa.\");
$smarty->display('abattle.tpl');
$expgain = (rand(5
,10
) * $stat[level
]); $creditgain = ($enemy[credits] / 10);
$smarty->assign(\"fight\", \"<b>\".$enemy[user].\"</b> zdobywa \".$expgain.\" doświadcznia i \".$creditgain.\" sztuk złota.\");
$smarty->display('abattle.tpl');
mysql_query(\"update players set hp=$enemy[hp] where id=$enemy[id]\"); mysql_query(\"update players set hp=0 where id=$stat[id]\"); mysql_query(\"update players set exp=exp+$expgain where id=$enemy[id]\"); mysql_query(\"update players set credits=credits+$creditgain where id=$enemy[id]\"); mysql_query(\"update players set wins=wins+1 where id=$enemy[id]\"); mysql_query(\"update players set losses=losses+1 where id=$stat[id]\"); mysql_query(\"update players set lastkilled='$stat[user]' where id=$enemy[id]\"); mysql_query(\"update players set lastkilledby='$enemy[user]' where id=$stat[id]\"); $texp = ($enemy[exp] + $expgain);
$expn = (($enemy[level] * 50) + ($enemy[level] * 15));
$tlevel = $enemy[level] + 1;
if ($texp >= $expn) {
$smarty->assign(\"fight\", \"<b>\".$enemy[user].\"</b> awansuje na \".$tlevel.\" poziom.\");
$smarty->display('abattle.tpl');
mysql_query(\"update players set ap=ap+4 where id=$enemy[id]\"); mysql_query(\"update players set level=level+1 where id=$enemy[id]\"); mysql_query(\"update players set exp=0 where id=$enemy[id]\"); mysql_query(\"insert into log (owner, log) values($enemy[id],'Pokonałeś <b>$stat[user]</b> i zdobyłeś poziom.')\"); }
mysql_query(\"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.')\"); mysql_query(\"insert into log (owner, log) values($stat[id],'You were defeated by <b>$enemy[user]</b>.')\"); } else {
attack();
}
function attackback() {
$repeat = ($enemy[agility] / $stat[agility]);
$attackstr = ceil($repeat); if ($attackstr <= 0) {
$attackstr = 1;
}
$mypower = ($mywep[power] + $stat[strength]);
$epower = ($enemy[strength] + $ewep[power]);
$attackdmg = ($epower - $mypower);
if ($attackdmg <= 0) {
$attackdmg = 1;
}
$round = 1;
$rzut = rand(1
,$stat[speed
]); while ($round <= $attackstr && $stat[hp] >= 0) {
if ($stat[unik] > $rzut) {
$smarty->assign(\"fight\", \"<b>\".$enemy[user].\"</b> uniknoł ciosu.\");
$smarty->display('abattle.tpl');
$stat[hp] = ($stat[hp] - $attackdmg);
$round = ($round + 1);
}
}
?>
<?php
if ($battle) {
if (!$enemy[id]) {
$smarty->assign('Error', 'Nie ma takiego gracza <a href=battle.php>Wróć</a>');
$smarty->display('failed3.tpl');
}
if ($enemy[id] == $stat[id]) {
$smarty->assign('Error', 'Nie możesz atakować samego siebie <a href=battle.php>Wróć</a>');
$smarty->display('failed3.tpl');
}
if ($enemy[hp] <= 0) {
$smarty->assign('Error', '$enemy[user] aktualnie jest martwy <a href=battle.php>Wróć</a>');
$smarty->display('failed3.tpl');
}
if ($stat[energy] < 1) {
$smarty->assign('Error', 'Masz zbyt mało energi aby walczyć <a href=battle.php>Wróć</a>');
$smarty->display('failed3.tpl');
}
if ($stat[hp] <= 0) {
$smarty->assign('Error', 'Jesteś martwy <a href=battle.php>Wróć</a>');
$smarty->display('failed3.tpl');
}
if ($enemy[tribe] == $stat[tribe] && $enemy[tribe] > 0) {
$smarty->assign('Error', 'Nie możesz atakować członka swojego klanu <a href=battle.php>Wróć</a>');
$smarty->display('failed3.tpl');
}
$span = ($stat['level'] > $enemy['level']);
if ($span > 2) {
$smarty->assign('Error', 'Nie możesz atakowac słabszych od siebie <a href=battle.php>Wróć</a>');
$smarty->display('failed3.tpl');
}
mysql_query(\"update players set energy=energy-1 where id=$stat[id]\"); if ($stat[agility] >= $enemy[agility]) {
attack();
} else {
attackback();
}
}
}
?>
<?php
$smarty->assign('fight', '$fight');
$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:
<?php
{include file=\"header.php\"} <table width=\"100%\">
<tr>
<td><center><u><b>TURA: {$round}</b></u></center></td></tr>
<br>
<tr><td><center>{$who}</center></td></tr>
<tr>
<td>
<br><br>
{$fight}
</td>
</tr>
<tr>
<td>
<br><br>
<b><u>{$stat.user}:<br> </u></b>
HP: {$stat.hp}<br>
MP: {$stat.mana}<br>
<b><u>{$enemy.user}: </u></b>
HP: {$enemy.hp}<br>
MP: {$enemy.mana}<br>
</td>
</tr>
<tr>
<td>
<br><br><br>
{$atack}<br>
{if $stat.klasa == \"barbarzyńca\"}
{$aatack}<br>
{/if}
{$potion}
{$losthim}
</td>
</tr>
</table>
?>
błąd występuje tutaj
<?php
$smarty->assign(\"fight\", \"<b>\".$stat[user].\"</b> zadał \".atackdmg.\" <b>\".$enemy[user].\"</b>\");
?>
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)