mforan Posted October 18, 2008 Share Posted October 18, 2008 okay, before i continue, its not that im dumb at php, but i basically bought the games code and have learnt from it. the problem i am having is, some output isnt working. im not sure why. btw, you can check the game out by googling "ambroid" shud be top hit! anyways, heres the code of an entire page of the game: <html> <head> <title>HQ</title> <link href="defaults.css" rel="StyleSheet" type="text/css"> </head> <body bgcolor="#000000"> <center> <iframe src="http://www.ambroid.co.uk/banner.php" frameborder="0" scrolling="no" width="468" height="60"></iframe> </center> <br> <?php include("dbinfo.inc.php"); if (!$loadeddbinfo) { die("<br><br><center>dbinfo couldnt be loaded</center></body></html>"); } include("loginverify.inc.php"); if (!$loadedloginverify) { mysql_close(); die("<br><br><center>loginverify couldnt be loaded</center></body></html>"); } $threeday = $day - 3; $buildchange[0] = ereg_replace("[^0-9]", "", $_POST['alliance']); $buildchange[1] = ereg_replace("[^A-Za-z0-9\_]", "", $_POST['squad']); $buildchange[2] = ereg_replace("[^0-9]", "", $_POST['t80']); $buildchange[3] = ereg_replace("[^0-9]", "", $_POST['bmp']); $buildchange[4] = ereg_replace("[^0-9]", "", $_POST['mi28']); $buildchange[5] = ereg_replace("[^0-9]", "", $_POST['ah64']); $buildchange[6] = ereg_replace("[^0-9]", "", $_POST['rah66']); $buildchange[7] = ereg_replace("[^0-9]", "", $_POST['f16']); $buildchange[8] = ereg_replace("[^0-9]", "", $_POST['f117']); $buildchange[9] = ereg_replace("[^0-9]", "", $_POST['f22']); $buildchange[10] = ereg_replace("[^0-9]", "", $_POST['b52']); $buildchange[11] = ereg_replace("[^0-9]", "", $_POST['b2']); if (($info[8] == "Private") || ($info[8] == "Captain")) { $buildchange[10] = ""; $buildchange[11] = ""; } if ($info[8] == "Major") { $buildchange[11] = ""; } # IF THERE WASN'T ANY INPUT, VARIABLE DEFINED AS A NEW WAR if (!$_POST) { $a = "new"; $alliance = ($info[24] == "1") ? "2" : "1"; } else { $query = "SELECT * FROM users WHERE username='$buildchange[1]' AND alliance='$buildchange[0]'"; $result = mysql_query($query) or die("Error: ".mysql_error()); $enemydet = array(); $enemydet = mysql_fetch_array($result, MYSQL_NUM); $enemyoriginal = array(); $enemyoriginal = $enemydet; if ($enemydet[0]) { # IF THE AMOUNT OF EACH UNIT'S AVAILABILITY IS LESS THAN THE AMOUNT THEY ARE TRYING TO SEND, VARIABLE IS NO $decision = true; for ($i = 0; $i <= 9; $i++) { if ($info[41 + $i] < $buildchange[2 + $i]) { $decision = false; } } # IF DECISION IS NO, OUTCOME IS AMOUNT WHICH INDICATES THERE ISN'T ENOUGH OF SOMETHING if (!$decision) { $a = "amount"; } else { # ASSIGN ATTACK POINT VALUES OF ALL UNITS TO THE VARIABLES $t80total = $buildchange[2]; $bmptotal = $buildchange[3]; $mi28total = $buildchange[4]; $ah64total = $buildchange[5] * 2; $rah66total = $buildchange[6] * 3; $f16total = $buildchange[7] * 4; $f117total = $buildchange[8] * 5; $f22total = $buildchange[9] * 5; $b52total = $buildchange[10] * 10; $b2total = $buildchange[11] * 10; # ADD UP TOTAL AND REMOVE DECIMAL PLACES $totaltotal = $t80total + $bmptotal + $mi28total + $ah64total + $rah66total + $f16total + $f117total + $f22total + $b52total + $b2total; $totaltotal = round($totaltotal); # ASSIGN VALUES TO THE AMOUNT OF ENEMY RESISTANCE $et80total = $enemydet[31]; $ebmptotal = $enemydet[32] * 2; $emi28total = $enemydet[33] * 3; $eah64total = $enemydet[34] * 3; $erah66total = $enemydet[35] * 3; $ef16total = $enemydet[36] * 3; $ef117total = $enemydet[37] * 3; $ef22total = $enemydet[38] * 4; $eb52total = $enemydet[39] * 0; $eb2total = $enemydet[40] * 5; $edeftotal = $enemydet[18] * 5; $esdtotal = $enemydet[20] * 20; $etotaltotal = $et80total + $ebmptotal + $emi28total + $eah64total + $erah66total + $ef16total + $ef117total + $ef22total + $eb52total + $eb2total + $edeftotal + $esdtotal; # CHECK FOR CHEATERS, IF SO CHANGE ALLIANCE TO INPUTTED AND EXIT LOOP # ALSO IF RANKS DIFFER EXIT LOOP AND CHANGE ALLIANCE TO INPUTTED # ELSE IF THE USER WON... if ($totaltotal < 0) { $a = "cheater"; $alliance = $buildchange[0]; } elseif ($info[8] != $enemydet[8]) { $a = "ranker"; $alliance = $buildchange[0]; } elseif ($enemydet[7] > $threeday) { $a = "weak"; $alliance = $buildchange[0]; } elseif ($info[7] > $threeday) { $a = "prot"; $alliance = $buildchange[0]; } elseif ($info[24] == $enemydet[24]) { $a = "yourself"; $alliance = $buildchange[0]; } elseif (!$info[24]) { $a = "noall"; $alliance = $buildchange[0]; } elseif ($info[9] <= 10000) { $a = "popular"; $alliance = $buildchange[0]; } elseif ($totaltotal >= ($etotaltotal / 2)) { # CHECK HOW MUCH LAND THE ENEMY HAS $enemydet[12] = $enemydet[14] + $enemydet[15] + $enemydet[16] + $enemydet[17] +$enemydet[18] + $enemydet[19] + $enemydet[20] + $enemydet[21]; # IF THEY HAD LESS THAN 10 ACRES, THEY'RE DEAD if ($enemydet[12] <= 10) { $killed = true; # TAKE THEIR MONEY $info[11] = $info[11] + $enemydet[11]; $info[21] = $info[21] + $enemydet[12]; # DELETE THEIR FILES $query = "DELETE FROM users WHERE username='$buildchange[1]'"; mysql_query($query) or die("Error: ".mysql_error()." ".$query); $query = "DELETE FROM messages WHERE receiver='$buildchange[1]'"; mysql_query($query) or die("Error: ".mysql_error()." ".$query); $query = "UPDATE alliances SET leader='$user' WHERE leader='$buildchange[1]'"; mysql_query($query) or die("Error: ".mysql_error()); # WRITE TO THE END OF THE ENEMY'S ALLIANCE NEWS $query = "INSERT INTO news SET sender='$user',receiver='$buildchange[1]',action='$info[5] attacked $buildchange[1]\[$buildchange[0]\] and killed him/her',day='$time',salliance='$info[24]',ralliance='$buildchange[0]',type='ATTACK'"; mysql_query($query) or die("Error: ".mysql_error()); # PUT EM ON THE DEAD LIST $query = "INSERT INTO deadlist SET username='$buildchange[1]',killer='$user',day='$time'"; mysql_query($query) or die("Error: ".mysql_error()); # ADD EXTRA DESCRIPTION $unrepair = 0; $erepair = 0; $bonus = ". Also killing the user. "; # IF THE USERS LAND WAS MORE THAN 10... } else { # KILLED VARIABLE IS NEGATIVE AND SO IS BONUS $killed = false; $bonus = " "; $percentwin = ($totaltotal >= $etotaltotal) ? 0.1 : (($totaltotal / $etotaltotal) /20); $percentloss = 1 - $percentwin; # CUT PERCENT OF THEIR MONEY AND REMOVE THE DECIMALS $mwinnings = round($enemydet[11] * $percentwin); # CUT PERCENT OF THEIR LAND AND REMOVE THE DECIMALS $winnings = round($enemydet[12] * $percentwin); # ADD THE LAND WINNINGS TO THE USER'S BARREN LAND AND ADD THE MONEY WINNINGS TO THE USER'S MONEY STASH $info[21] += $winnings; $info[11] += $mwinnings; # REMOVE THE MONEY AND LAND THAT THEY LOST $enemydet[11] -= $mwinnings; $landlost = 0; for ($i = 14; $i <= 21; $i++) { $landbefore = $enemydet[$i]; $enemydet[$i] = round($enemydet[$i] * $percentloss); $landlost += $landbefore - $enemydet[$i]; } $difference = $winnings - $landlost; if ($landlost < $winnings) { for ($j = 0; $j < $difference; $j++) { $rand = rand(14,21); $enemydet[$rand] -= ($enemydet[$rand] > 0) ? 1 : 0; } } # RECALCULATE THEIR AMOUNT OF LAND $enemydet[12] = $enemydet[14] + $enemydet[15] + $enemydet[16] + $enemydet[17] +$enemydet[18] + $enemydet[19] + $enemydet[20] + $enemydet[21]; # FIND OUT THE PERCENTAGE OF LAND THAT IS REPAIR BAYS AND USE IT TO CALCULATE LOSSES $unrepair = 1 - (0.9 + (($info[19] / $info[12]) / 10)); # CALCULATE THE LOSS OF EACH UNIT TYPE AND REMOVE DECIMALS $losses = array(); $elosses = array(); for ($i = 0; $i < 10; $i++) { $info[31 + $i] -= $buildchange[2 + $i] * $unrepair; $info[31 + $i] = ($info[31 + $i] < 0) ? 0 : round($info[31 + $i]); $losses[$i] = $original[31 + $i] - $info[31 + $i]; $info[41 + $i] -= $buildchange[2 + $i]; } # CALCULATE ENEMY REPAIR RATES FOR UNITS LOST AND UNITS LEFT $erepair = ($percentloss + (($enemydet[19] / $enemydet[12]) / 10)); # CALCULATE HOW MUCH OF EACH UNIT THEY HAVE LEFT AND HOW MNAY HAVE BEEN LOST AND REMOVE DECIMALS for ($i = 0; $i < 10; $i++) { $elosses[$i] = round((1 - $erepair) * $enemydet[31 + $i]); $enemydet[31 + $i] *= $erepair; $enemydet[31 + $i] = round($enemydet[31 + $i]); } # ADD UP DEFENSIVE VALUE OF EVERYTHING AND DIVIDE IT BY AMOUNT OF LAND TO GET NETWORTH $edt80 = $enemydet[31]; $edbmp = $enemydet[32] * 2; $edmi28 = $enemydet[33] * 3; $edah64 = $enemydet[34] * 3; $edrah66 = $enemydet[35] * 3; $edf16 = $enemydet[36] * 3; $edf117 = $enemydet[37] * 3; $edf22 = $enemydet[38] * 4; $edb52 = $enemydet[39] * 0; $edb2 = $enemydet[40] * 5; $edtur = $enemydet[18] * 5; $edstr = $enemydet[20] * 20; $ednetworth = $edt80 + $edbmp + $edmi28 + $edah64 + $edrah66 + $edf16 + $edf117 + $edf22 + $edb52 + $edb2 + $edtur + $edstr; $enemydet[26] = round($ednetworth / $enemydet[12]); # CALCLUATE USER ATTACK POINTS $edat80 = $enemydet[31]; $edabmp = $enemydet[32]; $edami28 = $enemydet[33]; $edaah64 = $enemydet[34] * 2; $edarah66 = $enemydet[35] * 3; $edaf16 = $enemydet[36] * 4; $edaf117 = $enemydet[37] * 5; $edaf22 = $enemydet[38] * 5; $edab52 = $enemydet[39] * 10; $edab2 = $enemydet[40] * 10; $eddefp = $ednetworth; $edattp = $edat80 + $edabmp + $edami28 + $edaah64 + $edarah66 + $edaf16 + $edaf117 + $edaf22 + $edab52 + $edab2; $enemydet[52] = round(($eddefp + $edattp) / 2); # CALCULATE RANKING if ($info[52] <= 500) { $info[8] = "Private"; } elseif ($info[52] <= 5000) { $info[8] = "Captain"; } elseif ($info[52] <= 50000) { $info[8] = "Major"; } elseif ($info[52] <= 500000) { $info[8] = "Lt. Colonel"; } elseif ($info[52] <= 1000000) { $info[8] = "Colonel"; } elseif ($info[52] <= 2500000) { $info[8] = "Major General"; } elseif ($info[52] <= 5000000) { $info[8] = "Lt. General"; } elseif ($info[52] > 5000000) { $info[8] = "General"; } # OPEN THE ENEMY FILE AND REWRITE ALL THE STUFF BY GOING THROUGH A LOOP $query = "UPDATE users SET "; $occurence = 0; for ($i = 0; $i < count($enemyoriginal); $i++) { if ($enemyoriginal[$i] != $enemydet[$i]) { if ($occurence!=0) { $query.=","; } switch($i) { case 0: $query .= "fullname"; break; case 1: $query .= "email"; break; case 2: $query .= "cemail"; break; case 3: $query .= "username"; break; case 4: $query .= "password"; break; case 5: $query .= "squadname"; break; case 6: $query .= "lastclick"; break; case 7: $query .= "protection"; break; case 8: $query .= "rank"; break; case 9: $query .= "lastday"; break; case 10: $query .= "lasthour"; break; case 11: $query .= "money"; break; case 12: $query .= "land"; break; case 13: $query .= "people"; break; case 14: $query .= "homes"; break; case 15: $query .= "farms"; break; case 16: $query .= "factories"; break; case 17: $query .= "hangars"; break; case 18: $query .= "turrets"; break; case 19: $query .= "repairbays"; break; case 20: $query .= "satellites"; break; case 21: $query .= "barren"; break; case 22: $query .= "spies"; break; case 23: $query .= "freeland"; break; case 24: $query .= "alliance"; break; case 25: $query .= "lastminute"; break; case 26: $query .= "networth"; break; case 27: $query .= "timer"; break; case 28: $query .= "messagecount"; break; case 29: $query .= "newscount"; break; case 30: $query .= "anewscount"; break; case 31: $query .= "t80"; break; case 32: $query .= "bmp"; break; case 33: $query .= "mi28"; break; case 34: $query .= "ah64"; break; case 35: $query .= "rah66"; break; case 36: $query .= "f16"; break; case 37: $query .= "f117"; break; case 38: $query .= "f22"; break; case 39: $query .= "b52"; break; case 40: $query .= "b2"; break; case 41: $query .= "t80a"; break; case 42: $query .= "bmpa"; break; case 43: $query .= "mi28a"; break; case 44: $query .= "ah64a"; break; case 45: $query .= "rah66a"; break; case 46: $query .= "f16a"; break; case 47: $query .= "f117a"; break; case 48: $query .= "f22a"; break; case 49: $query .= "b52a"; break; case 50: $query .= "b2a"; break; case 51: $query .= "aid"; break; case 52: $query .= "power"; break; } $query .= "='$enemydet[$i]'"; $occurence=1; } } $query .= " WHERE username='$buildchange[1]'"; if ($occurence != 0) { mysql_query($query) or die("Error Writing to Database: ".mysql_error()); } # OPEN THE ENEMY'S NEWS AND WRITE A MESSAGE ABOUT THE WAR $query = "INSERT INTO news SET sender='$user',receiver='$buildchange[1]',action='$info[5] attacked $buildchange[1]\[$buildchange[0]\] and won $winnings acres of land',day='$time',salliance='$info[24]',ralliance='$buildchange[0]',type='ATTACK'"; mysql_query($query) or die("Error: ".mysql_error()); # MAKE VARIABLES WRITING THE RESULTS OF THE WAR $warresult = "You won <a class='variable'>".$winnings."</a> acres of land and <a class='variable'>£".$mwinnings."</a> ".$bonus; $a = "added"; # IF THE USER DIDN'T WIN... } $info[9] -= 10000; } else { # FIND OUT THE PERCENTAGE OF LAND THAT IS REPAIR BAYS AND USE IT TO CALCULATE LOSSES $unrepair = 1 - (0.9 + (($info[19] / $info[12]) / 10)); $erepair = 1; # CALCULATE THE LOSS OF EACH UNIT TYPE AND REMOVE DECIMALS for ($i = 0; $i < 10; $i++) { $info[31 + $i] -= $buildchange[2 + $i] * $unrepair; $info[31 + $i] = ($info[31 + $i] < 0) ? 0 : round($info[31 + $i]); $losses[$i] = $original[31 + $i] - $info[31 + $i]; $info[41 + $i] -= $buildchange[2 + $i]; } # OPEN THE ENEMY'S NEWS AND WRITE A MESSAGE ABOUT THE WAR $query = "INSERT INTO news SET sender='$user',receiver='$buildchange[1]',action='$info[5] attacked $buildchange[1]\[$buildchange[0]\] and lost',day='$time',salliance='$info[24]',ralliance='$buildchange[0]',type='ATTACK ATTEMPT'"; mysql_query($query) or die("Error: ".mysql_error()); $warresult = "You lost"; $resultsound = "lose"; $a = "added"; $info[9] -= 10000; } } $alliance = $buildchange[0]; } else { $a = "change"; $alliance = $buildchange[0]; } } $alliance = ($alliance == 0) ? 1 : $alliance; include("incomeupdate.inc.php"); if (!$loadedincomeupdate) { mysql_close(); die("<br><br><center>incomeupdate couldnt be loaded</center></body></html>"); } include("newsupdate.inc.php"); if (!$loadednewsupdate) { mysql_close(); die("<br><br><center>newsupdate couldnt be loaded</center></body></html>"); } include("militaryupdate.inc.php"); if (!$loadedmilitaryupdate) { mysql_close(); die("<br><br><center>militaryupdate couldnt be loaded</center></body></html>"); } include("updateusers.inc.php"); if (!$loadedupdateusers) { mysql_close(); die("<br><br><center>updateusers couldnt be loaded</center></body></html>"); } include("statsbar.inc.php"); if (!$loadedstatsbar) { mysql_close(); die("<br><br><center>statsbar couldnt be loaded</center></body></html>"); } ?> <center> <?php if (!$info[24]) { echo "You need to be in an alliance to go to war"; } else { if ($a == "change") { echo "Alliance Changed<br><br><br>"; } elseif ($a == "added") { echo $warresult."<br><br>Your total AP: ".$totaltotal." <font color='#FF0000'>(".round($unrepair*100,1)."% losses)</font><br>Enemy total DP: ".$etotaltotal." <font color='#00FF00'>(".round((1-$erepair)*100,1)."% damage)</font><br><br>"; $unitnames = array("T80","BMP","Mi-28","AH-64","RAH-66","F-16","F-117","F-22","B52","B2"); $j = false; for ($i = 0; $i < 10; $i++) { if ($elosses[$i]) { if (!$j) { echo "You killed:<br>"; $j = true; } echo "<a class='variable'>".$elosses[$i]."</a> enemy ".$unitnames[$i]."s<br>"; } } if ($j) { echo "<br>"; } else { echo "You killed 0 enemy units<br><br>"; } $j = false; for ($i = 0; $i < 10; $i++) { if ($losses[$i]) { if (!$j) { echo "You lost:<br>"; $j = true; } echo "<a class='variable'>".$losses[$i]."</a> ".$unitnames[$i]."s<br>"; } } if ($j) { echo "<br>"; } else { echo "You lost 0 units<br><br>"; } echo "<br><br>"; } elseif ($a == "amount") { echo "You haven't got this amount of troops to send!<br><br><br>"; } elseif ($a == "cheater") { echo "Trying to cheat?<br><br><br>"; } elseif ($a == "ranker") { echo "This person is way out of your rank!<br><br><br>"; } elseif ($a == "weak") { echo "This person is under the three day protection<br><br><br>"; } elseif ($a == "prot") { echo "You are under 3 days protection and cannot attack anyone<br><br><br>"; } elseif ($a == "yourself") { echo "You cannot attack someone in you own alliance<br><br><br>"; } elseif ($a == "popular") { echo "Your civilians refuse to go to war for you.<br><br><br>"; } ?> <table width="90%" border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"> <table class="metal" cellpadding="3" cellspacing="3" width="100%"> <tr><td class="head"> <center> <font size="6"><b>War</b></font> </center> </td></tr> </table></th></tr> <tr><td width="33%" colspan="1" valign="top"><b><br> Welcome <a class="variable"><?php echo $info[8]." ".$info[0]; ?></a>. You're troops are ready for orders! Good Luck!</b></td> <td colspan="1" width="67%" valign="top"> <br><br> <center> <form action="war.php" method="post"> <table width="80%" cellpadding="3" cellspacing="3" class="metal"> <tr><td class="head" colspan="2">Attack Details</th></tr> <tr><td class="variable" colspan="1" width="50%" align="left"><b>Alliance:</b></td> <td class="variable" width="50%" colspan="1"><input type="text" name="alliance" value="<?php echo $alliance; ?>" size="5" class="text">0 - <?php $query = "SELECT count(allianceno) FROM alliances"; $result = mysql_query($query) or die("Error: ".mysql_error()); $alliances = array(); $alliances = mysql_fetch_array($result, MYSQL_NUM); echo $alliances[0]; ?> <input type="submit" name="send" value="Change" class="submit"></td></tr><tr><td class="variable"><b>Squad:</b></td><td class="variable"><select name="squad"> <?php $query = "SELECT username FROM users WHERE alliance='$alliance'"; $result = mysql_query($query) or die("Error: ".mysql_error()); $alli = array(); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $alli[] = $row[0]; } for ($i = 0; $i < count($alli); $i++) { echo '<option value="',$alli[$i],'">',$alli[$i]; } ?> </select> </td></tr> </table> <br><br> <table width="80%" class="metal" cellspacing="3" cellpadding="3"> <tr align="center"><td class="head">Type</th><td class="head">Available</th><td class="head">Send</th></tr> <tr align="center"><td class="variable"><b>T-80s:</b></td><td class="variable"><?php echo $info[41]." of ".$info[31]; ?></td><td class="variable"><input type="text" name="t80" size="5" class="text"></td></tr> <tr align="center"><td class="variable"><b>BMPs:</b></td><td class="variable"><?php echo $info[42]." of ".$info[32]; ?></td><td class="variable"><input type="text" name="bmp" size="5" class="text"></td></tr> <tr align="center"><td class="variable"><b>Mi-28s:</b></td><td class="variable"><?php echo $info[43]." of ".$info[33]; ?></td><td class="variable"><input type="text" name="mi28" size="5" class="text"></td></tr> <tr align="center"><td class="variable"><b>AH-64s:</b></td><td class="variable"><?php echo $info[44]." of ".$info[34]; ?></td><td class="variable"><input type="text" name="ah64" size="5" class="text"></td></tr> <tr align="center"><td class="variable"><b>RAH-66s:</b></td><td class="variable"><?php echo $info[45]." of ".$info[35]; ?></td><td class="variable"><input type="text" name="rah66" size="5" class="text"></td></tr> <tr align="center"><td class="variable"><b>F-16s:</b></td><td class="variable"><?php echo $info[46]." of ".$info[36]; ?></td><td class="variable"><input type="text" name="f16" size="5" class="text"></td></tr> <tr align="center"><td class="variable"><b>F-117s:</b></td><td class="variable"><?php echo $info[47]." of ".$info[37]; ?></td><td class="variable"><input type="text" name="f117" size="5" class="text"></td></tr> <tr align="center"><td class="variable"><b>F-22s:</b></td><td class="variable"><?php echo $info[48]." of ".$info[38]; ?></td><td class="variable"><input type="text" name="f22" size="5" class="text"></td></tr> <?php if (($info[8] == "Private") || ($info[8] == "Captain")) { ?> <tr align="center"><td class="variable"><b>B-52s:</b></td><td class="variable"><?php echo $info[49]." of ".$info[39]; ?></td><td class="variable"><input type="text" name="b52" size="5" class="text" disabled></td></tr> <?php } else { ?> <tr align="center"><td class="variable"><b>B-52s:</b></td><td class="variable"><?php echo $info[49]." of ".$info[39]; ?></td><td class="variable"><input type="text" name="b52" size="5" class="text"></td></tr> <?php } if (($info[8] == "Private") || ($info[8] == "Captain") || ($info[8] == "Major")) { ?> <tr align="center"><td class="variable"><b>B-2s:</b></td><td class="variable"><?php echo $info[50]." of ".$info[40]; ?></td><td class="variable"><input type="text" name="b2" size="5" class="text" disabled></td></tr> <?php } else { ?> <tr align="center"><td class="variable"><b>B-2s:</b></td><td class="variable"><?php echo $info[50]." of ".$info[40]; ?></td><td class="variable"><input type="text" name="b2" size="5" class="text"></td></tr> <?php } ?> </table> <input type="submit" value=" Send " class="submit"> </form> </th></tr> </table> <?php } ?> </center> </body> </html> <?php mysql_close(); ?> The problem is that, the extra bonus part is not working, when the user is killed. $bonus = ". Also killing the user. "; this is not outputted at the bottom of the page. when a user is killed in the game, absoloutly nothing is outputted, its just like it refreshs the page. another problem concerns (most probably): # FIND OUT THE PERCENTAGE OF LAND THAT IS REPAIR BAYS AND USE IT TO CALCULATE LOSSES $unrepair = 1 - (0.9 + (($info[19] / $info[12]) / 10)); # CALCULATE THE LOSS OF EACH UNIT TYPE AND REMOVE DECIMALS $losses = array(); $elosses = array(); for ($i = 0; $i < 10; $i++) { $info[31 + $i] -= $buildchange[2 + $i] * $unrepair; $info[31 + $i] = ($info[31 + $i] < 0) ? 0 : round($info[31 + $i]); $losses[$i] = $original[31 + $i] - $info[31 + $i]; $info[41 + $i] -= $buildchange[2 + $i]; } # CALCULATE ENEMY REPAIR RATES FOR UNITS LOST AND UNITS LEFT $erepair = ($percentloss + (($enemydet[19] / $enemydet[12]) / 10)); # CALCULATE HOW MUCH OF EACH UNIT THEY HAVE LEFT AND HOW MNAY HAVE BEEN LOST AND REMOVE DECIMALS for ($i = 0; $i < 10; $i++) { $elosses[$i] = round((1 - $erepair) * $enemydet[31 + $i]); $enemydet[31 + $i] *= $erepair; $enemydet[31 + $i] = round($enemydet[31 + $i]); } the problem with the code there, that i yet have to understand, is when a user is attacked and has full repair bays, they actually gain units, rather than still loose them. info19 is repairbays, info12 land. some of this may be easier to understand if you played the game i guess. just to make things a little easier to understand, here is the update list: case 0: $query .= "fullname"; break; case 1: $query .= "email"; break; case 2: $query .= "cemail"; break; case 3: $query .= "username"; break; case 4: $query .= "password"; break; case 5: $query .= "squadname"; break; case 6: $query .= "lastclick"; break; case 7: $query .= "protection"; break; case 8: $query .= "rank"; break; case 9: $query .= "lastday"; break; case 10: $query .= "lasthour"; break; case 11: $query .= "money"; break; case 12: $query .= "land"; break; case 13: $query .= "people"; break; case 14: $query .= "homes"; break; case 15: $query .= "farms"; break; case 16: $query .= "factories"; break; case 17: $query .= "hangars"; break; case 18: $query .= "turrets"; break; case 19: $query .= "repairbays"; break; case 20: $query .= "satellites"; break; case 21: $query .= "barren"; break; case 22: $query .= "spies"; break; case 23: $query .= "freeland"; break; case 24: $query .= "alliance"; break; case 25: $query .= "lastminute"; break; case 26: $query .= "networth"; break; case 27: $query .= "timer"; break; case 28: $query .= "messagecount"; break; case 29: $query .= "newscount"; break; case 30: $query .= "anewscount"; break; case 31: $query .= "t80"; break; case 32: $query .= "bmp"; break; case 33: $query .= "mi28"; break; case 34: $query .= "ah64"; break; case 35: $query .= "rah66"; break; case 36: $query .= "f16"; break; case 37: $query .= "f117"; break; case 38: $query .= "f22"; break; case 39: $query .= "b52"; break; case 40: $query .= "b2"; break; case 41: $query .= "t80a"; break; case 42: $query .= "bmpa"; break; case 43: $query .= "mi28a"; break; case 44: $query .= "ah64a"; break; case 45: $query .= "rah66a"; break; case 46: $query .= "f16a"; break; case 47: $query .= "f117a"; break; case 48: $query .= "f22a"; break; case 49: $query .= "b52a"; break; case 50: $query .= "b2a"; break; case 51: $query .= "aid"; break; case 52: $query .= "power"; break; so, anyone have any ideas how to solve either of these annoying problems? Quote Link to comment Share on other sites More sharing options...
mforan Posted October 22, 2008 Author Share Posted October 22, 2008 im guessing no one understands this? or cannot see a problem ? ??? ??? Quote Link to comment Share on other sites More sharing options...
philipolson Posted October 22, 2008 Share Posted October 22, 2008 Basically it's too much code to read and understand here. I suggest starting the debugging process by writing stuff like die("HELLO!"); in places so you know that part of the code executes, and when you see it does, move to somewhere else. Quote Link to comment Share on other sites More sharing options...
mforan Posted October 22, 2008 Author Share Posted October 22, 2008 gotcha.... have u got any ideas as to why it might be giving + units for the repairbays part? <?php # FIND OUT THE PERCENTAGE OF LAND THAT IS REPAIR BAYS AND USE IT TO CALCULATE LOSSES $unrepair = 1 - (0.9 + (($info[19] / $info[12]) / 10)); # CALCULATE THE LOSS OF EACH UNIT TYPE AND REMOVE DECIMALS $losses = array(); $elosses = array(); for ($i = 0; $i < 10; $i++) { $info[31 + $i] -= $buildchange[2 + $i] * $unrepair; $info[31 + $i] = ($info[31 + $i] < 0) ? 0 : round($info[31 + $i]); $losses[$i] = $original[31 + $i] - $info[31 + $i]; $info[41 + $i] -= $buildchange[2 + $i]; } # CALCULATE ENEMY REPAIR RATES FOR UNITS LOST AND UNITS LEFT $erepair = ($percentloss + (($enemydet[19] / $enemydet[12]) / 10)); # CALCULATE HOW MUCH OF EACH UNIT THEY HAVE LEFT AND HOW MNAY HAVE BEEN LOST AND REMOVE DECIMALS for ($i = 0; $i < 10; $i++) { $elosses[$i] = round((1 - $erepair) * $enemydet[31 + $i]); $enemydet[31 + $i] *= $erepair; $enemydet[31 + $i] = round($enemydet[31 + $i]); } ?> you see, bascially if the target user has full repairbays, after they are attacked they gain units. rather than not loose any. Quote Link to comment Share on other sites More sharing options...
philipolson Posted October 22, 2008 Share Posted October 22, 2008 No, but you should start printing stuff to see what these variables contain. Quote Link to comment Share on other sites More sharing options...
prexep Posted October 23, 2008 Share Posted October 23, 2008 The $bonus is only outputted once. Which is on line 487. It only outputs only the else statement (line 180) which its if starts at 142. So the $bonus will never output something unless its on the else statement which equals a space. Quote Link to comment Share on other sites More sharing options...
mforan Posted October 24, 2008 Author Share Posted October 24, 2008 i see what u meen now. how the hell do i make it display?? rearange the ifs and code ?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.