percentage.php

$total = $_POST['total']; $skill = array( //This is the base level for the skill "attack" => $_POST['attack'], //0 "strength" => $_POST['strength'], //1 "defence" => $_POST['defence'], //2 "range" => $_POST['range'], //3 "prayer" => $_POST['prayer'], //4 "magic" => $_POST['magic'], //5 "runecrafting" => $_POST['runecrafting'], //6 "construction" => $_POST['construction'], //7 "hitpoints" => $_POST['hitpoints'], //8 "agility" => $_POST['agility'], //9 "herblore" => $_POST['herblore'], //10 "thieving" => $_POST['thieving'], //11 "crafting" => $_POST['crafting'], //12 "fletching" => $_POST['fletching'], //13 "slayer" => $_POST['slayer'], //14 "hunter" => $_POST['hunter'], //15 "mining" => $_POST['mining'], //16 "smithing" => $_POST['smithing'], //17 "fishing" => $_POST['fishing'], //18 "cooking" => $_POST['cooking'], //19 "firemaking" => $_POST['firemaking'], //20 "woodcutting" => $_POST['woodcutting'], //21 "farming" => $_POST['farming'], //22 ); foreach($skill as $skill_name => $skill_value) { if(!is_numeric($skill_value)) { die($skill_name , 'did not have a numeric value!'); } else { echo "Skill=" , $skill_name , "Value=" , $skill_value; echo get_percentage($skill_goal,$skill_value).'%<br>'; echo "<br>"; } } if(!isset($_GET['method')) { //if the method is not set, $method = 'level'; //default it to level } elseif($_GET['method'] == 'experience') { //method is set to experience $method = 'experience'; //set method to experience in the code } else { //nothing interesting happens $method = 'level'; //set method to level anyway } function get_percentage($total, $number) { if ( $total > 0 ) { //total should be greater than 0 return round($number / ($total / 100),2); //formula to find percentage } else { return 0; //$total is less than 0 } }
partial script for finding percentage to goal for runescape (oldschool)

yes i know it's a mess; im still working on it :)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.