Updating defense and displaying it real time.
Posted: Mon Dec 27, 2010 8:43 am
Hey people, so i have a equipment page showing the current Armor the player has unequipped and equipped just as shown on the MMO Series. and i added in code to display the Defense of the player witch is quite simple but when someone equips a piece of armor it will add 2 or subtract 2 when unequiping, so with that being said, my problem is that the player has to refresh the page just to see the updated defense and that can get really confusing to players, so i did try making a script saying if a piece of armor got equipped then it will print defense + 2 and that works real time and is fine with me but at the same time i don't think it will work correctly when going into battle, so i have to update their armor some how. But when i equip more than one piece of armor it leaves it at the highest amount of armor witch is 2 so instead of equipping another piece of armor and it displaying defense + 4 it says defense + 2. can anyone guide me in the right direction please. I got rid of the code because it didn't work properly but i will display my original code if someone can get an idea of what to do.
I broke this up into parts, This is the equip and unequip part of the script.
This is the query for the armor and where it displays the weapon and armor table.
Any help is appreciated! Thanks for anyone who can help! 
I broke this up into parts, This is the equip and unequip part of the script.
Code: Select all
<?php
$type=$_GET['type'];
$local=$_GET['local'];
$randid=$_GET['randid'];
if ($type=="a")
{
$updateequip="Update playerarmor SET equip=0 WHERE pid='$id' AND equip=1 AND location='$local'";
mysql_query($updateequip) or die("Could not update armor");
$reequip="Update playerarmor set equip=1 where pid='$id' AND randid='$randid' AND location='$local'";
mysql_query($reequip) or die("Could not update armor2");
echo "<center><big><big>Armor Equipped<br></big></big>";
}
if ($type=="ua")
{
$updateequip="Update playerarmor SET equip=0 WHERE pid='$id' AND equip=1 AND location='$local'";
mysql_query($updateequip) or die("Could not update armor");
echo "<center><big><big>Armor UnEquipped<br></big></big>";
}
?>
This is the query for the armor and where it displays the weapon and armor table.
Code: Select all
<?php
print "<center><h3>Armor</h3></center>";
print "<center>";
print "<table border='0' width='70%' cellspacing='20'>";
print "<tr><td width='25%' valign='top'>";
print "</td>";
print "<td valign='top' width='75%'>";
$selectarmor="SELECT * from playerarmor where pid='$id'";
$selectarmor2=mysql_query($selectarmor) or die("could not select armor3");
print "<table border='1' bordercolor='white' bgcolor='#FFFFFF' >";
print "<tr><td><img src='Images/Name_Text.gif'></td><td>
<img src='Images/Defense_Text.gif'></td><td>
<img src='Images/Level_Text.gif'></td><td>
<img src='Images/Location_Text.gif'><td>
<img src='Images/Status_Text.gif'></td></tr>";
while($selectarmor3=mysql_fetch_array($selectarmor2))
{
if ($selectarmor3[equip] == 1)
{$selectarmor3[equip] = "<img src='Images/Equipped_Text.gif'>" . " <a href='Equipment.php?equip=1&type=ua&local=$selectarmor3[location]'><img src='Images/unequip_Button.gif'></a><br><br>";}
else {$selectarmor3[equip] = "<A href='equipment.php?equip=1&randid=$selectarmor3[randid]&type=a&local=$selectarmor3[location]'><img src='Images/Equip_Button.gif'></a>";}
$randid = $selectarmor3[randid];
print "<tr><td><center>$selectarmor3[name]</center></td><td><center>$selectarmor3[defense]</center></td><td><center>$selectarmor3[level]</center></td><td><center>$selectarmor3[location]</center></td><td><center>$selectarmor3[equip]</center></td>
</tr>";
}
print "</table>";
print "</td></tr></table>";
print "</center>";
}
?>