function reset_character()
{
global $resetmoney;
global $resettype;
global $resetpoints;
global $resetclearinv;
global $resetclearskill;
global $maxresets;
global $resetlevel;
$character = secure($_POST['character']);
$account = secure($_POST['login']);
$password = secure($_POST['password']);
check_inject();
$query = mssql_query("Select clevel,resets,money,leveluppoint from Character where Name='$character'");
$row = mssql_fetch_row($query);
$newmoney = $row[2]-$resetmoney;
$newresets = $row[1] + 1;
if($row[1] >= 1) { $newpoints = $row[1] * $resetpoints; }
$newleveluppoints = $row[3] + $resetpoints;
$queryaccount = mssql_query("Select * from MEMB_INFO where memb___id='$account'");
$accountcheck = mssql_num_rows($queryaccount);
$queryonline = mssql_query("Select * from MEMB_STAT where memb___id='$account' and connectstat='1'");
$onlinecheck = mssql_num_rows($queryonline);
$querypassword = mssql_query("Select * from MEMB_INFO where memb___id='$account' and memb__pwd='$password'");
$passwordcheck = mssql_num_rows($querypassword);
$querychar = mssql_query("Select * from Character where Name='$character'");
$charcheck = mssql_num_rows($querychar);
if(empty($character) or empty($account) or empty($password)) { echo"<font color='red'>You cannot leave any fields blank!</font><br>"; $error=1; }
elseif($accountcheck <= 0) { echo"<font color='red'>Your Login does not exist in our database. Please go back and try again!</font><br>"; $error=1; }
elseif($passwordcheck <= 0) { echo"<font color='red'>Your Password does not exist in our database. Please go back and try again!</font><br>"; $error=1; }
elseif($charcheck <= 0) { echo"<font color='red'>Your Character does not exist in our database. Please go back and try again!</font><br>"; $error=1; }
else
{
if($newmoney < 0) { echo"<font color='red'>Character $character dones not have enough money to reset!</font><br>"; $error=1;}
if($row[0] < $resetlevel) { echo"<font color='red'>Character $character must be $resetlevel in order to reset!</font><br>"; $error=1;}
if($newresets > $maxresets) { echo"<font color='red'>Character $character is maximum resets!</font><br>"; $error=1;}
if($onlinecheck >= 1) { echo"<font color='red'>Account $account is online!Please LogOff First!</font><br>"; $error=1;}
if($error != 1)
{
echo"<font color='green'>Character $character has been succesfully restarted.</font><br>";
if($resettype == keep)
{
$a = mssql_query("Update Character Set Money='$newmoney',clevel='1',Experience='0',Resets='$newresets' where name='$character'");
}
elseif($resettype == bonus)
{
$a = mssql_query("Update Character Set Money='$newmoney',clevel='1',Experience='0',Resets='$newresets',LevelUpPoint='$newpoints' where name='$character'");
}
elseif($resettype == reset)
{
$a = mssql_query("Update Character Set Strength='25',Dexterity='25',Vitality='25',Energy='25' ,Money='$newmoney',clevel='1',Experience='0',Resets='$newresets',LevelUpPoint='$newpoints' where name='$character'");
}
if($resetclearinv == yes) { $b = mssql_query("UPDATE Character set Inventory=CONVERT(varbinary(1080), null) WHERE Name='$character'"); }
if($resetclearskill == yes) { $c = mssql_query("Update Character set magiclist= CONVERT(varbinary(60), null) WHERE Name='$character'"); }
}
}
}