Hey guys i decided to share with you a cool php script that could come in handy,
What this does is. it gets the Rs highscores for the selected user using the highscores api
and then it sorts it in arrays to be used later on in the script.The script is pretty much self explanatory
What this does is. it gets the Rs highscores for the selected user using the highscores api
and then it sorts it in arrays to be used later on in the script.The script is pretty much self explanatory
- Code:
<?php
// *Check if data was submitted
if (!isset($_GET['username']))
{
echo '
<form id="search" class="form" action="" method="get">
<input type="text" name="username" type="text" size="15" placeholder="RS username" />
</form>
';
}
else
{
$name = $_GET["username"];
//*Check if the form is empty
if ($name == "")
{
echo '
<form id="search" class="form" action="" method="get">
<input type="text" name="username" type="text" size="15" placeholder="RS username" />
</form>
<p>Please Write your username</p>
';
}
else // *If the form is not empty, continue with downloading highscores.
{
$rawdata = file_get_contents("http://hiscore.Rs.com/index_lite.ws?player=$name");
fclose($rawdata);
$name = ucwords($name);
if (!$rawdata == "")
{
//Replace "-1" with zero.
$data = str_replace("-1", "0", $rawdata);
//Divide the stats into an array
$SplitSkill = explode("\n",$data);
//Divide each skill into array by Rank/Level/XP
$Overall = explode(",",$SplitSkill[0]);
$Attack = explode(",",$SplitSkill[1]);
$Defence = explode(",",$SplitSkill[2]);
$Strength = explode(",",$SplitSkill[3]);
$Constitution = explode(",",$SplitSkill[4]);
$Ranged= explode(",",$SplitSkill[5]);
$Prayer = explode(",",$SplitSkill[6]);
$Magic= explode(",",$SplitSkill[7]);
$Cooking = explode(",",$SplitSkill[8]);
$Woodcutting = explode(",",$SplitSkill[9]);
$Fletching = explode(",",$SplitSkill[10]);
$Fishing = explode(",",$SplitSkill[11]);
$Firemaking = explode(",",$SplitSkill[12]);
$Crafting = explode(",",$SplitSkill[13]);
$Smithing = explode(",",$SplitSkill[14]);
$Mining = explode(",",$SplitSkill[15]);
$Herblore = explode(",",$SplitSkill[16]);
$Agility = explode(",",$SplitSkill[17]);
$Thieving = explode(",",$SplitSkill[18]);
$Slayer = explode(",",$SplitSkill[19]);
$Farming = explode(",",$SplitSkill[20]);
$Runecrafting = explode(",",$SplitSkill[21]);
$Hunter = explode(",",$SplitSkill[22]);
$Construction = explode(",",$SplitSkill[23]);
$Summoning = explode(",",$SplitSkill[24]);
$Dungeoneering = explode(",",$SplitSkill[25]);
$Divination = explode(",",$SplitSkill[26]);
//Add Commas to Values + Names
for ($i=0; $i<=3; $i++)
{
$Overall[$i] = number_format($Overall[$i]);
$Attack[$i] = number_format($Attack[$i]);
$Defence[$i] = number_format($Defence[$i]);
$Strength[$i] = number_format($Strength[$i]);
$Constitution[$i] = number_format($Constitution[$i]);
$Ranged[$i] = number_format($Ranged[$i]);
$Prayer[$i] = number_format($Prayer[$i]);
$Magic[$i] = number_format($Magic[$i]);
$Cooking[$i] = number_format($Cooking[$i]);
$Woodcutting[$i] = number_format($Woodcutting[$i]);
$Fletching[$i] = number_format($Fletching[$i]);
$Fishing[$i] = number_format($Fishing[$i]);
$Firemaking[$i] = number_format($Firemaking[$i]);
$Crafting[$i] = number_format($Crafting[$i]);
$Smithing[$i] = number_format($Smithing[$i]);
$Mining[$i] = number_format($Mining[$i]);
$Herblore[$i] = number_format($Herblore[$i]);
$Agility[$i] = number_format($Agility[$i]);
$Thieving[$i] = number_format($Thieving[$i]);
$Slayer[$i] = number_format($Slayer[$i]);
$Farming[$i] = number_format($Farming[$i]);
$Runecrafting[$i] = number_format($Runecrafting[$i]);
$Hunter[$i] = number_format($Hunter[$i]);
$Construction[$i] = number_format($Construction[$i]);
$Summoning[$i] = number_format($Summoning[$i]);
$Dungeoneering[$i] = number_format($Dungeoneering[$i]);
$Divination[$i] = number_format($Divination[$i]);
}
//Put your code here [0]=rank [1]=Level [2]=Experience
echo '
<b>Insert html here</b><br />
<b>'. $name.' Divination level is:'.$Divination[1].'</b>
';
}
else
{
echo '
<form id="search" class="form" action="" method="get">
<input type="text" name="username" type="text" size="15" placeholder="RS username" />
</form>
<b>*'.$name.' not found in highscores.</b>
';
}
}
}
?>
- Spoiler:
Rs Avatar:
- Code:
<img src="http://services.Rs.com/m=avatar-rs/'. $name.'/chat.png">
- Code:
<img src="http://services.Rs.com/m=avatar-rs/'. $name.'/full.png">
- Code:
<img src="http://services.Rs.com/m=avatar-rs/'. $name.'/ownclan.png">