- Joined
- Dec 11, 2014
- Messages
- 17
- Reaction score
- 1
PHP:
<?php
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 ( $Resets == 0 ) { $new_res = '1'; $exp = '35774999'; $clevel = '150'; }
if ( $Resets == 1 ) { $new_res = '2'; $exp = '35774999'; $clevel = '150'; }
if ( $Resets == 2 ) { $new_res = '3'; $exp = '83599999'; $clevel = '200'; }
if ( $Resets == 3 ) { $new_res = '4'; $exp = '83599999'; $clevel = '200'; }
if ( $Resets == 4 ) { $new_res = '6'; $exp = '161874999'; $clevel = '250'; }
if ( $Resets == 5 ) { $new_res = '7'; $exp = '161874999'; $clevel = '250'; }
if ( $Resets == 7 ) { $new_res = '8'; $exp = '2802876999'; $clevel = '300'; }
if ( $Resets == 8 ) { $new_res = '8'; $exp = '2802876999'; $clevel = '300'; }
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 = $clevel, Experience = $exp 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;
}
I'm using this code for resetting at every stage as u can see but i'm having some problems, the scripts works but when i reset character it does 1 reset starts from 150 and finish there, any solution?