Jump to content

Fairly simple problem


LemonInflux

Recommended Posts

 //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 ($range & 1){ $range = $range*195-65; }
else { $range = $range*195; }

if ($magic & 1){ $magic = $magic*195-65; }
else { $magic = $magic*195; }

$melee_combat = ($attack*130 + $strength*130)/400;
$range_combat = $range/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; ?>

 

This script works out RuneScape combat levels (not 100% accurate). The problem is, it doesn't seem to work. When I type <?PHP echo $combat_level ?>, absolutely nothing shows on the page. I'm guessing this is a math script error, but I didn't put it in the math section just in case. Any ideas, anyone?

Link to comment
Share on other sites

<?php

$username = $_POST['username'];

$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]);

//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 ($range && 1){ $range = $range*195-65; }
else { $range = $range*195; }

if ($magic && 1){ $magic = $magic*195-65; }
else { $magic = $magic*195; }

$melee_combat = ($attack*130 + $strength*130)/400;
$range_combat = $range/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; ?>

<?php echo $combat_level; ?>

Link to comment
Share on other sites

Wait, I showed you the wrong code >_>

 

<?php
//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 ($range && 1){ $range = $range*195-65; }
else { $range = $range*195; }

if ($magic && 1){ $magic = $magic*195-65; }
else { $magic = $magic*195; }

$melee_combat = ($attack*130 + $strength*130)/400;
$range_combat = $range/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;

$username = $_REQUEST['username'];


$username = strtolower($username);
$username = ucwords($username);


$website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username);

$stats = explode("\n", $website);
$overall = explode(",", $stats[0]);
$stat['att'] = explode(",", $stats[1]);
$stat['def'] = explode(",", $stats[2]);
$stat['str'] = explode(",", $stats[3]);
$stat['hp'] = explode(",", $stats[4]);
$stat['rng'] = explode(",", $stats[5]);
$stat['pry'] = explode(",", $stats[6]);
$stat['mag'] = explode(",", $stats[7]);
$stat['ck'] = explode(",", $stats[8]);
$stat['wc'] = explode(",", $stats[9]);
$stat['fsh'] = explode(",", $stats[11]);
$stat['fm'] = explode(",", $stats[12]);
$stat['cra'] = explode(",", $stats[13]);
$stat['smi'] = explode(",", $stats[14]);
$stat['min'] = explode(",", $stats[15]);
$stat['rc'] = explode(",", $stats[21]);



$image_link = 'http://reflexprojects.net/Assets/Images/stats/sigbg/sig8.png';
$image = imagecreatefrompng($image_link);

//this is the font. You must include the filetype
$font = 'arial.ttf';
$font_colour = imagecolorallocate($image, 255, 255, 255);
$font_size = 12; 

// x axis
//first number is x position for column 1
//second number is x position for cloumn 2
//third number is x position for column 3
//fourth number is x position for column 4
//fifth number is x position for column 5
$x = array('30', '82', '135', '187');

// y axis
//first number is y position for row 1
//second number is y position for row 2
//third number is y position for row 3
//fourth number is y position for row 4
//fifth number is y position for row 5
$y = array('49', '74', '99', '124', '149'); 

$i = '0';
$a = '0';
foreach($stat as $s_key => $value){
imagettftext($image, $font_size, 0, $x[$a], $y[$i], $font_colour, $font , $value[1]);
$i++;
if($i == '5'){
	$i = '0';
	$a++;
}
}

imagettftext($image, $font_size, 0, '208', '53', $font_colour, $font , ' ' . $combat_level);
imagettftext($image, $font_size, 0, '200', '24', $font_colour, $font , ' ' . $overall[1]);
imagettftext($image, $font_size, 0, '40', '24', $font_colour, $font , $username);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

 

It writes to an image, but as you can see at the moment here:

 

output1.php?username=zezima&fakeparm=.gif

 

it writes it as '0', no matter what it is.

Link to comment
Share on other sites

variable $prayer is array and you can not do some math with it

in your example it is array( 146, 99, 14019128)

try

<?php
$username = $_POST['username'];

$website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player='.$username);
$stats = explode("\n", $website);
//print_r($stats);
$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]);

//calculate base combat
if ($prayer[1] & 1) { $prayer[1] = ($prayer[1] - 1)*50; }
else { $prayer[1] = $prayer[1]*50; }
$base_combat = ($defence[1]*100 + $hitpoints[1]*100 + $prayer[1])/400;

//calculate personal class combats for melee, ranged and mage
if ($range[1] & 1){ $range[1] = $range[1]*195-65; }
else { $range[1] = $range[1]*195; }

if ($magic[1] & 1){ $magic[1] = $magic[1]*195-65; }
else { $magic[1] = $magic[1]*195; }

$melee_combat = ($attack[1]*130 + $strength[1]*130)/400;
$range_combat = $range[1]/400;
$mage_combat = $magic[1]/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

I've deleted it now.

 

but uuuh...It was sasa's in

<?php

$username = $_REQUEST['username'];


$username = strtolower($username);
$username = ucwords($username);


$website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username);

$stats = explode("\n", $website);
$overall = explode(",", $stats[0]);
$stat['att'] = explode(",", $stats[1]);
$stat['def'] = explode(",", $stats[2]);
$stat['str'] = explode(",", $stats[3]);
$stat['hp'] = explode(",", $stats[4]);
$stat['rng'] = explode(",", $stats[5]);
$stat['pry'] = explode(",", $stats[6]);
$stat['mag'] = explode(",", $stats[7]);
$stat['ck'] = explode(",", $stats[8]);
$stat['wc'] = explode(",", $stats[9]);
$stat['fsh'] = explode(",", $stats[11]);
$stat['fm'] = explode(",", $stats[12]);
$stat['cra'] = explode(",", $stats[12]);
$stat['smi'] = explode(",", $stats[14]);
$stat['min'] = explode(",", $stats[15]);
$stat['rc'] = explode(",", $stats[21]);

$image_link = 'http://reflexprojects.net/Assets/Images/stats/sigbg/sig8.png';
$image = imagecreatefrompng($image_link);

//this is the font. You must include the filetype
$font = 'arial.ttf';
$font_colour = imagecolorallocate($image, 255, 255, 255);
$font_size = 12; 

// x axis
//first number is x position for column 1
//second number is x position for cloumn 2
//third number is x position for column 3
//fourth number is x position for column 4
//fifth number is x position for column 5
$x = array('30', '82', '135', '187');

// y axis
//first number is y position for row 1
//second number is y position for row 2
//third number is y position for row 3
//fourth number is y position for row 4
//fifth number is y position for row 5
$y = array('49', '74', '99', '124', '149'); 

$i = '0';
$a = '0';
foreach($stat as $s_key => $value){
imagettftext($image, $font_size, 0, $x[$a], $y[$i], $font_colour, $font , $value[1]);
$i++;
if($i == '5'){
	$i = '0';
	$a++;
}
}

imagettftext($image, $font_size, 0, '200', '124', $font_colour, $font , ' ' . $combat_level);
imagettftext($image, $font_size, 0, '200', '24', $font_colour, $font , ' ' . $overall[1]);
imagettftext($image, $font_size, 0, '40', '24', $font_colour, $font , $username);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

 

the first imagettftext co-ords were made up, though. They're not the ones I used.

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.