<?php
//if(!$login) { echo "<img src='img/l.gif' OnLoad=\"location.reload();\">"; }
$account = secure($_COOKIE['username']);
$maximumgrandresets = $shopy['misc']['maximum_grandresets'];
$grandresetlevel = $shopy['misc']['grandreset_level'];
$grandresetprice = $shopy['misc']['grandreset_price'];
echo "<table align='center' class='fborder'>
<div align='center' style='font-size: 15px; padding-top: 3px; padding-bottom: 3px; margin-top: 5px; margin-bottom: 0px;'>Grand Reset Character information:</div>
<tr>
<td class='proba'> </td>
<tr><td align='center'>1. Maximum restarts: ".$maximumgrandresets."</td></tr>
<tr><td align='center'>2. Character must be at least ".$grandresetlevel." level to Reset!</td></tr>
<tr><td align='center'>3. Grand Reset Character costs ".number_format($grandresetprice)." zen.</td></tr>
<tr><td align='center'>4. Please remove all items from your personal store (Shop) before reset.</td></tr>
<tr><td align='center'>5. After the restart your character will be at level 1. </td></tr>
<tr><td align='center'>6. With every reset you get stronger and stronger.</td></tr>
<tr><td align='center'>7. Your character will appear in the select menu, when you are at least ".$grandresetlevel." level.</td></tr>
<td> </td>
</tr>
</table>";
$i = 0;
$query = mssql_query("SELECT * FROM Character WHERE AccountID='".$account."' AND cLevel>=".$grandresetlevel."");
while($char = mssql_fetch_array($query))
{
if($char['Name'] == $_GET['char'])
{
$bann = " selected";
}
else
{
$bann = "";
}
$mychars .= "<option value='".htmlspecialchars($char['Name'])."'$bann>".$char['Name']."</option>";
$i++;
}
echo "<center>Character: <select id='char'><optgroup label='Select a char'>$mychars</select><br /><input type='submit' class='button' OnClick=\"ajax('greset&'+doc('char'),'Character Reset '+document.getElementById('char').value)\" value='Grand Reset Character '></center>";
if($_GET['char'])
{
$online = mssql_fetch_array(mssql_query("SELECT * FROM MEMB_STAT WHERE memb___id='".$account."' AND ConnectStat = 1"));
$chara = mssql_fetch_array(mssql_query("SELECT * FROM Character WHERE Name = '".secure($_GET['char'])."'"));
$requiredresets = $shopy['misc']['grandreset_required_resets'];
$currentgrandresets = $chara['Grand_Resets'];
$newpoints = ($currentgrandresets+1) * $shopy['misc']['grandreset_bonuspoints'];
$bonus = $chara['LevelUpPoint'] + $shopy['misc']['grandreset_bonuspoints'];
$bonuswebshopcredits = $shopy['misc']['grandreset_bonuscredits'];
if(@$online)
{
$output = "Your account is online. Must to be offline to use this function.";
$error = true;
}
else if($chara['cLevel'] < $grandresetlevel)
{
$output = "Error: Character ".$chara['Name']." haven't got ".$grandresetlevel." level to reset.";
$error = true;
}
else if($chara['Resets'] < $requiredresets)
{
$output = "Error: Character ".$chara['Name']." don't have ".number_format($requiredresets)." resets.";
$error = true;
}
else if($currentgrandresets >= $maximumgrandresets)
{
$output = "Error: Character ".$chara['Name']." have reached the maximum grand resets.";
$error = true;
}
else if($chara['Money'] < $grandresetprice)
{
$output = "Error: Character ".$chara['Name']." haven't got ".number_format($grandresetprice)." money to reset.";
$error = true;
}
else if(!$error)
{
if($shopy['misc']['grandreset_type'] == "keep")
{
mssql_query("Update Character Set Money=Money-".$grandresetprice.",clevel=1,Experience=0,Resets=Resets-".$requiredresets.",Grand_Resets=Grand_Resets+1 WHERE Name='".$chara['Name']."'");
}
else if($shopy['misc']['grandreset_type'] == "bonus")
{
mssql_query("Update Character Set Money=Money-".$grandresetprice.",clevel=1,Experience=0,Resets=Resets-".$requiredresets.",Grand_Resets=Grand_Resets+1, LevelUpPoint=".$bonus." WHERE Name='".$chara['Name']."'");
}
else if($shopy['misc']['grandreset_type'] == "reset")
{
mssql_query("Update Character Set Strength=25,Dexterity=25,Vitality=25,Energy=25,LeaderShip=25,Money=Money-".$grandresetprice.",clevel=1,Experience=0,Resets=Resets-".$requiredresets.",Grand_Resets=Grand_Resets+1,LevelUpPoint=".$newpoints." WHERE Name='".$chara['Name']."'");
}
if($bonuswebshopcredits > 0)
{
if(mssql_num_rows(mssql_query("SELECT * FROM MEMB_CREDITS WHERE memb___id='".$account."'")) == 0)
{
mssql_query("INSERT INTO MEMB_CREDITS(memb___id, credits) VALUES('".$account."', ".$bonuswebshopcredits.")");
}
else
{
mssql_query("UPDATE MEMB_CREDITS SET credits=credits+".$bonuswebshopcredits." WHERE memb___id='".$account."'");
}
}
$output = "Character ".$chara['Name']." successfully restarted and now is ".number_format($currentgrandresets+1)." grand resets. <img src='img/l.gif' Onload=\"logged()\">";
}
echo "<br /><center>".$output."</center><br /><br />";
}
?>