Welcome Guest [Log In] [Register]
Welcome to iPeer. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
RuneScape EXP Script
Topic Started: Apr 28 2009, 02:13 AM (406 Views)
iPeer
If you have used Spirals XP script, you'll know what this is. I'll admit, it's not the tidiest PHP script in the world, but it does the job, and most importantly, it's right (bar a few exceptions, but they're only 1 out)!

Demo (also contains examples): Link

Code:
 
<?php /* PHP RuneScape Exp Calc... thing - made by iPeer (DreamScripting) */

/*
* This works exactly the same as it would in mSL (if it could run PHP that is!)
* A script identical to this can be found on my bot (Spiral, mSL version)
* This script does NOT support exp values (?exp=*) with commas (EX: 1,234,567 (<- Would return "1"))
* Some values on EXP (?exp=*) are ONE exp out.
* Have fun!
*/

function exp2($lev,$mode) {
$x = 1;
$levl = ($lev - 1);
$xp = 0;
// Setting var defaults before evaluating
while ($x <= $levl) {
$TempXp = (floor(($x + 300 * pow(2,($x / 7)))) / 4);
// mSL is very similar: var %TempXp = $calc($floor($calc(%x + 300 * 2 ^ (%x / 7))) / 4)
$xp += $TempXp;
// "Includes" $xp by the value of $TempXp
$x++;
// Adds 1 to the level.
}
if ($mode == 1) $xp--;
return $xp;
}
function exp2lvl($lvl,$experience,$mode) {
$lvl = 1;
while (exp2($lvl,0) <= $experience) {
$lvl++;
}
$lvl--;
// Decreases the level to make it the correct one.
return $lvl;
}

$lvl = $_GET['lvl']; $goal = $_GET['goal']; $exp1 = $_GET['exp']; // Info Vars

if ($exp1) { // Checking for EXP2LEVEL
$exp2level = exp2lvl($lvl,$exp1,1);
$expdiff = "(+".number_format($exp1 - exp2($exp2level,0)).")";
echo number_format($exp1)." exp is level $exp2level $expdiff";
}
elseif ($lvl && $goal) { // Checking for LVL2LVL
if ($goal < $lvl) { echo "Goal must be HIGHER than level."; exit ; }
$goalexp = exp2($goal,0);
$mainexp = exp2($lvl,0);
echo "From $lvl to $goal is ".number_format(floor($goalexp - $mainexp + 1)). " exp.";
}
elseif ($lvl && !$goal) { // Checking for LVL
echo "EXP at level $lvl: ".number_format(exp2($lvl,0));
}
else { // Invalid.
echo "Please supply an exp value, level or a level and a goal.<br />\nExamples:<br /><a href=\"".$_SERVER['PHP_SELF']."?exp=13456789\">Experience</a><br /><a href=\"".$_SERVER['PHP_SELF']."?lvl=95\">Level</a><br /><a href=\"".$_SERVER['PHP_SELF']."?lvl=95&goal=99\">Goal</a>";
}
?>
Member Avatar
Did the green bottles really fall or were they pushed?!

Posted ImagePosted Image
I couldn't decide which I liked more, so I have both ^.^
Posted ImagePosted ImagePosted ImagePosted Image
Click on an Image to feed them! | Get One For Yourself!
Quote Post Goto Top Offline Profile
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · PHP Script Showcase · Next Topic »
Add Reply