// rc = Reset Character
$option['rc_level'] = 400; // Level required to reset a character
$option['rc_zen'] = 1000000; // Zen required to reset a character
$option['rc_zen_type'] = 0; // Increase required zen for every reset: 1 = enable, 0 = disable
$option['rc_stats_type'] = 1; // Increase stats for every reset(1r=500,2r=1000,...): 1 = enable, 0 = disable
$option['rc_max_resets'] = 100; // Max resets
$option['rc_stats_per_reset'] = 0; // Bonus stats per reset
$option['rc_clear_stats'] = 0; // Clear stats after reset: 1 = enable, 0 = disable
// Bonus points for every class
$option['rc_bonus_points'] = 0; // Bonus points for every class: 1 = enable, 0 = disable
$option['rc_stats_for_sm'] = 300; // Points for dw,sm and grm
$option['rc_stats_for_bk'] = 400; // Points for dk,bk and bm
$option['rc_stats_for_me'] = 500; // Points for elf,me and he
$option['rc_stats_for_mg'] = 600; // Points for mg and dum
$option['rc_stats_for_dl'] = 700; // Points for dl and le
function do_reset_character()
{
global $option;
$acc = $_SESSION['dt_username'];
$char = $_POST['character'];
$show_msg=array(
'error'=>array()
);
if(empty($char))
{
$show_msg['error'][] = 'Please select a character!';
}
elseif(preg_match('/[^a-zA-Z0-9\_\-]/', $char))
{
$show_msg['error'][] = 'Invalid symbols!';
}
elseif(strlen($char) < 3 || strlen($char) > 10)
{
$show_msg['error'][] = 'Invalid Character Name!';
}
else
{
$is_acc_char = mssql_num_rows(
mssql_query("SELECT Name FROM Character WHERE AccountID='". $acc ."' AND Name='". $char ."'")
);
$is_online=is_online($char, 1);
$character=char_info($char);
$new_res=($character['Resets'] + 1);
if($option['rc_zen_type'] === 1)
{
$option['rc_zen'] = ($option['rc_zen'] * $new_res);
}
$new_money=($character['Money'] - $option['rc_zen']);
if($option['rc_bonus_points'] == 1)
{
switch($character['Class'])
{
case 0:
case 1:
case 2:
$option['rc_stats_per_reset'] = $option['rc_stats_for_sm'];
break;
case 16:
case 17:
case 18:
$option['rc_stats_per_reset'] = $option['rc_stats_for_bk'];
break;
case 32:
case 33:
case 34:
$option['rc_stats_per_reset'] = $option['rc_stats_for_me'];
break;
case 48:
case 49:
$option['rc_stats_per_reset'] = $option['rc_stats_for_mg'];
break;
case 64:
case 65:
$option['rc_stats_per_reset'] = $option['rc_stats_for_dl'];
break;
}
}
$level_up_points = $option['rc_stats_per_reset'];
if($option['rc_stats_type'] === 1)
{
$level_up_points = $level_up_points * $new_res;
}
if($option['rc_gr_bonus'] === 1)
{
$level_up_points += ($option['gr_reward'] * $character['GrandResets']);
}
if($is_acc_char == 0)
{
$show_msg['error'][] = 'This character is not yours!';
}
elseif($is_online === 1)
{
$show_msg['error'][] = 'You need to leave the game!';
}
elseif($character['cLevel'] < $option['rc_level'])
{
$show_msg['error'][] = 'You need '.($option['rc_level'] - $character['cLevel']).' more levels!';
}
elseif($new_money < 0)
{
$show_msg['error'][] = 'You don't have enough money(zen)!';
}
elseif($new_res > $option['rc_max_resets'])
{
$show_msg['error'][] = 'You have reach the maximum resets!';
}
else
{
$sql='UPDATE Character SET ';
if($option['rc_clear_stats'] === 1)
{
$sql .='Strength = 25, Dexterity = 25, Vitality = 25, Energy = 25, ';
}
$sql .="Resets = ".$new_res.", Money = ".$new_money.", LevelUpPoint = ".$level_up_points.",cLevel = 1,Experience = 0 WHERE Name='".$character['Name']."' AND AccountID='".$acc."'";
mssql_query($sql);
$show_msg['success'][0] = $char .' have successfully reset for '.$new_res.' time.';
}
}
return $show_msg;
}