LemonInflux Posted August 29, 2007 Share Posted August 29, 2007 OK, I shall say here and now there is probably a very basic error with this code, but meh. I'm not a PHP expert, in all truth. Here's the code: <?PHP $username = $_GET['username']; $username = strtolower($username); $username = ucwords($username); ?> <?PHP $website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player='.$username); $stats = explode("\n", $website); $overall = explode(",", $stats[0]); $attack = explode(",", $stats[1]); $defence = explode(",", $stats[2]); $strength = explode(",", $stats[3]); $hitpoints = explode(",", $stats[4]); $range = explode(",", $stats[5]); $prayer = explode(",", $stats[6]); $magic = explode(",", $stats[7]); $cooking = explode(",", $stats[8]); $woodcutting = explode(",", $stats[9]); $fletching = explode(",", $stats[10]); $fishing = explode(",", $stats[11]); $firemaking = explode(",", $stats[12]); $crafting = explode(",", $stats[13]); $smithing = explode(",", $stats[14]); $mining = explode(",", $stats[15]); $herblore = explode(",", $stats[16]); $agility = explode(",", $stats[17]); $thieving = explode(",", $stats[18]); $slayer = explode(",", $stats[19]); $farming = explode(",", $stats[20]); $runecrafting = explode(",", $stats[21]); $hunting = explode(",", $stats[22]); $construction = explode(",", $stats[23]); if ($att[1] == 1) { $att[1] = " "; } if ($str[1] == 1) { $str[1] = " "; } if ($def[1] == 1) { $def[1] = " "; } if ($hp[1] == 1) { $hp[1] = " "; } if ($rng[1] == 1) { $rng[1] = " "; } if ($pry[1] == 1) { $pry[1] = " "; } if ($mag[1] == 1) { $mag[1] = " "; } if ($ck[1] == 1) { $ck[1] = " "; } if ($wc[1] == 1) { $wc[1] = " "; } if ($flt[1] == 1) { $flt[1] = " "; } if ($fsh[1] == 1) { $fsh[1] = " "; } if ($fm[1] == 1) { $fm[1] = " "; } if ($cra[1] == 1) { $cra[1] = " "; } if ($smi[1] == 1) { $smi[1] = " "; } if ($min[1] == 1) { $min[1] = " "; } if ($her[1] == 1) { $her[1] = " "; } if ($ag[1] == 1) { $ag[1] = " "; } if ($th[1] == 1) { $th[1] = " "; } if ($sl[1] == 1) { $sl[1] = " "; } if ($frm[1] == 1) { $frm[1] = " "; } if ($rc[1] == 1) { $rc[1] = " "; } if ($hun[1] == 1) { $hun[1] = " "; } if ($cs[1] == 1) { $cs[1] = " "; } ?> //calculate base combat if ($prayer & 1) { $prayer = ($prayer - 1)*50; } else { $prayer = $prayer*50; } $base_combat = ($defence*100 + $hitpoints*100 + $prayer)/400; //calculate personal class combats for melee, ranged and mage if ($ranged & 1){ $ranged = $ranged*195-65; } else { $ranged = $ranged*195; } if ($magic & 1){ $magic = $magic*195-65; } else { $magic = $magic*195; } $melee_combat = ($attack*130 + $strength*130)/400; $range_combat = $ranged/400; $mage_combat = $magic/400; //calculate final class combat (get max personal combat) if ($melee_combat >= $range_combat & $melee_combat >= $mage_combat) { $class_combat = $melee_combat; } elseif ($range_combat >= $melee_combat & $range_combat >= $mage_combat) { $class_combat = $range_combat; } else $class_combat = $mage_combat; //finalize combat level $combat_level = $class_combat + $base_combat; echo $combat_level; Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/ Share on other sites More sharing options...
LemonInflux Posted August 29, 2007 Author Share Posted August 29, 2007 Note: I mean this bit: //calculate base combat if ($prayer & 1) { $prayer = ($prayer - 1)*50; } else { $prayer = $prayer*50; } $base_combat = ($defence*100 + $hitpoints*100 + $prayer)/400; //calculate personal class combats for melee, ranged and mage if ($ranged & 1){ $ranged = $ranged*195-65; } else { $ranged = $ranged*195; } if ($magic & 1){ $magic = $magic*195-65; } else { $magic = $magic*195; } $melee_combat = ($attack*130 + $strength*130)/400; $range_combat = $ranged/400; $mage_combat = $magic/400; //calculate final class combat (get max personal combat) if ($melee_combat >= $range_combat & $melee_combat >= $mage_combat) { $class_combat = $melee_combat; } elseif ($range_combat >= $melee_combat & $range_combat >= $mage_combat) { $class_combat = $range_combat; } else $class_combat = $mage_combat; //finalize combat level $combat_level = $class_combat + $base_combat; Everything else is ok. Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/#findComment-337011 Share on other sites More sharing options...
AndyB Posted August 29, 2007 Share Posted August 29, 2007 Why doesn't this work? What is/isn't it not doing/doing that you expect/hope for? Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/#findComment-337079 Share on other sites More sharing options...
Ken2k7 Posted August 29, 2007 Share Posted August 29, 2007 http://www.phpfreaks.com/forums/index.php/topic,157233.0.html Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/#findComment-337082 Share on other sites More sharing options...
LemonInflux Posted August 29, 2007 Author Share Posted August 29, 2007 I want the formula to work. The long code in the second post has an error, I think, because if you add under it <?PHP echo $combat_level ?>, nothing happens (see http://www.reflexprojects.net/rs/combat_in.htm) Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/#findComment-337089 Share on other sites More sharing options...
LemonInflux Posted August 29, 2007 Author Share Posted August 29, 2007 I'll try that. Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/#findComment-337091 Share on other sites More sharing options...
chocopi Posted August 29, 2007 Share Posted August 29, 2007 I think you meant to post http://www.reflexprojects.net/rs/combat_in.php Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/#findComment-337100 Share on other sites More sharing options...
LemonInflux Posted August 29, 2007 Author Share Posted August 29, 2007 yeah, sorry. Quote Link to comment https://forums.phpfreaks.com/topic/67184-why-doesnt-this-work/#findComment-337102 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.