Jump to content

Why doesn't this work


LemonInflux

Recommended Posts

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;

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.