PDA

View Full Version : [MU] Reset vip netbanbe



huuthao
14-08-12, 12:34 AM
reset vip của cũng phải giới hạn time theo reset thường
có cách nào reset vip không cần time được kg

The Gamer
14-08-12, 11:24 AM
bản nào ? thiếu file giới hạn rs

huuthao
14-08-12, 01:05 PM
có cách nào reset vip không cần time giúp mình với

huuthao
15-08-12, 01:49 PM
upppppppppppppppppppppppppppppppppppppppppppppppp

apple
15-08-12, 02:46 PM
reset:

<?php
include_once("security.php");
include_once('config.php');
include_once('config/config_reset.php');
include_once('config/config_hotrotanthu.php');
include_once('config/config_gioihanrs.php');
include_once('config/config_relife.php');
include_once('config/config_event.php');
include_once('function.php');

$login = $_POST['login'];
$name = $_POST['name'];

$resetnow = $_POST['resetnow']; $resetnow = abs(intval($resetnow));

$passtransfer = $_POST['passtransfer'];

if ($passtransfer == $transfercode) {

$string_login = $_POST['string_login'];
checklogin($login,$string_login);

fixrs($name);
check_resetday();
check_resetmonth();

$inventory_query = "SELECT Inventory FROM Character WHERE AccountID = '$login' AND Name='$name'";

kiemtra_doinv($login,$name);
kiemtra_online($login);

$inventory_result_sql = $db->Execute($inventory_query);
$inventory_result = $inventory_result_sql->fetchrow();

$sql_PkLevel_check = $db->Execute("SELECT PkLevel FROM Character WHERE PkLevel > 3 and Name='$name'");
$PkLevel_check = $sql_PkLevel_check->numrows();

$sql_char_back_reged_check = $db->Execute("SELECT Name FROM Character_back WHERE Name='$name' and AccountID = '$login'");
$char_back_reged_check = $sql_char_back_reged_check->numrows();

$result = $db->Execute("Select Clevel,Resets,Money,LevelUpPoint,Class,Relifes,NoR esetInDay,Resets_Time, Top50 From Character where Name='$name'");
$row = $result->fetchrow();

if($resetnow >0 && abs(intval($row[1])) == 0) {
echo "Hệ thống Reset bị gián đoạn. Vui lòng Reset lại";
exit();
}

$vpoint_result = $db->Execute("Select vpoint From MEMB_INFO where memb___id='$login'");
$vpoint = $vpoint_result->fetchrow();

$check_jewel = $db->Execute("SELECT jewel_chao,jewel_cre,jewel_blue FROM MEMB_INFO WHERE memb___id='$login'");
$jewel = $check_jewel->fetchrow();

$thehe_result = $db->Execute("Select thehe From MEMB_INFO where memb___id='$login'");
$thehe_fetch = $thehe_result->fetchrow();
$thehe = $thehe_fetch[0];

$inventory = $inventory_result[0];
$inventory = bin2hex($inventory);
$inventory3 = substr($inventory,76*32,32*32);
$inventory3 = strtoupper($inventory3);

$no_item = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
for ($i=0;$i<32;$i++) $shop_empty .= $no_item;

if ($inventory3 != $shop_empty) { echo "Cửa hàng cá nhân có vật phẩm. Vui lòng bỏ ra khỏi cửa hàng cá nhân để tránh bị mất đồ."; exit(); }

$CountNoResetInDay=$row[6]+1;

//Begin Giới hạn Reset trong ngày

//End Giới hạn Reset trong ngày

if ($PkLevel_check > 0){
echo "Bạn đang là Sát thủ. Phải rửa tội trước khi Reset."; exit();
}

if ( ($row[1] >= $reset_cap_0) AND ($row[1] < $reset_cap_1) )
{
$level = $level_cap_1;
$zen = $zen_cap_1;
$time_reset_next = $time_reset_next_1;
$chao = $chao_cap_1;
$cre = $cre_cap_1;
$blue = $blue_cap_1;
}
elseif ( ($row[1] >= $reset_cap_1) AND ($row[1] < $reset_cap_2) )
{
$level = $level_cap_2;
$zen = $zen_cap_2;
$time_reset_next = $time_reset_next_2;
$chao = $chao_cap_2;
$cre = $cre_cap_2;
$blue = $blue_cap_2;
}
elseif ( ($row[1] >= $reset_cap_2) AND ($row[1] < $reset_cap_3) )
{
$level = $level_cap_3;
$zen = $zen_cap_3;
$time_reset_next = $time_reset_next_3;
$chao = $chao_cap_3;
$cre = $cre_cap_3;
$blue = $blue_cap_3;
}
elseif ( ($row[1] >= $reset_cap_3) AND ($row[1] < $reset_cap_4) )
{
$level = $level_cap_4;
$zen = $zen_cap_4;
$time_reset_next = $time_reset_next_4;
$chao = $chao_cap_4;
$cre = $cre_cap_4;
$blue = $blue_cap_4;
}
elseif ( ($row[1] >= $reset_cap_4) AND ($row[1] < $reset_cap_5) )
{
$level = $level_cap_5;
$zen = $zen_cap_5;
$time_reset_next = $time_reset_next_5;
$chao = $chao_cap_5;
$cre = $cre_cap_5;
$blue = $blue_cap_5;
}
elseif ( ($row[1] >= $reset_cap_5) AND ($row[1] < $reset_cap_6) )
{
$level = $level_cap_6;
$zen = $zen_cap_6;
$time_reset_next = $time_reset_next_6;
$chao = $chao_cap_6;
$cre = $cre_cap_6;
$blue = $blue_cap_6;
}
elseif ( ($row[1] >= $reset_cap_6) AND ($row[1] < $reset_cap_7) )
{
$level = $level_cap_7;
$zen = $zen_cap_7;
$time_reset_next = $time_reset_next_7;
$chao = $chao_cap_7;
$cre = $cre_cap_7;
$blue = $blue_cap_7;
}
elseif ( ($row[1] >= $reset_cap_7) AND ($row[1] < $reset_cap_8) )
{
$level = $level_cap_8;
$zen = $zen_cap_8;
$time_reset_next = $time_reset_next_8;
$chao = $chao_cap_8;
$cre = $cre_cap_8;
$blue = $blue_cap_8;
}
elseif ( ($row[1] >= $reset_cap_8) AND ($row[1] < $reset_cap_9) )
{
$level = $level_cap_9;
$zen = $zen_cap_9;
$time_reset_next = $time_reset_next_9;
$chao = $chao_cap_9;
$cre = $cre_cap_9;
$blue = $blue_cap_9;
}
elseif ( ($row[1] >= $reset_cap_9) AND ($row[1] < $reset_cap_10) )
{
$level = $level_cap_10;
$zen = $zen_cap_10;
$time_reset_next = $time_reset_next_10;
$chao = $chao_cap_10;
$cre = $cre_cap_10;
$blue = $blue_cap_10;
}
elseif ( ($row[1] >= $reset_cap_10) AND ($row[1] < $reset_cap_11) )
{
$level = $level_cap_11;
$zen = $zen_cap_11;
$time_reset_next = $time_reset_next_11;
$chao = $chao_cap_11;
$cre = $cre_cap_11;
$blue = $blue_cap_11;
}
elseif ( ($row[1] >= $reset_cap_11) AND ($row[1] < $reset_cap_12) )
{
$level = $level_cap_12;
$zen = $zen_cap_12;
$time_reset_next = $time_reset_next_12;
$chao = $chao_cap_12;
$cre = $cre_cap_12;
$blue = $blue_cap_12;
}
elseif ( ($row[1] >= $reset_cap_12) AND ($row[1] < $reset_cap_13) )
{
$level = $level_cap_13;
$zen = $zen_cap_13;
$time_reset_next = $time_reset_next_13;
$chao = $chao_cap_13;
$cre = $cre_cap_13;
$blue = $blue_cap_13;
}
elseif ( ($row[1] >= $reset_cap_13) AND ($row[1] < $reset_cap_14) )
{
$level = $level_cap_14;
$zen = $zen_cap_14;
$time_reset_next = $time_reset_next_14;
$chao = $chao_cap_14;
$cre = $cre_cap_14;
$blue = $blue_cap_14;
}
elseif ( ($row[1] >= $reset_cap_14) AND ($row[1] < $reset_cap_15) )
{
$level = $level_cap_15;
$zen = $zen_cap_15;
$time_reset_next = $time_reset_next_15;
$chao = $chao_cap_15;
$cre = $cre_cap_15;
$blue = $blue_cap_15;
}
elseif ( ($row[1] >= $reset_cap_15) AND ($row[1] < $reset_cap_16) )
{
$level = $level_cap_16;
$zen = $zen_cap_16;
$time_reset_next = $time_reset_next_16;
$chao = $chao_cap_16;
$cre = $cre_cap_16;
$blue = $blue_cap_16;
}
elseif ( ($row[1] >= $reset_cap_16) AND ($row[1] < $reset_cap_17) )
{
$level = $level_cap_17;
$zen = $zen_cap_17;
$time_reset_next = $time_reset_next_17;
$chao = $chao_cap_17;
$cre = $cre_cap_17;
$blue = $blue_cap_17;
}
elseif ( ($row[1] >= $reset_cap_17) AND ($row[1] < $reset_cap_18) )
{
$level = $level_cap_18;
$zen = $zen_cap_18;
$time_reset_next = $time_reset_next_18;
$chao = $chao_cap_18;
$cre = $cre_cap_18;
$blue = $blue_cap_18;
}
elseif ( ($row[1] >= $reset_cap_18) AND ($row[1] < $reset_cap_19) )
{
$level = $level_cap_19;
$zen = $zen_cap_19;
$time_reset_next = $time_reset_next_19;
$chao = $chao_cap_19;
$cre = $cre_cap_19;
$blue = $blue_cap_19;
}
elseif ( ($row[1] >= $reset_cap_19) AND ($row[1] < $reset_cap_20) )
{
$level = $level_cap_20;
$zen = $zen_cap_20;
$time_reset_next = $time_reset_next_20;
$chao = $chao_cap_20;
$cre = $cre_cap_20;
$blue = $blue_cap_20;
}

//Begin hỗ trợ tân thủ
if ($hotrotanthu == 1) {
$Resetnow = $row[1];
$Relifenow = $row[5];

if ( 1 <= $capsudung && $cap1_reset_min <= $row[1] && $row[1] <= $cap1_reset_max && $cap1_relife_min <= $row[5] && $row[5] <= $cap1_relife_max )
{
$level -= $cap1_levelgiam;
}
else if ( 2 <= $capsudung && $cap2_reset_min <= $row[1] && $row[1] <= $cap2_reset_max && $cap2_relife_min <= $row[5] && $row[5] <= $cap2_relife_max )
{
$level -= $cap2_levelgiam;
}
else if ( 3 <= $capsudung && $cap3_reset_min <= $row[1] && $row[1] <= $cap3_reset_max && $cap3_relife_min <= $row[5] && $row[5] <= $cap3_relife_max )
{
$level -= $cap3_levelgiam;
}
else if ( 4 <= $capsudung && $cap4_reset_min <= $row[1] && $row[1] <= $cap4_reset_max && $cap4_relife_min <= $row[5] && $row[5] <= $cap4_relife_max )
{
$level -= $cap4_levelgiam;
}
else if ( 5 <= $capsudung && $cap5_reset_min <= $row[1] && $row[1] <= $cap5_reset_max && $cap5_relife_min <= $row[5] && $row[5] <= $cap5_relife_max )
{
$level -= $cap5_levelgiam;
}
}
//End hỗ trợ tân thủ


switch ($row[5]) {
case 0:
$reset_relifes = $rl_reset_relife1;
$point_relifes = 0;
$ml_relifes = 0;
break;
case 1:
$reset_relifes = $rl_reset_relife2;
$point_relifes = $rl_point_relife1;
$ml_relifes = $rl_ml_relife1;
break;
case 2:
$reset_relifes = $rl_reset_relife3;
$point_relifes = $rl_point_relife2;
$ml_relifes = $rl_ml_relife2;
break;
case 3:
$reset_relifes = $rl_reset_relife4;
$point_relifes = $rl_point_relife3;
$ml_relifes = $rl_ml_relife3;
break;
case 4:
$reset_relifes = $rl_reset_relife5;
$point_relifes = $rl_point_relife4;
$ml_relifes = $rl_ml_relife4;
break;
case 5:
$reset_relifes = $rl_reset_relife6;
$point_relifes = $rl_point_relife5;
$ml_relifes = $rl_ml_relife5;
break;
case 6:
$reset_relifes = $rl_reset_relife7;
$point_relifes = $rl_point_relife6;
$ml_relifes = $rl_ml_relife6;
break;
case 7;
$reset_relifes = $rl_reset_relife8;
$point_relifes = $rl_point_relife7;
$ml_relifes = $rl_ml_relife7;
break;
case 8:
$reset_relifes = $rl_reset_relife9;
$point_relifes = $rl_point_relife8;
$ml_relifes = $rl_ml_relife8;
break;
case 9:
$reset_relifes = $rl_reset_relife10;
$point_relifes = $rl_point_relife9;
$ml_relifes = $rl_ml_relife9;
break;
case 10:
$reset_relifes = $rl_reset_relife11;
$point_relifes = $rl_point_relife10;
$ml_relifes = $rl_ml_relife10;
break;
}

if ( $row[1] >= $reset_relifes ) {
echo "$name đang ReLife: $row[5] - Reset: $row[1]. Để Reset tiếp bạn cần phải ReLife."; exit();
}

$relife = $row[5];
$resetold = $row[1]; $resetold = abs(intval($resetold));
$resetup = $resetold + 1;


//Cong thuc Reset
if ( ($jewel[0] < $chao) OR ($jewel[1] < $cre) OR ($jewel[2] < $blue) )
{
echo "Bạn không đủ Jewel trong ngân hàng.<br>Số lần Reset hiện tại của bạn là $row[1]. Bạn cần $chao Chao , $cre Creation , $blue Blue Feather."; exit();
}
if ($row[0] < $level) {echo "$name cần $level level để Reset lần $resetup."; exit();}
if ($row[2] < $zen) {echo "$name cần $zen Zen để Reset lần $resetup."; exit();}

$time_reset_next = $row[7]+$time_reset_next*60;
if ($time_reset_next > $timestamp) {
$time_free = $time_reset_next - $timestamp;
echo "$name cần $time_free giây nữa để Reset lần tiếp theo."; exit();
}

//Reset lần 1
if ($row[1] == $reset_cap_0)
{
$resetpoint=$point_relifes+$point_cap_1;
$resetmoeny = $row[2] - $zen_cap_1;
$leadership = $ml_relifes+$ml_cap_1;
}
//Reset cấp 1
elseif ($row[1] < $reset_cap_1)
{
$resetpoint=$point_relifes+$point_cap_1+$row[1]*$point_cap_1;
$resetmoeny = $row[2] - $zen_cap_1;
$leadership = $ml_relifes+$ml_relifes+$ml_cap_1+$row[1]*$ml_cap_1;
}
//Reset cấp 1 -> 2
elseif ($row[1] >= $reset_cap_1 AND $row[1] < $reset_cap_2)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($row[1]-($reset_cap_1-1))*$point_cap_2;
$resetmoeny = $row[2] - $zen_cap_2;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $row[1]-($reset_cap_1-1))*$ml_cap_2;
}
//Reset cấp 2 -> 3
elseif ($row[1] >= $reset_cap_2 AND $row[1] < $reset_cap_3)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$point_cap_3;
$resetmoeny = $row[2] - $zen_cap_3;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$ml_cap_3;
}
//Reset cấp 3 -> 4
elseif ($row[1] >= $reset_cap_3 AND $row[1] < $reset_cap_4)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$point_cap_4;
$resetmoeny = $row[2] - $zen_cap_4;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$ml_cap_4;
}
//Reset cấp 4 -> 5
elseif ($row[1] >= $reset_cap_4 AND $row[1] < $reset_cap_5)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$point_cap_5;
$resetmoeny = $row[2] - $zen_cap_5;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$ml_cap_5;
}
//Reset cấp 5 -> 6
elseif ($row[1] >= $reset_cap_5 AND $row[1] < $reset_cap_6)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$point_cap_6;
$resetmoeny = $row[2] - $zen_cap_6;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$ml_cap_6;
}
//Reset cấp 6 -> 7
elseif ($row[1] >= $reset_cap_6 AND $row[1] < $reset_cap_7)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$point_cap_7;
$resetmoeny = $row[2] - $zen_cap_7;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$ml_cap_7;
}
//Reset cấp 7 -> 8
elseif ($row[1] >= $reset_cap_7 AND $row[1] < $reset_cap_8)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$point_cap_8;
$resetmoeny = $row[2] - $zen_cap_8;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$ml_cap_8;
}
//Reset cấp 8 -> 9
elseif ($row[1] >= $reset_cap_8 AND $row[1] < $reset_cap_9)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$point_cap_9;
$resetmoeny = $row[2] - $zen_cap_9;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$ml_cap_9;
}
//Reset cấp 9 -> 10
elseif ($row[1] >= $reset_cap_9 AND $row[1] < $reset_cap_10)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$point_cap_10;
$resetmoeny = $row[2] - $zen_cap_10;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$ml_cap_10;
}
//Reset cấp 10 -> 11
elseif ($row[1] >= $reset_cap_10 AND $row[1] < $reset_cap_11)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$point_cap_11;
$resetmoeny = $row[2] - $zen_cap_11;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$ml_cap_11;
}
//Reset cấp 11 -> 12
elseif ($row[1] >= $reset_cap_11 AND $row[1] < $reset_cap_12)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$point_cap_12;
$resetmoeny = $row[2] - $zen_cap_12;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$ml_cap_12;
}
//Reset cấp 12 -> 13
elseif ($row[1] >= $reset_cap_12 AND $row[1] < $reset_cap_13)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$point_cap_13;
$resetmoeny = $row[2] - $zen_cap_13;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$ml_cap_13;
}
//Reset cấp 13 -> 14
elseif ($row[1] >= $reset_cap_13 AND $row[1] < $reset_cap_14)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$point_cap_14;
$resetmoeny = $row[2] - $zen_cap_14;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$ml_cap_14;
}
//Reset cấp 14 -> 15
elseif ($row[1] >= $reset_cap_14 AND $row[1] < $reset_cap_15)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$point_cap_15;
$resetmoeny = $row[2] - $zen_cap_15;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$ml_cap_15;
}
//Reset cấp 15 -> 16
elseif ($row[1] >= $reset_cap_15 AND $row[1] < $reset_cap_16)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$point_cap_16;
$resetmoeny = $row[2] - $zen_cap_16;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$ml_cap_16;
}
//Reset cấp 16 -> 17
elseif ($row[1] >= $reset_cap_16 AND $row[1] < $reset_cap_17)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$point_cap_17;
$resetmoeny = $row[2] - $zen_cap_17;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$ml_cap_17;
}
//Reset cấp 17 -> 18
elseif ($row[1] >= $reset_cap_17 AND $row[1] < $reset_cap_18)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($point_cap_17*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$point_cap_18;
$resetmoeny = $row[2] - $zen_cap_18;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($ml_cap_17*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$ml_cap_18;
}
//Reset cấp 18 -> 19
elseif ($row[1] >= $reset_cap_18 AND $row[1] < $reset_cap_19)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($point_cap_17*($reset_cap_17-$reset_cap_16))+($point_cap_18*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$point_cap_19;
$resetmoeny = $row[2] - $zen_cap_19;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($ml_cap_17*($reset_cap_17-$reset_cap_16))+($ml_cap_18*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$ml_cap_19;
}
//Reset cấp 19 -> 20
elseif ($row[1] >= $reset_cap_19 AND $row[1] < $reset_cap_20)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($point_cap_17*($reset_cap_17-$reset_cap_16))+($point_cap_18*($reset_cap_18-$reset_cap_17))+($point_cap_19*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$point_cap_20;
$resetmoeny = $row[2] - $zen_cap_20;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($ml_cap_17*($reset_cap_17-$reset_cap_16))+($ml_cap_18*($reset_cap_18-$reset_cap_17))+($ml_cap_19*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$ml_cap_20;
}
//Fix Menh lenh DarkLord > 32k
if ( $leadership>32000 ) $leadership=32000;


$ClassType = $row[4];
switch ($ClassType){
case 0:
case 1:
case 2:
case 3:
$Class_Default = 0;
break;

case 16:
case 17:
case 18:
case 19:
$Class_Default = 16;
break;

case 32:
case 33:
case 34:
case 35:
$Class_Default = 32;
break;

case 48:
case 49:
case 50:
$Class_Default = 48;
break;

case 64:
case 65:
case 66:
$Class_Default = 64;
break;

case 80:
case 81:
case 82:
case 83:
$Class_Default = 80;
break;

case 96:
case 97:
case 98:
$Class_Default = 96;
break;

default :
$Class_Default = 0;
}
$default_query = "SELECT Strength, Dexterity, Vitality, Energy, Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY FROM DefaultClassType WHERE Class=" . $Class_Default;
$default_result = $db->execute($default_query);
check_queryerror($default_query, $default_result);
$point_default = $default_result->fetchrow();
$Strength_Default = $point_default[0];
$Dexterity_Default = $point_default[1];
$Vitality_Default = $point_default[2];
$Energy_Default = $point_default[3];
$Life_Default = $point_default[4];
$MaxLife_Default = $point_default[5];
$Mana_Default = $point_default[6];
$MaxMana_Default = $point_default[7];
$MapNumber_Default = $point_default[8];
$MapPosX_Default = $point_default[9];
$MapPosY_Default = $point_default[10];


$Strength = $Strength_Default;
$Dexterity = $Dexterity_Default;
$Vitality = $Vitality_Default;
$Energy = $Energy_Default;
$Life = $Life_Default;
$MaxLife = $MaxLife_Default;
$Mana = $Mana_Default;
$MaxMana = $MaxMana_Default;
$MapNumber = $MapNumber_Default;
$MapPosX = $MapPosX_Default;
$MapPosY = $MapPosY_Default;
$Mapdir=0;

$Point_Default_total = $Strength + $Dexterity + $Vitality + $Energy;

//End Cong thuc Reset

//Tat ca cac Quest
$all_quest="Update character set Quest=0xaaeaffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffff where name='$name'";
if( intval($level_after_reset) >1 ) $clevel = $level_after_reset;
else $clevel = 1;

$point_event_qr = $db->Execute("SELECT point_event FROM Character WHERE Name='$name'");
$point_event = $point_event_qr->fetchrow();
$resetpoint = $resetpoint + $point_event[0];

if( $resetpoint > 65000) {
$pointup = 65000;
$resetpoint = $resetpoint - 65000;
} else {
$pointup = $resetpoint;
$resetpoint = 0;
}

switch ($month)
{
case '01' : $fieldtopmonth = 'TopMonth01'; break;
case '02' : $fieldtopmonth = 'TopMonth02'; break;
case '03' : $fieldtopmonth = 'TopMonth03'; break;
case '04' : $fieldtopmonth = 'TopMonth04'; break;
case '05' : $fieldtopmonth = 'TopMonth05'; break;
case '06' : $fieldtopmonth = 'TopMonth06'; break;
case '07' : $fieldtopmonth = 'TopMonth07'; break;
case '08' : $fieldtopmonth = 'TopMonth08'; break;
case '09' : $fieldtopmonth = 'TopMonth09'; break;
case '10' : $fieldtopmonth = 'TopMonth10'; break;
case '11' : $fieldtopmonth = 'TopMonth11'; break;
case '12' : $fieldtopmonth = 'TopMonth12'; break;
default : $fieldtopmonth = 'TopMonth01';
}

kiemtra_doinv($login,$name);
kiemtra_online($login);

// Reset nhan vat la Darklord
if ($row[4] == 64 OR $row[4] == 65 OR $row[4] == 66)
{
$sql_reset_script="Update dbo.character set [clevel]='$clevel',[experience]='0',[money]='$resetmoeny',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='0',[Leadership]='$leadership',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='0',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script) or die("Lỗi Query: $sql_reset_script");

//Nhan vat dang ki tai sinh
if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup, [LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Leadership]='$leadership',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
}
}

//Reset nhan vat khong phai la DarkLord
else
{
$sql_reset_script="Update Character set [clevel]='$clevel',[experience]='0',[money]='$resetmoeny',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='$Mapdir',[Leadership]='0',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='0',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script) or die("Lỗi Query: $sql_reset_script");

//All Quest For Class 3
//if ($row[4] == $class_dw_3 OR $row[4] == $class_dk_3 OR $row[4] == $class_elf_3 OR $row[4] == $class_mg_2 OR $row[4] == $class_dl_2 OR $row[4] == $class_sum_3) {
// $sql_all_quest = $db->Execute($all_quest);
// }

if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup,[LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
}
}

//Reset Point Master Skill
//include_once('MasterLV.php');

$tru_jewel = $db->Execute("UPDATE MEMB_INFO SET jewel_chao=jewel_chao-$chao,jewel_cre=jewel_cre-$cre,jewel_blue=jewel_blue-$blue WHERE memb___id='$login'");

//Event TOP Reset in Time
include_once('event_toprs_intime.php');


//Ghi vào Log nhung nhan vàt Reset
/*
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
$log_price = "";
$log_Des = "";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
*/
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
$log_price = " - ";
$log_Des = "<b>$name</b> Reset lần thứ <b>$resetup</b> khi ". $row[0] ." Level/". $resetold ." Reset, Relife $relife";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
//End Ghi vào Log nhung nhan vàt Reset tren 0 lan

top50();

$reponse = "<info>OK</info>
<resetmoeny>$resetmoeny</resetmoeny>
<resetpoint>$pointup</resetpoint>
<pointdutru>$resetpoint</pointdutru>
<messenge>$name Reset lần thứ $resetup thành công!";
if($resetpoint > 0) {
$reponse .= " Point sau khi Reset trên 65.000 Point. Bạn vào Game cộng điểm sau đó vào phần <b>Rút Point</b> để lấy Point còn lại";
}
$reponse .= "</messenge>";

echo $reponse;
}
?>

reset vip:

<?php
include_once("security.php");
include_once ('config.php');
include_once('config/config_reset.php');
include_once('config/config_resetvip.php');
include_once('config/config_hotrotanthu.php');
include_once('config/config_gioihanrs.php');
include_once('config/config_relife.php');
include_once('config/config_event.php');
include_once ('function.php');

$login = $_POST['login'];
$name = $_POST['name'];
$tiente = $_POST['tiente'];

$resetnow = $_POST['resetnow']; $resetnow = abs(intval($resetnow));

$passtransfer = $_POST['passtransfer'];

if ($passtransfer == $transfercode) {

$string_login = $_POST['string_login'];
checklogin($login,$string_login);

fixrs($name);
check_resetday();
check_resetmonth();

$inventory_query = "SELECT Inventory FROM Character WHERE AccountID = '$login' AND Name='$name'";

kiemtra_doinv($login,$name);
kiemtra_online($login);

$inventory_result_sql = $db->Execute($inventory_query);
check_queryerror($inventory_query,$inventory_resul t_sql);
$inventory_result = $inventory_result_sql->fetchrow();

$spl_PkLevel_query = "SELECT PkLevel FROM Character WHERE PkLevel > 3 and Name='$name'";
$sql_PkLevel_check = $db->Execute($spl_PkLevel_query);
check_queryerror($spl_PkLevel_query,$sql_PkLevel_c heck);
$PkLevel_check = $sql_PkLevel_check->numrows();

$sql_char_back_reged_query = "SELECT Name FROM Character_back WHERE Name='$name' and AccountID = '$login'";
$sql_char_back_reged_check = $db->Execute($sql_char_back_reged_query);
check_queryerror($sql_char_back_reged_query,$sql_c har_back_reged_check);
$char_back_reged_check = $sql_char_back_reged_check->numrows();

$query = "Select Clevel,Resets,Money,LevelUpPoint,Class,Relifes,NoR esetInDay,Resets_Time, Top50 From Character where Name='$name'";
$result = $db->Execute($query);
check_queryerror($query,$result);
$row = $result->fetchrow();

if($resetnow >0 && abs(intval($row[1])) == 0) {
echo "Hệ thống Reset bị gián đoạn. Vui lòng Reset lại";
exit();
}

$vpoint_query = "Select vpoint From MEMB_INFO where memb___id='$login'";
$vpoint_result = $db->Execute($vpoint_query);
check_queryerror($vpoint_query,$vpoint_result);
$vpoint = $vpoint_result->fetchrow();
$vpointnew = $vpoint[0];

$gcoin_query = "Select gcoin,gcoin_km From MEMB_INFO where memb___id='$login'";
$gcoin_result = $db->Execute($gcoin_query);
check_queryerror($gcoin_query, $gcoin_result);
$gcoin = $gcoin_result->fetchrow();

$thehe_query = "Select thehe From MEMB_INFO where memb___id='$login'";
$thehe_result = $db->Execute($thehe_query);
check_queryerror($thehe_query, $thehe_result);
$thehe_fetch = $thehe_result->fetchrow();
$thehe = $thehe_fetch[0];

$inventory = $inventory_result[0];
$inventory = bin2hex($inventory);
$inventory3 = substr($inventory,76*32,32*32);
$inventory3 = strtoupper($inventory3);

$no_item = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
for ($i=0;$i<32;$i++) $shop_empty .= $no_item;

if ($inventory3 != $shop_empty) { echo "Cửa hàng cá nhân có vật phẩm. Vui lòng bỏ ra khỏi cửa hàng cá nhân để tránh bị mất đồ."; exit(); }

if ($PkLevel_check > 0){
echo "Bạn đang là Sát thủ. Phải rửa tội trước khi Reset."; exit();
}

$CountNoResetInDay=$row[6]+1;

$gcoin_extra = 0;
//Begin Giới hạn Reset trong ngày

//End Giới hạn Reset trong ngày

if ( ($row[1] >= $reset_cap_0) AND ($row[1] < $reset_cap_1) )
{
$level = $level_cap_1_vip;
$gcoin_reset_vip = $gcoin_cap_1_vip;
$time_reset_next = $time_reset_next_1;
}
elseif ( ($row[1] >= $reset_cap_1) AND ($row[1] < $reset_cap_2) )
{
$level = $level_cap_2_vip;
$gcoin_reset_vip = $gcoin_cap_2_vip;
$time_reset_next = $time_reset_next_2;
}
elseif ( ($row[1] >= $reset_cap_2) AND ($row[1] < $reset_cap_3) )
{
$level = $level_cap_3_vip;
$gcoin_reset_vip = $gcoin_cap_3_vip;
$time_reset_next = $time_reset_next_3;
}
elseif ( ($row[1] >= $reset_cap_3) AND ($row[1] < $reset_cap_4) )
{
$level = $level_cap_4_vip;
$gcoin_reset_vip = $gcoin_cap_4_vip;
$time_reset_next = $time_reset_next_4;
}
elseif ( ($row[1] >= $reset_cap_4) AND ($row[1] < $reset_cap_5) )
{
$level = $level_cap_5_vip;
$gcoin_reset_vip = $gcoin_cap_5_vip;
$time_reset_next = $time_reset_next_5;
}
elseif ( ($row[1] >= $reset_cap_5) AND ($row[1] < $reset_cap_6) )
{
$level = $level_cap_6_vip;
$gcoin_reset_vip = $gcoin_cap_6_vip;
$time_reset_next = $time_reset_next_6;
}
elseif ( ($row[1] >= $reset_cap_6) AND ($row[1] < $reset_cap_7) )
{
$level = $level_cap_7_vip;
$gcoin_reset_vip = $gcoin_cap_7_vip;
$time_reset_next = $time_reset_next_7;
}
elseif ( ($row[1] >= $reset_cap_7) AND ($row[1] < $reset_cap_8) )
{
$level = $level_cap_8_vip;
$gcoin_reset_vip = $gcoin_cap_8_vip;
$time_reset_next = $time_reset_next_8;
}
elseif ( ($row[1] >= $reset_cap_8) AND ($row[1] < $reset_cap_9) )
{
$level = $level_cap_9_vip;
$gcoin_reset_vip = $gcoin_cap_9_vip;
$time_reset_next = $time_reset_next_9;
}
elseif ( ($row[1] >= $reset_cap_9) AND ($row[1] < $reset_cap_10) )
{
$level = $level_cap_10_vip;
$gcoin_reset_vip = $gcoin_cap_10_vip;
$time_reset_next = $time_reset_next_10;
}
elseif ( ($row[1] >= $reset_cap_10) AND ($row[1] < $reset_cap_11) )
{
$level = $level_cap_11_vip;
$gcoin_reset_vip = $gcoin_cap_11_vip;
$time_reset_next = $time_reset_next_11;
}
elseif ( ($row[1] >= $reset_cap_11) AND ($row[1] < $reset_cap_12) )
{
$level = $level_cap_12_vip;
$gcoin_reset_vip = $gcoin_cap_12_vip;
$time_reset_next = $time_reset_next_12;
}
elseif ( ($row[1] >= $reset_cap_12) AND ($row[1] < $reset_cap_13) )
{
$level = $level_cap_13_vip;
$gcoin_reset_vip = $gcoin_cap_13_vip;
$time_reset_next = $time_reset_next_13;
}
elseif ( ($row[1] >= $reset_cap_13) AND ($row[1] < $reset_cap_14) )
{
$level = $level_cap_14_vip;
$gcoin_reset_vip = $gcoin_cap_14_vip;
$time_reset_next = $time_reset_next_14;
}
elseif ( ($row[1] >= $reset_cap_14) AND ($row[1] < $reset_cap_15) )
{
$level = $level_cap_15_vip;
$gcoin_reset_vip = $gcoin_cap_15_vip;
$time_reset_next = $time_reset_next_15;
}
elseif ( ($row[1] >= $reset_cap_15) AND ($row[1] < $reset_cap_16) )
{
$level = $level_cap_16_vip;
$gcoin_reset_vip = $gcoin_cap_16_vip;
$time_reset_next = $time_reset_next_16;
}
elseif ( ($row[1] >= $reset_cap_16) AND ($row[1] < $reset_cap_17) )
{
$level = $level_cap_17_vip;
$gcoin_reset_vip = $gcoin_cap_17_vip;
$time_reset_next = $time_reset_next_17;
}
elseif ( ($row[1] >= $reset_cap_17) AND ($row[1] < $reset_cap_18) )
{
$level = $level_cap_18_vip;
$gcoin_reset_vip = $gcoin_cap_18_vip;
$time_reset_next = $time_reset_next_18;
}
elseif ( ($row[1] >= $reset_cap_18) AND ($row[1] < $reset_cap_19) )
{
$level = $level_cap_19_vip;
$gcoin_reset_vip = $gcoin_cap_19_vip;
$time_reset_next = $time_reset_next_19;
}
elseif ( ($row[1] >= $reset_cap_19) AND ($row[1] < $reset_cap_20) )
{
$level = $level_cap_20_vip;
$gcoin_reset_vip = $gcoin_cap_20_vip;
$time_reset_next = $time_reset_next_20;
}

$gcoinnew = $gcoin[0];
$gcoin_km = $gcoin[1];
$gcoin_total = $gcoinnew + $gcoin_km;
if ($tiente == 'gcoin') {
$gcoin_rs = $gcoin_reset_vip+$gcoin_extra;
if ( $gcoin_total < $gcoin_rs )
{
echo "Không có đủ gcoin yêu cầu Reset. Bạn đang Reset $row[1] lần. Bạn cần có $gcoin_rs gcoin chi phí Reset VIP"; exit();
}
else {
if ( $gcoin_rs <= $gcoin_km )
{
$gcoin_km -= $gcoin_rs;
}
else
{
$gcoinnew -= $gcoin_rs - $gcoin_km;
$gcoin_km = 0;
}

}
} elseif ($tiente == 'vpoint') {
$vpoint_reset_vip = $gcoin_reset_vip * ( 1 + $vpoint_extra / 100 );
if ( $vpointnew < $vpoint_reset_vip )
{
echo "Không có đủ Vpoint yêu cầu Reset. Bạn đang Reset ";
echo $row['1'];
echo " lần. Bạn cần có ";
echo $vpoint_reset_vip;
echo " Vpoint chi phí Reset VIP";
exit( );
}
$vpointnew -= $vpoint_reset_vip;
} else { echo "Sai loại tiền tệ"; exit(); }

//Begin hỗ trợ tân thủ
if ($hotrotanthu == 1) {
$Resetnow = $row[1];
$Relifenow = $row[5];
if ( 1 <= $capsudung && $cap1_reset_min <= $row[1] && $row[1] <= $cap1_reset_max && $cap1_relife_min <= $row[5] && $row[5] <= $cap1_relife_max )
{
$level -= $cap1_levelgiam;
}
else if ( 2 <= $capsudung && $cap2_reset_min <= $row[1] && $row[1] <= $cap2_reset_max && $cap2_relife_min <= $row[5] && $row[5] <= $cap2_relife_max )
{
$level -= $cap2_levelgiam;
}
else if ( 3 <= $capsudung && $cap3_reset_min <= $row[1] && $row[1] <= $cap3_reset_max && $cap3_relife_min <= $row[5] && $row[5] <= $cap3_relife_max )
{
$level -= $cap3_levelgiam;
}
else if ( 4 <= $capsudung && $cap4_reset_min <= $row[1] && $row[1] <= $cap4_reset_max && $cap4_relife_min <= $row[5] && $row[5] <= $cap4_relife_max )
{
$level -= $cap4_levelgiam;
}
else if ( 5 <= $capsudung && $cap5_reset_min <= $row[1] && $row[1] <= $cap5_reset_max && $cap5_relife_min <= $row[5] && $row[5] <= $cap5_relife_max )
{
$level -= $cap5_levelgiam;
}
}
//End hỗ trợ tân thủ

$relife = $row[5];
$resetold = $row[1]; $resetold = abs(intval($resetold));
$resetup = $resetold + 1;
list( , $resetold, , , , $relife ) = $row;
$resetold = abs( intval( $resetold ) );
$resetup = $resetold + 1;
if ($row[0] < $level) {echo "$name cần $level level để Reset lần $resetup."; exit();}


$time_reset_next = $row[7]+$time_reset_next*60;
if ($time_reset_next > $timestamp) {
$time_free = $time_reset_next - $timestamp;
echo "$name cần $time_free giây nữa để Reset lần tiếp theo."; exit();
}

switch ($row[5]) {
case 0:
$reset_relifes = $rl_reset_relife1;
$point_relifes = 0;
$ml_relifes = 0;
break;
case 1:
$reset_relifes = $rl_reset_relife2;
$point_relifes = $rl_point_relife1;
$ml_relifes = $rl_ml_relife1;
break;
case 2:
$reset_relifes = $rl_reset_relife3;
$point_relifes = $rl_point_relife2;
$ml_relifes = $rl_ml_relife2;
break;
case 3:
$reset_relifes = $rl_reset_relife4;
$point_relifes = $rl_point_relife3;
$ml_relifes = $rl_ml_relife3;
break;
case 4:
$reset_relifes = $rl_reset_relife5;
$point_relifes = $rl_point_relife4;
$ml_relifes = $rl_ml_relife4;
break;
case 5:
$reset_relifes = $rl_reset_relife6;
$point_relifes = $rl_point_relife5;
$ml_relifes = $rl_ml_relife5;
break;
case 6:
$reset_relifes = $rl_reset_relife7;
$point_relifes = $rl_point_relife6;
$ml_relifes = $rl_ml_relife6;
break;
case 7;
$reset_relifes = $rl_reset_relife8;
$point_relifes = $rl_point_relife7;
$ml_relifes = $rl_ml_relife7;
break;
case 8:
$reset_relifes = $rl_reset_relife9;
$point_relifes = $rl_point_relife8;
$ml_relifes = $rl_ml_relife8;
break;
case 9:
$reset_relifes = $rl_reset_relife10;
$point_relifes = $rl_point_relife9;
$ml_relifes = $rl_ml_relife9;
break;
case 10:
$reset_relifes = $rl_reset_relife11;
$point_relifes = $rl_point_relife10;
$ml_relifes = $rl_ml_relife10;
break;
}

if ( $row[1] >= $reset_relifes ) {
echo "$name đang ReLife: $row[5] - Reset: $row[1]. Để Reset tiếp bạn cần phải ReLife."; exit();
}

//Reset lần 1
if ($row[1] == $reset_cap_0)
{
$resetpoint=$point_relifes+$point_cap_1_vip;
$leadership = $ml_relifes+$ml_cap_1_vip;
}
//Reset cấp 1
elseif ($row[1] < $reset_cap_1)
{
$resetpoint=$point_relifes+$point_cap_1_vip+$row[1]*$point_cap_1_vip;
$leadership = $ml_relifes+$ml_relifes+$ml_cap_1_vip+$row[1]*$ml_cap_1_vip;
}
//Reset cấp 1 -> 2
elseif ($row[1] >= $reset_cap_1 AND $row[1] < $reset_cap_2)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($row[1]-($reset_cap_1-1))*$point_cap_2_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($row[1]-($reset_cap_1-1))*$ml_cap_2_vip;
}
//Reset cấp 2 -> 3
elseif ($row[1] >= $reset_cap_2 AND $row[1] < $reset_cap_3)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$point_cap_3_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$ml_cap_3_vip;
}
//Reset cấp 3 -> 4
elseif ($row[1] >= $reset_cap_3 AND $row[1] < $reset_cap_4)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$point_cap_4_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$ml_cap_4_vip;
}
//Reset cấp 4 -> 5
elseif ($row[1] >= $reset_cap_4 AND $row[1] < $reset_cap_5)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$point_cap_5_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$ml_cap_5_vip;
}
//Reset cấp 5 -> 6
elseif ($row[1] >= $reset_cap_5 AND $row[1] < $reset_cap_6)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$point_cap_6_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$ml_cap_6_vip;
}
//Reset cấp 6 -> 7
elseif ($row[1] >= $reset_cap_6 AND $row[1] < $reset_cap_7)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$point_cap_7_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$ml_cap_7_vip;
}
//Reset cấp 7 -> 8
elseif ($row[1] >= $reset_cap_7 AND $row[1] < $reset_cap_8)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$point_cap_8_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$ml_cap_8_vip;
}
//Reset cấp 8 -> 9
elseif ($row[1] >= $reset_cap_8 AND $row[1] < $reset_cap_9)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$point_cap_9_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$ml_cap_9_vip;
}
//Reset cấp 9 -> 10
elseif ($row[1] >= $reset_cap_9 AND $row[1] < $reset_cap_10)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$point_cap_10_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$ml_cap_10_vip;
}
//Reset cấp 10 -> 11
elseif ($row[1] >= $reset_cap_10 AND $row[1] < $reset_cap_11)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$point_cap_11_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$ml_cap_11_vip;
}
//Reset cấp 11 -> 12
elseif ($row[1] >= $reset_cap_11 AND $row[1] < $reset_cap_12)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$point_cap_12_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$ml_cap_12_vip;
}
//Reset cấp 12 -> 13
elseif ($row[1] >= $reset_cap_12 AND $row[1] < $reset_cap_13)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$point_cap_13_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$ml_cap_13_vip;
}
//Reset cấp 13 -> 14
elseif ($row[1] >= $reset_cap_13 AND $row[1] < $reset_cap_14)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$point_cap_14_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$ml_cap_14_vip;
}
//Reset cấp 14 -> 15
elseif ($row[1] >= $reset_cap_14 AND $row[1] < $reset_cap_15)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$point_cap_15_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$ml_cap_15_vip;
}
//Reset cấp 15 -> 16
elseif ($row[1] >= $reset_cap_15 AND $row[1] < $reset_cap_16)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$point_cap_16_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$ml_cap_16_vip;
}
//Reset cấp 16 -> 17
elseif ($row[1] >= $reset_cap_16 AND $row[1] < $reset_cap_17)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$point_cap_17_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$ml_cap_17_vip;
}
//Reset cấp 17 -> 18
elseif ($row[1] >= $reset_cap_17 AND $row[1] < $reset_cap_18)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($point_cap_17_vip*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$point_cap_18_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($ml_cap_17_vip*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$ml_cap_18_vip;
}
//Reset cấp 18 -> 19
elseif ($row[1] >= $reset_cap_18 AND $row[1] < $reset_cap_19)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($point_cap_17_vip*($reset_cap_17-$reset_cap_16))+($point_cap_18_vip*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$point_cap_19_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($ml_cap_17_vip*($reset_cap_17-$reset_cap_16))+($ml_cap_18_vip*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$ml_cap_19_vip;
}
//Reset cấp 19 -> 20
elseif ($row[1] >= $reset_cap_19 AND $row[1] < $reset_cap_20)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($point_cap_17_vip*($reset_cap_17-$reset_cap_16))+($point_cap_18_vip*($reset_cap_18-$reset_cap_17))+($point_cap_19_vip*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$point_cap_20_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($ml_cap_17_vip*($reset_cap_17-$reset_cap_16))+($ml_cap_18_vip*($reset_cap_18-$reset_cap_17))+($ml_cap_19_vip*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$ml_cap_20_vip;
}
//Fix Menh lenh DarkLord > 32k
if ( $leadership>32000 ) $leadership=32000;


$ClassType = $row[4];
switch ($ClassType){
case 0:
case 1:
case 2:
case 3:
$Class_Default = 0;
break;

case 16:
case 17:
case 18:
case 19:
$Class_Default = 16;
break;

case 32:
case 33:
case 34:
case 35:
$Class_Default = 32;
break;

case 48:
case 49:
case 50:
$Class_Default = 48;
break;

case 64:
case 65:
case 66:
$Class_Default = 64;
break;

case 80:
case 81:
case 82:
case 83:
$Class_Default = 80;
break;

case 96:
case 97:
case 98:
$Class_Default = 96;
break;

default :
$Class_Default = 0;
}
$default_query = "SELECT Strength, Dexterity, Vitality, Energy, Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY FROM DefaultClassType WHERE Class=" . $Class_Default;
$default_result = $db->execute($default_query);
$Date = date("h:i:sA, d/m/Y");
$fp = fopen("log_rs.txt", "a+");
fputs ($fp, "Lúc: $Date. $default_query \n");
fclose($fp);
check_queryerror($default_query, $default_result);
$point_default = $default_result->fetchrow();
$Strength_Default = $point_default[0];
$Dexterity_Default = $point_default[1];
$Vitality_Default = $point_default[2];
$Energy_Default = $point_default[3];
$Life_Default = $point_default[4];
$MaxLife_Default = $point_default[5];
$Mana_Default = $point_default[6];
$MaxMana_Default = $point_default[7];
$MapNumber_Default = $point_default[8];
$MapPosX_Default = $point_default[9];
$MapPosY_Default = $point_default[10];


$Strength = $Strength_Default;
$Dexterity = $Dexterity_Default;
$Vitality = $Vitality_Default;
$Energy = $Energy_Default;
$Life = $Life_Default;
$MaxLife = $MaxLife_Default;
$Mana = $Mana_Default;
$MaxMana = $MaxMana_Default;
$MapNumber = $MapNumber_Default;
$MapPosX = $MapPosX_Default;
$MapPosY = $MapPosY_Default;
$Mapdir=0;

$Point_Default_total = $Strength + $Dexterity + $Vitality + $Energy;
//End Cong thuc Reset

//Tat ca cac Quest
$all_quest="Update character set Quest=0xaaeaffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffff where name='$name'";
if( intval($level_after_reset) >1 ) $clevel = $level_after_reset;
else $clevel = 1;

$point_event_query = "SELECT point_event FROM Character WHERE Name='$name'";
$point_event_qr = $db->Execute($point_event_query);
check_queryerror($point_event_query, $point_event_qr);
$point_event = $point_event_qr->fetchrow();
$resetpoint = $resetpoint + $point_event[0];


if( $resetpoint > 65000) {
$pointup = 65000;
$resetpoint = $resetpoint - 65000;
} else {
$pointup = $resetpoint;
$resetpoint = 0;
}

switch ($month)
{
case '01' : $fieldtopmonth = 'TopMonth01'; break;
case '02' : $fieldtopmonth = 'TopMonth02'; break;
case '03' : $fieldtopmonth = 'TopMonth03'; break;
case '04' : $fieldtopmonth = 'TopMonth04'; break;
case '05' : $fieldtopmonth = 'TopMonth05'; break;
case '06' : $fieldtopmonth = 'TopMonth06'; break;
case '07' : $fieldtopmonth = 'TopMonth07'; break;
case '08' : $fieldtopmonth = 'TopMonth08'; break;
case '09' : $fieldtopmonth = 'TopMonth09'; break;
case '10' : $fieldtopmonth = 'TopMonth10'; break;
case '11' : $fieldtopmonth = 'TopMonth11'; break;
case '12' : $fieldtopmonth = 'TopMonth12'; break;
default : $fieldtopmonth = 'TopMonth01';
}

kiemtra_doinv($login,$name);
kiemtra_online($login);

// Reset nhan vat la Darklord
if ($row[4] == 64 OR $row[4] == 65 OR $row[4] == 66)
{
$sql_reset_script="Update dbo.character set [clevel]='$clevel',[experience]='0',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='0',[Leadership]='$leadership',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='1',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script);
check_queryerror($sql_reset_script, $sql_reset_exec);

//Nhan vat dang ki tai sinh
if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup,[LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Leadership]='$leadership',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
check_queryerror($msquery,$msresults);
}
}

//Reset nhan vat khong phai la DarkLord
else
{
$sql_reset_script="Update Character set [clevel]='$clevel',[experience]='0',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='$Mapdir',[Leadership]='0',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='1',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script);
check_queryerror($sql_reset_script, $sql_reset_exec);

//All Quest For Class 3
//if ($row[4] == $class_dw_3 OR $row[4] == $class_dk_3 OR $row[4] == $class_elf_3 OR $row[4] == $class_mg_2 OR $row[4] == $class_dl_2 OR $row[4] == $class_sum_3) {
// $sql_all_quest = $db->Execute($all_quest);
// check_queryerror($all_quest,$sql_all_quest);
// }

if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup,[LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
check_queryerror($msquery, $msquery);
}
}

//Reset Point Master Skill
//include_once('MasterLV.php');

$tru_vpoint_query = "UPDATE MEMB_INFO SET [vpoint]=$vpointnew WHERE memb___id='$login'";
$tru_vpoint = $db->Execute($tru_vpoint_query);
check_queryerror($tru_vpoint_query, $tru_vpoint);

$tru_gcoin_query = "UPDATE MEMB_INFO SET [gcoin]=$gcoinnew,gcoin_km=$gcoin_km WHERE memb___id='$login'";
$tru_gcoin = $db->Execute($tru_gcoin_query);
check_queryerror($tru_gcoin_query, $tru_gcoin);

//Event TOP Reset in Time
include_once('event_toprs_intime.php');

top50();

//Ghi vào Log nhung nhan vàt Reset VIP
/*
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
$log_price = "";
$log_Des = "";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
*/
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
if ($tiente == 'vpoint')
{
$log_price = "- $vpoint_reset_vip Vpoint";
} else
{
$log_price = " - $gcoin_rs Gcoin";
}

$log_Des = "<b>$name</b> Reset VIP lần thứ <b>$resetup</b> khi ". $row[0] ." Level/". $resetold ." Reset, Relife $relife";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
//End Ghi vào Log nhung nhan vàt Reset tren 0 lan

$reponse = "<info>OK</info>
<gcoin>$gcoinnew</gcoin>
<gcoin_km>$gcoin_km</gcoin_km>
<vpoint>$vpointnew</vpoint>
<resetpoint>$pointup</resetpoint>
<pointdutru>$resetpoint</pointdutru>
<messenge>$name Reset VIP lần thứ $resetup thành công!";
if($resetpoint > 0) {
$reponse .= " Point sau khi Reset trên 65.000 Point. Bạn vào Game cộng điểm sau đó vào phần <b>Rút Point</b> để lấy Point còn lại";
}
$reponse .= "</messenge>";

echo $reponse;
}
?>

huuthao
15-08-12, 03:30 PM
ok cảm ơn bạn mình làm được rùi

bỏ mấy cái dòng yêu cầu time reset next

huuthao
18-08-12, 04:14 AM
mình config là top 1 - 10 reset 10 lần là max

nhưng reset thường thì kog cho reset típ

còn reset vip thì vẫn reset dc đến 20 lần mới kg cho reset tiếp

tớ đã config chuẩn file giới hạn là top 1 - 10 rs 10 lần và kg cho vượt mức giới hạn.

xin giúp tớ sửa lại với

remesouth
27-03-13, 06:26 AM
reset:

<?php
include_once("security.php");
include_once('config.php');
include_once('config/config_reset.php');
include_once('config/config_hotrotanthu.php');
include_once('config/config_gioihanrs.php');
include_once('config/config_relife.php');
include_once('config/config_event.php');
include_once('function.php');

$login = $_POST['login'];
$name = $_POST['name'];

$resetnow = $_POST['resetnow']; $resetnow = abs(intval($resetnow));

$passtransfer = $_POST['passtransfer'];

if ($passtransfer == $transfercode) {

$string_login = $_POST['string_login'];
checklogin($login,$string_login);

fixrs($name);
check_resetday();
check_resetmonth();

$inventory_query = "SELECT Inventory FROM Character WHERE AccountID = '$login' AND Name='$name'";

kiemtra_doinv($login,$name);
kiemtra_online($login);

$inventory_result_sql = $db->Execute($inventory_query);
$inventory_result = $inventory_result_sql->fetchrow();

$sql_PkLevel_check = $db->Execute("SELECT PkLevel FROM Character WHERE PkLevel > 3 and Name='$name'");
$PkLevel_check = $sql_PkLevel_check->numrows();

$sql_char_back_reged_check = $db->Execute("SELECT Name FROM Character_back WHERE Name='$name' and AccountID = '$login'");
$char_back_reged_check = $sql_char_back_reged_check->numrows();

$result = $db->Execute("Select Clevel,Resets,Money,LevelUpPoint,Class,Relifes,NoR esetInDay,Resets_Time, Top50 From Character where Name='$name'");
$row = $result->fetchrow();

if($resetnow >0 && abs(intval($row[1])) == 0) {
echo "Hệ thống Reset bị gián đoạn. Vui lòng Reset lại";
exit();
}

$vpoint_result = $db->Execute("Select vpoint From MEMB_INFO where memb___id='$login'");
$vpoint = $vpoint_result->fetchrow();

$check_jewel = $db->Execute("SELECT jewel_chao,jewel_cre,jewel_blue FROM MEMB_INFO WHERE memb___id='$login'");
$jewel = $check_jewel->fetchrow();

$thehe_result = $db->Execute("Select thehe From MEMB_INFO where memb___id='$login'");
$thehe_fetch = $thehe_result->fetchrow();
$thehe = $thehe_fetch[0];

$inventory = $inventory_result[0];
$inventory = bin2hex($inventory);
$inventory3 = substr($inventory,76*32,32*32);
$inventory3 = strtoupper($inventory3);

$no_item = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
for ($i=0;$i<32;$i++) $shop_empty .= $no_item;

if ($inventory3 != $shop_empty) { echo "Cửa hàng cá nhân có vật phẩm. Vui lòng bỏ ra khỏi cửa hàng cá nhân để tránh bị mất đồ."; exit(); }

$CountNoResetInDay=$row[6]+1;

//Begin Giới hạn Reset trong ngày

//End Giới hạn Reset trong ngày

if ($PkLevel_check > 0){
echo "Bạn đang là Sát thủ. Phải rửa tội trước khi Reset."; exit();
}

if ( ($row[1] >= $reset_cap_0) AND ($row[1] < $reset_cap_1) )
{
$level = $level_cap_1;
$zen = $zen_cap_1;
$time_reset_next = $time_reset_next_1;
$chao = $chao_cap_1;
$cre = $cre_cap_1;
$blue = $blue_cap_1;
}
elseif ( ($row[1] >= $reset_cap_1) AND ($row[1] < $reset_cap_2) )
{
$level = $level_cap_2;
$zen = $zen_cap_2;
$time_reset_next = $time_reset_next_2;
$chao = $chao_cap_2;
$cre = $cre_cap_2;
$blue = $blue_cap_2;
}
elseif ( ($row[1] >= $reset_cap_2) AND ($row[1] < $reset_cap_3) )
{
$level = $level_cap_3;
$zen = $zen_cap_3;
$time_reset_next = $time_reset_next_3;
$chao = $chao_cap_3;
$cre = $cre_cap_3;
$blue = $blue_cap_3;
}
elseif ( ($row[1] >= $reset_cap_3) AND ($row[1] < $reset_cap_4) )
{
$level = $level_cap_4;
$zen = $zen_cap_4;
$time_reset_next = $time_reset_next_4;
$chao = $chao_cap_4;
$cre = $cre_cap_4;
$blue = $blue_cap_4;
}
elseif ( ($row[1] >= $reset_cap_4) AND ($row[1] < $reset_cap_5) )
{
$level = $level_cap_5;
$zen = $zen_cap_5;
$time_reset_next = $time_reset_next_5;
$chao = $chao_cap_5;
$cre = $cre_cap_5;
$blue = $blue_cap_5;
}
elseif ( ($row[1] >= $reset_cap_5) AND ($row[1] < $reset_cap_6) )
{
$level = $level_cap_6;
$zen = $zen_cap_6;
$time_reset_next = $time_reset_next_6;
$chao = $chao_cap_6;
$cre = $cre_cap_6;
$blue = $blue_cap_6;
}
elseif ( ($row[1] >= $reset_cap_6) AND ($row[1] < $reset_cap_7) )
{
$level = $level_cap_7;
$zen = $zen_cap_7;
$time_reset_next = $time_reset_next_7;
$chao = $chao_cap_7;
$cre = $cre_cap_7;
$blue = $blue_cap_7;
}
elseif ( ($row[1] >= $reset_cap_7) AND ($row[1] < $reset_cap_8) )
{
$level = $level_cap_8;
$zen = $zen_cap_8;
$time_reset_next = $time_reset_next_8;
$chao = $chao_cap_8;
$cre = $cre_cap_8;
$blue = $blue_cap_8;
}
elseif ( ($row[1] >= $reset_cap_8) AND ($row[1] < $reset_cap_9) )
{
$level = $level_cap_9;
$zen = $zen_cap_9;
$time_reset_next = $time_reset_next_9;
$chao = $chao_cap_9;
$cre = $cre_cap_9;
$blue = $blue_cap_9;
}
elseif ( ($row[1] >= $reset_cap_9) AND ($row[1] < $reset_cap_10) )
{
$level = $level_cap_10;
$zen = $zen_cap_10;
$time_reset_next = $time_reset_next_10;
$chao = $chao_cap_10;
$cre = $cre_cap_10;
$blue = $blue_cap_10;
}
elseif ( ($row[1] >= $reset_cap_10) AND ($row[1] < $reset_cap_11) )
{
$level = $level_cap_11;
$zen = $zen_cap_11;
$time_reset_next = $time_reset_next_11;
$chao = $chao_cap_11;
$cre = $cre_cap_11;
$blue = $blue_cap_11;
}
elseif ( ($row[1] >= $reset_cap_11) AND ($row[1] < $reset_cap_12) )
{
$level = $level_cap_12;
$zen = $zen_cap_12;
$time_reset_next = $time_reset_next_12;
$chao = $chao_cap_12;
$cre = $cre_cap_12;
$blue = $blue_cap_12;
}
elseif ( ($row[1] >= $reset_cap_12) AND ($row[1] < $reset_cap_13) )
{
$level = $level_cap_13;
$zen = $zen_cap_13;
$time_reset_next = $time_reset_next_13;
$chao = $chao_cap_13;
$cre = $cre_cap_13;
$blue = $blue_cap_13;
}
elseif ( ($row[1] >= $reset_cap_13) AND ($row[1] < $reset_cap_14) )
{
$level = $level_cap_14;
$zen = $zen_cap_14;
$time_reset_next = $time_reset_next_14;
$chao = $chao_cap_14;
$cre = $cre_cap_14;
$blue = $blue_cap_14;
}
elseif ( ($row[1] >= $reset_cap_14) AND ($row[1] < $reset_cap_15) )
{
$level = $level_cap_15;
$zen = $zen_cap_15;
$time_reset_next = $time_reset_next_15;
$chao = $chao_cap_15;
$cre = $cre_cap_15;
$blue = $blue_cap_15;
}
elseif ( ($row[1] >= $reset_cap_15) AND ($row[1] < $reset_cap_16) )
{
$level = $level_cap_16;
$zen = $zen_cap_16;
$time_reset_next = $time_reset_next_16;
$chao = $chao_cap_16;
$cre = $cre_cap_16;
$blue = $blue_cap_16;
}
elseif ( ($row[1] >= $reset_cap_16) AND ($row[1] < $reset_cap_17) )
{
$level = $level_cap_17;
$zen = $zen_cap_17;
$time_reset_next = $time_reset_next_17;
$chao = $chao_cap_17;
$cre = $cre_cap_17;
$blue = $blue_cap_17;
}
elseif ( ($row[1] >= $reset_cap_17) AND ($row[1] < $reset_cap_18) )
{
$level = $level_cap_18;
$zen = $zen_cap_18;
$time_reset_next = $time_reset_next_18;
$chao = $chao_cap_18;
$cre = $cre_cap_18;
$blue = $blue_cap_18;
}
elseif ( ($row[1] >= $reset_cap_18) AND ($row[1] < $reset_cap_19) )
{
$level = $level_cap_19;
$zen = $zen_cap_19;
$time_reset_next = $time_reset_next_19;
$chao = $chao_cap_19;
$cre = $cre_cap_19;
$blue = $blue_cap_19;
}
elseif ( ($row[1] >= $reset_cap_19) AND ($row[1] < $reset_cap_20) )
{
$level = $level_cap_20;
$zen = $zen_cap_20;
$time_reset_next = $time_reset_next_20;
$chao = $chao_cap_20;
$cre = $cre_cap_20;
$blue = $blue_cap_20;
}

//Begin hỗ trợ tân thủ
if ($hotrotanthu == 1) {
$Resetnow = $row[1];
$Relifenow = $row[5];

if ( 1 <= $capsudung && $cap1_reset_min <= $row[1] && $row[1] <= $cap1_reset_max && $cap1_relife_min <= $row[5] && $row[5] <= $cap1_relife_max )
{
$level -= $cap1_levelgiam;
}
else if ( 2 <= $capsudung && $cap2_reset_min <= $row[1] && $row[1] <= $cap2_reset_max && $cap2_relife_min <= $row[5] && $row[5] <= $cap2_relife_max )
{
$level -= $cap2_levelgiam;
}
else if ( 3 <= $capsudung && $cap3_reset_min <= $row[1] && $row[1] <= $cap3_reset_max && $cap3_relife_min <= $row[5] && $row[5] <= $cap3_relife_max )
{
$level -= $cap3_levelgiam;
}
else if ( 4 <= $capsudung && $cap4_reset_min <= $row[1] && $row[1] <= $cap4_reset_max && $cap4_relife_min <= $row[5] && $row[5] <= $cap4_relife_max )
{
$level -= $cap4_levelgiam;
}
else if ( 5 <= $capsudung && $cap5_reset_min <= $row[1] && $row[1] <= $cap5_reset_max && $cap5_relife_min <= $row[5] && $row[5] <= $cap5_relife_max )
{
$level -= $cap5_levelgiam;
}
}
//End hỗ trợ tân thủ


switch ($row[5]) {
case 0:
$reset_relifes = $rl_reset_relife1;
$point_relifes = 0;
$ml_relifes = 0;
break;
case 1:
$reset_relifes = $rl_reset_relife2;
$point_relifes = $rl_point_relife1;
$ml_relifes = $rl_ml_relife1;
break;
case 2:
$reset_relifes = $rl_reset_relife3;
$point_relifes = $rl_point_relife2;
$ml_relifes = $rl_ml_relife2;
break;
case 3:
$reset_relifes = $rl_reset_relife4;
$point_relifes = $rl_point_relife3;
$ml_relifes = $rl_ml_relife3;
break;
case 4:
$reset_relifes = $rl_reset_relife5;
$point_relifes = $rl_point_relife4;
$ml_relifes = $rl_ml_relife4;
break;
case 5:
$reset_relifes = $rl_reset_relife6;
$point_relifes = $rl_point_relife5;
$ml_relifes = $rl_ml_relife5;
break;
case 6:
$reset_relifes = $rl_reset_relife7;
$point_relifes = $rl_point_relife6;
$ml_relifes = $rl_ml_relife6;
break;
case 7;
$reset_relifes = $rl_reset_relife8;
$point_relifes = $rl_point_relife7;
$ml_relifes = $rl_ml_relife7;
break;
case 8:
$reset_relifes = $rl_reset_relife9;
$point_relifes = $rl_point_relife8;
$ml_relifes = $rl_ml_relife8;
break;
case 9:
$reset_relifes = $rl_reset_relife10;
$point_relifes = $rl_point_relife9;
$ml_relifes = $rl_ml_relife9;
break;
case 10:
$reset_relifes = $rl_reset_relife11;
$point_relifes = $rl_point_relife10;
$ml_relifes = $rl_ml_relife10;
break;
}

if ( $row[1] >= $reset_relifes ) {
echo "$name đang ReLife: $row[5] - Reset: $row[1]. Để Reset tiếp bạn cần phải ReLife."; exit();
}

$relife = $row[5];
$resetold = $row[1]; $resetold = abs(intval($resetold));
$resetup = $resetold + 1;


//Cong thuc Reset
if ( ($jewel[0] < $chao) OR ($jewel[1] < $cre) OR ($jewel[2] < $blue) )
{
echo "Bạn không đủ Jewel trong ngân hàng.<br>Số lần Reset hiện tại của bạn là $row[1]. Bạn cần $chao Chao , $cre Creation , $blue Blue Feather."; exit();
}
if ($row[0] < $level) {echo "$name cần $level level để Reset lần $resetup."; exit();}
if ($row[2] < $zen) {echo "$name cần $zen Zen để Reset lần $resetup."; exit();}

$time_reset_next = $row[7]+$time_reset_next*60;
if ($time_reset_next > $timestamp) {
$time_free = $time_reset_next - $timestamp;
echo "$name cần $time_free giây nữa để Reset lần tiếp theo."; exit();
}

//Reset lần 1
if ($row[1] == $reset_cap_0)
{
$resetpoint=$point_relifes+$point_cap_1;
$resetmoeny = $row[2] - $zen_cap_1;
$leadership = $ml_relifes+$ml_cap_1;
}
//Reset cấp 1
elseif ($row[1] < $reset_cap_1)
{
$resetpoint=$point_relifes+$point_cap_1+$row[1]*$point_cap_1;
$resetmoeny = $row[2] - $zen_cap_1;
$leadership = $ml_relifes+$ml_relifes+$ml_cap_1+$row[1]*$ml_cap_1;
}
//Reset cấp 1 -> 2
elseif ($row[1] >= $reset_cap_1 AND $row[1] < $reset_cap_2)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($row[1]-($reset_cap_1-1))*$point_cap_2;
$resetmoeny = $row[2] - $zen_cap_2;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $row[1]-($reset_cap_1-1))*$ml_cap_2;
}
//Reset cấp 2 -> 3
elseif ($row[1] >= $reset_cap_2 AND $row[1] < $reset_cap_3)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$point_cap_3;
$resetmoeny = $row[2] - $zen_cap_3;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$ml_cap_3;
}
//Reset cấp 3 -> 4
elseif ($row[1] >= $reset_cap_3 AND $row[1] < $reset_cap_4)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$point_cap_4;
$resetmoeny = $row[2] - $zen_cap_4;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$ml_cap_4;
}
//Reset cấp 4 -> 5
elseif ($row[1] >= $reset_cap_4 AND $row[1] < $reset_cap_5)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$point_cap_5;
$resetmoeny = $row[2] - $zen_cap_5;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$ml_cap_5;
}
//Reset cấp 5 -> 6
elseif ($row[1] >= $reset_cap_5 AND $row[1] < $reset_cap_6)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$point_cap_6;
$resetmoeny = $row[2] - $zen_cap_6;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$ml_cap_6;
}
//Reset cấp 6 -> 7
elseif ($row[1] >= $reset_cap_6 AND $row[1] < $reset_cap_7)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$point_cap_7;
$resetmoeny = $row[2] - $zen_cap_7;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$ml_cap_7;
}
//Reset cấp 7 -> 8
elseif ($row[1] >= $reset_cap_7 AND $row[1] < $reset_cap_8)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$point_cap_8;
$resetmoeny = $row[2] - $zen_cap_8;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$ml_cap_8;
}
//Reset cấp 8 -> 9
elseif ($row[1] >= $reset_cap_8 AND $row[1] < $reset_cap_9)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$point_cap_9;
$resetmoeny = $row[2] - $zen_cap_9;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$ml_cap_9;
}
//Reset cấp 9 -> 10
elseif ($row[1] >= $reset_cap_9 AND $row[1] < $reset_cap_10)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$point_cap_10;
$resetmoeny = $row[2] - $zen_cap_10;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$ml_cap_10;
}
//Reset cấp 10 -> 11
elseif ($row[1] >= $reset_cap_10 AND $row[1] < $reset_cap_11)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$point_cap_11;
$resetmoeny = $row[2] - $zen_cap_11;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$ml_cap_11;
}
//Reset cấp 11 -> 12
elseif ($row[1] >= $reset_cap_11 AND $row[1] < $reset_cap_12)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$point_cap_12;
$resetmoeny = $row[2] - $zen_cap_12;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$ml_cap_12;
}
//Reset cấp 12 -> 13
elseif ($row[1] >= $reset_cap_12 AND $row[1] < $reset_cap_13)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$point_cap_13;
$resetmoeny = $row[2] - $zen_cap_13;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$ml_cap_13;
}
//Reset cấp 13 -> 14
elseif ($row[1] >= $reset_cap_13 AND $row[1] < $reset_cap_14)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$point_cap_14;
$resetmoeny = $row[2] - $zen_cap_14;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$ml_cap_14;
}
//Reset cấp 14 -> 15
elseif ($row[1] >= $reset_cap_14 AND $row[1] < $reset_cap_15)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$point_cap_15;
$resetmoeny = $row[2] - $zen_cap_15;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$ml_cap_15;
}
//Reset cấp 15 -> 16
elseif ($row[1] >= $reset_cap_15 AND $row[1] < $reset_cap_16)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$point_cap_16;
$resetmoeny = $row[2] - $zen_cap_16;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$ml_cap_16;
}
//Reset cấp 16 -> 17
elseif ($row[1] >= $reset_cap_16 AND $row[1] < $reset_cap_17)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$point_cap_17;
$resetmoeny = $row[2] - $zen_cap_17;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$ml_cap_17;
}
//Reset cấp 17 -> 18
elseif ($row[1] >= $reset_cap_17 AND $row[1] < $reset_cap_18)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($point_cap_17*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$point_cap_18;
$resetmoeny = $row[2] - $zen_cap_18;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($ml_cap_17*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$ml_cap_18;
}
//Reset cấp 18 -> 19
elseif ($row[1] >= $reset_cap_18 AND $row[1] < $reset_cap_19)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($point_cap_17*($reset_cap_17-$reset_cap_16))+($point_cap_18*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$point_cap_19;
$resetmoeny = $row[2] - $zen_cap_19;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($ml_cap_17*($reset_cap_17-$reset_cap_16))+($ml_cap_18*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$ml_cap_19;
}
//Reset cấp 19 -> 20
elseif ($row[1] >= $reset_cap_19 AND $row[1] < $reset_cap_20)
{
$resetpoint=$point_relifes+($point_cap_1*$reset_ca p_1)+($point_cap_2*($reset_cap_2-$reset_cap_1))+($point_cap_3*($reset_cap_3-$reset_cap_2))+($point_cap_4*($reset_cap_4-$reset_cap_3))+($point_cap_5*($reset_cap_5-$reset_cap_4))+($point_cap_6*($reset_cap_6-$reset_cap_5))+($point_cap_7*($reset_cap_7-$reset_cap_6))+($point_cap_8*($reset_cap_8-$reset_cap_7))+($point_cap_9*($reset_cap_9-$reset_cap_8))+($point_cap_10*($reset_cap_10-$reset_cap_9))+($point_cap_11*($reset_cap_11-$reset_cap_10))+($point_cap_12*($reset_cap_12-$reset_cap_11))+($point_cap_13*($reset_cap_13-$reset_cap_12))+($point_cap_14*($reset_cap_14-$reset_cap_13))+($point_cap_15*($reset_cap_15-$reset_cap_14))+($point_cap_16*($reset_cap_16-$reset_cap_15))+($point_cap_17*($reset_cap_17-$reset_cap_16))+($point_cap_18*($reset_cap_18-$reset_cap_17))+($point_cap_19*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$point_cap_20;
$resetmoeny = $row[2] - $zen_cap_20;
$leadership=$ml_relifes+($ml_cap_1*$reset_cap_1)+( $ml_cap_2*($reset_cap_2-$reset_cap_1))+($ml_cap_3*($reset_cap_3-$reset_cap_2))+($ml_cap_4*($reset_cap_4-$reset_cap_3))+($ml_cap_5*($reset_cap_5-$reset_cap_4))+($ml_cap_6*($reset_cap_6-$reset_cap_5))+($ml_cap_7*($reset_cap_7-$reset_cap_6))+($ml_cap_8*($reset_cap_8-$reset_cap_7))+($ml_cap_9*($reset_cap_9-$reset_cap_8))+($ml_cap_10*($reset_cap_10-$reset_cap_9))+($ml_cap_11*($reset_cap_11-$reset_cap_10))+($ml_cap_12*($reset_cap_12-$reset_cap_11))+($ml_cap_13*($reset_cap_13-$reset_cap_12))+($ml_cap_14*($reset_cap_14-$reset_cap_13))+($ml_cap_15*($reset_cap_15-$reset_cap_14))+($ml_cap_16*($reset_cap_16-$reset_cap_15))+($ml_cap_17*($reset_cap_17-$reset_cap_16))+($ml_cap_18*($reset_cap_18-$reset_cap_17))+($ml_cap_19*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$ml_cap_20;
}
//Fix Menh lenh DarkLord > 32k
if ( $leadership>32000 ) $leadership=32000;


$ClassType = $row[4];
switch ($ClassType){
case 0:
case 1:
case 2:
case 3:
$Class_Default = 0;
break;

case 16:
case 17:
case 18:
case 19:
$Class_Default = 16;
break;

case 32:
case 33:
case 34:
case 35:
$Class_Default = 32;
break;

case 48:
case 49:
case 50:
$Class_Default = 48;
break;

case 64:
case 65:
case 66:
$Class_Default = 64;
break;

case 80:
case 81:
case 82:
case 83:
$Class_Default = 80;
break;

case 96:
case 97:
case 98:
$Class_Default = 96;
break;

default :
$Class_Default = 0;
}
$default_query = "SELECT Strength, Dexterity, Vitality, Energy, Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY FROM DefaultClassType WHERE Class=" . $Class_Default;
$default_result = $db->execute($default_query);
check_queryerror($default_query, $default_result);
$point_default = $default_result->fetchrow();
$Strength_Default = $point_default[0];
$Dexterity_Default = $point_default[1];
$Vitality_Default = $point_default[2];
$Energy_Default = $point_default[3];
$Life_Default = $point_default[4];
$MaxLife_Default = $point_default[5];
$Mana_Default = $point_default[6];
$MaxMana_Default = $point_default[7];
$MapNumber_Default = $point_default[8];
$MapPosX_Default = $point_default[9];
$MapPosY_Default = $point_default[10];


$Strength = $Strength_Default;
$Dexterity = $Dexterity_Default;
$Vitality = $Vitality_Default;
$Energy = $Energy_Default;
$Life = $Life_Default;
$MaxLife = $MaxLife_Default;
$Mana = $Mana_Default;
$MaxMana = $MaxMana_Default;
$MapNumber = $MapNumber_Default;
$MapPosX = $MapPosX_Default;
$MapPosY = $MapPosY_Default;
$Mapdir=0;

$Point_Default_total = $Strength + $Dexterity + $Vitality + $Energy;

//End Cong thuc Reset

//Tat ca cac Quest
$all_quest="Update character set Quest=0xaaeaffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffff where name='$name'";
if( intval($level_after_reset) >1 ) $clevel = $level_after_reset;
else $clevel = 1;

$point_event_qr = $db->Execute("SELECT point_event FROM Character WHERE Name='$name'");
$point_event = $point_event_qr->fetchrow();
$resetpoint = $resetpoint + $point_event[0];

if( $resetpoint > 65000) {
$pointup = 65000;
$resetpoint = $resetpoint - 65000;
} else {
$pointup = $resetpoint;
$resetpoint = 0;
}

switch ($month)
{
case '01' : $fieldtopmonth = 'TopMonth01'; break;
case '02' : $fieldtopmonth = 'TopMonth02'; break;
case '03' : $fieldtopmonth = 'TopMonth03'; break;
case '04' : $fieldtopmonth = 'TopMonth04'; break;
case '05' : $fieldtopmonth = 'TopMonth05'; break;
case '06' : $fieldtopmonth = 'TopMonth06'; break;
case '07' : $fieldtopmonth = 'TopMonth07'; break;
case '08' : $fieldtopmonth = 'TopMonth08'; break;
case '09' : $fieldtopmonth = 'TopMonth09'; break;
case '10' : $fieldtopmonth = 'TopMonth10'; break;
case '11' : $fieldtopmonth = 'TopMonth11'; break;
case '12' : $fieldtopmonth = 'TopMonth12'; break;
default : $fieldtopmonth = 'TopMonth01';
}

kiemtra_doinv($login,$name);
kiemtra_online($login);

// Reset nhan vat la Darklord
if ($row[4] == 64 OR $row[4] == 65 OR $row[4] == 66)
{
$sql_reset_script="Update dbo.character set [clevel]='$clevel',[experience]='0',[money]='$resetmoeny',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='0',[Leadership]='$leadership',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='0',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script) or die("Lỗi Query: $sql_reset_script");

//Nhan vat dang ki tai sinh
if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup, [LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Leadership]='$leadership',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
}
}

//Reset nhan vat khong phai la DarkLord
else
{
$sql_reset_script="Update Character set [clevel]='$clevel',[experience]='0',[money]='$resetmoeny',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='$Mapdir',[Leadership]='0',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='0',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script) or die("Lỗi Query: $sql_reset_script");

//All Quest For Class 3
//if ($row[4] == $class_dw_3 OR $row[4] == $class_dk_3 OR $row[4] == $class_elf_3 OR $row[4] == $class_mg_2 OR $row[4] == $class_dl_2 OR $row[4] == $class_sum_3) {
// $sql_all_quest = $db->Execute($all_quest);
// }

if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup,[LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
}
}

//Reset Point Master Skill
//include_once('MasterLV.php');

$tru_jewel = $db->Execute("UPDATE MEMB_INFO SET jewel_chao=jewel_chao-$chao,jewel_cre=jewel_cre-$cre,jewel_blue=jewel_blue-$blue WHERE memb___id='$login'");

//Event TOP Reset in Time
include_once('event_toprs_intime.php');


//Ghi vào Log nhung nhan vàt Reset
/*
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
$log_price = "";
$log_Des = "";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
*/
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
$log_price = " - ";
$log_Des = "<b>$name</b> Reset lần thứ <b>$resetup</b> khi ". $row[0] ." Level/". $resetold ." Reset, Relife $relife";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
//End Ghi vào Log nhung nhan vàt Reset tren 0 lan

top50();

$reponse = "<info>OK</info>
<resetmoeny>$resetmoeny</resetmoeny>
<resetpoint>$pointup</resetpoint>
<pointdutru>$resetpoint</pointdutru>
<messenge>$name Reset lần thứ $resetup thành công!";
if($resetpoint > 0) {
$reponse .= " Point sau khi Reset trên 65.000 Point. Bạn vào Game cộng điểm sau đó vào phần <b>Rút Point</b> để lấy Point còn lại";
}
$reponse .= "</messenge>";

echo $reponse;
}
?>

reset vip:

<?php
include_once("security.php");
include_once ('config.php');
include_once('config/config_reset.php');
include_once('config/config_resetvip.php');
include_once('config/config_hotrotanthu.php');
include_once('config/config_gioihanrs.php');
include_once('config/config_relife.php');
include_once('config/config_event.php');
include_once ('function.php');

$login = $_POST['login'];
$name = $_POST['name'];
$tiente = $_POST['tiente'];

$resetnow = $_POST['resetnow']; $resetnow = abs(intval($resetnow));

$passtransfer = $_POST['passtransfer'];

if ($passtransfer == $transfercode) {

$string_login = $_POST['string_login'];
checklogin($login,$string_login);

fixrs($name);
check_resetday();
check_resetmonth();

$inventory_query = "SELECT Inventory FROM Character WHERE AccountID = '$login' AND Name='$name'";

kiemtra_doinv($login,$name);
kiemtra_online($login);

$inventory_result_sql = $db->Execute($inventory_query);
check_queryerror($inventory_query,$inventory_resul t_sql);
$inventory_result = $inventory_result_sql->fetchrow();

$spl_PkLevel_query = "SELECT PkLevel FROM Character WHERE PkLevel > 3 and Name='$name'";
$sql_PkLevel_check = $db->Execute($spl_PkLevel_query);
check_queryerror($spl_PkLevel_query,$sql_PkLevel_c heck);
$PkLevel_check = $sql_PkLevel_check->numrows();

$sql_char_back_reged_query = "SELECT Name FROM Character_back WHERE Name='$name' and AccountID = '$login'";
$sql_char_back_reged_check = $db->Execute($sql_char_back_reged_query);
check_queryerror($sql_char_back_reged_query,$sql_c har_back_reged_check);
$char_back_reged_check = $sql_char_back_reged_check->numrows();

$query = "Select Clevel,Resets,Money,LevelUpPoint,Class,Relifes,NoR esetInDay,Resets_Time, Top50 From Character where Name='$name'";
$result = $db->Execute($query);
check_queryerror($query,$result);
$row = $result->fetchrow();

if($resetnow >0 && abs(intval($row[1])) == 0) {
echo "Hệ thống Reset bị gián đoạn. Vui lòng Reset lại";
exit();
}

$vpoint_query = "Select vpoint From MEMB_INFO where memb___id='$login'";
$vpoint_result = $db->Execute($vpoint_query);
check_queryerror($vpoint_query,$vpoint_result);
$vpoint = $vpoint_result->fetchrow();
$vpointnew = $vpoint[0];

$gcoin_query = "Select gcoin,gcoin_km From MEMB_INFO where memb___id='$login'";
$gcoin_result = $db->Execute($gcoin_query);
check_queryerror($gcoin_query, $gcoin_result);
$gcoin = $gcoin_result->fetchrow();

$thehe_query = "Select thehe From MEMB_INFO where memb___id='$login'";
$thehe_result = $db->Execute($thehe_query);
check_queryerror($thehe_query, $thehe_result);
$thehe_fetch = $thehe_result->fetchrow();
$thehe = $thehe_fetch[0];

$inventory = $inventory_result[0];
$inventory = bin2hex($inventory);
$inventory3 = substr($inventory,76*32,32*32);
$inventory3 = strtoupper($inventory3);

$no_item = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
for ($i=0;$i<32;$i++) $shop_empty .= $no_item;

if ($inventory3 != $shop_empty) { echo "Cửa hàng cá nhân có vật phẩm. Vui lòng bỏ ra khỏi cửa hàng cá nhân để tránh bị mất đồ."; exit(); }

if ($PkLevel_check > 0){
echo "Bạn đang là Sát thủ. Phải rửa tội trước khi Reset."; exit();
}

$CountNoResetInDay=$row[6]+1;

$gcoin_extra = 0;
//Begin Giới hạn Reset trong ngày

//End Giới hạn Reset trong ngày

if ( ($row[1] >= $reset_cap_0) AND ($row[1] < $reset_cap_1) )
{
$level = $level_cap_1_vip;
$gcoin_reset_vip = $gcoin_cap_1_vip;
$time_reset_next = $time_reset_next_1;
}
elseif ( ($row[1] >= $reset_cap_1) AND ($row[1] < $reset_cap_2) )
{
$level = $level_cap_2_vip;
$gcoin_reset_vip = $gcoin_cap_2_vip;
$time_reset_next = $time_reset_next_2;
}
elseif ( ($row[1] >= $reset_cap_2) AND ($row[1] < $reset_cap_3) )
{
$level = $level_cap_3_vip;
$gcoin_reset_vip = $gcoin_cap_3_vip;
$time_reset_next = $time_reset_next_3;
}
elseif ( ($row[1] >= $reset_cap_3) AND ($row[1] < $reset_cap_4) )
{
$level = $level_cap_4_vip;
$gcoin_reset_vip = $gcoin_cap_4_vip;
$time_reset_next = $time_reset_next_4;
}
elseif ( ($row[1] >= $reset_cap_4) AND ($row[1] < $reset_cap_5) )
{
$level = $level_cap_5_vip;
$gcoin_reset_vip = $gcoin_cap_5_vip;
$time_reset_next = $time_reset_next_5;
}
elseif ( ($row[1] >= $reset_cap_5) AND ($row[1] < $reset_cap_6) )
{
$level = $level_cap_6_vip;
$gcoin_reset_vip = $gcoin_cap_6_vip;
$time_reset_next = $time_reset_next_6;
}
elseif ( ($row[1] >= $reset_cap_6) AND ($row[1] < $reset_cap_7) )
{
$level = $level_cap_7_vip;
$gcoin_reset_vip = $gcoin_cap_7_vip;
$time_reset_next = $time_reset_next_7;
}
elseif ( ($row[1] >= $reset_cap_7) AND ($row[1] < $reset_cap_8) )
{
$level = $level_cap_8_vip;
$gcoin_reset_vip = $gcoin_cap_8_vip;
$time_reset_next = $time_reset_next_8;
}
elseif ( ($row[1] >= $reset_cap_8) AND ($row[1] < $reset_cap_9) )
{
$level = $level_cap_9_vip;
$gcoin_reset_vip = $gcoin_cap_9_vip;
$time_reset_next = $time_reset_next_9;
}
elseif ( ($row[1] >= $reset_cap_9) AND ($row[1] < $reset_cap_10) )
{
$level = $level_cap_10_vip;
$gcoin_reset_vip = $gcoin_cap_10_vip;
$time_reset_next = $time_reset_next_10;
}
elseif ( ($row[1] >= $reset_cap_10) AND ($row[1] < $reset_cap_11) )
{
$level = $level_cap_11_vip;
$gcoin_reset_vip = $gcoin_cap_11_vip;
$time_reset_next = $time_reset_next_11;
}
elseif ( ($row[1] >= $reset_cap_11) AND ($row[1] < $reset_cap_12) )
{
$level = $level_cap_12_vip;
$gcoin_reset_vip = $gcoin_cap_12_vip;
$time_reset_next = $time_reset_next_12;
}
elseif ( ($row[1] >= $reset_cap_12) AND ($row[1] < $reset_cap_13) )
{
$level = $level_cap_13_vip;
$gcoin_reset_vip = $gcoin_cap_13_vip;
$time_reset_next = $time_reset_next_13;
}
elseif ( ($row[1] >= $reset_cap_13) AND ($row[1] < $reset_cap_14) )
{
$level = $level_cap_14_vip;
$gcoin_reset_vip = $gcoin_cap_14_vip;
$time_reset_next = $time_reset_next_14;
}
elseif ( ($row[1] >= $reset_cap_14) AND ($row[1] < $reset_cap_15) )
{
$level = $level_cap_15_vip;
$gcoin_reset_vip = $gcoin_cap_15_vip;
$time_reset_next = $time_reset_next_15;
}
elseif ( ($row[1] >= $reset_cap_15) AND ($row[1] < $reset_cap_16) )
{
$level = $level_cap_16_vip;
$gcoin_reset_vip = $gcoin_cap_16_vip;
$time_reset_next = $time_reset_next_16;
}
elseif ( ($row[1] >= $reset_cap_16) AND ($row[1] < $reset_cap_17) )
{
$level = $level_cap_17_vip;
$gcoin_reset_vip = $gcoin_cap_17_vip;
$time_reset_next = $time_reset_next_17;
}
elseif ( ($row[1] >= $reset_cap_17) AND ($row[1] < $reset_cap_18) )
{
$level = $level_cap_18_vip;
$gcoin_reset_vip = $gcoin_cap_18_vip;
$time_reset_next = $time_reset_next_18;
}
elseif ( ($row[1] >= $reset_cap_18) AND ($row[1] < $reset_cap_19) )
{
$level = $level_cap_19_vip;
$gcoin_reset_vip = $gcoin_cap_19_vip;
$time_reset_next = $time_reset_next_19;
}
elseif ( ($row[1] >= $reset_cap_19) AND ($row[1] < $reset_cap_20) )
{
$level = $level_cap_20_vip;
$gcoin_reset_vip = $gcoin_cap_20_vip;
$time_reset_next = $time_reset_next_20;
}

$gcoinnew = $gcoin[0];
$gcoin_km = $gcoin[1];
$gcoin_total = $gcoinnew + $gcoin_km;
if ($tiente == 'gcoin') {
$gcoin_rs = $gcoin_reset_vip+$gcoin_extra;
if ( $gcoin_total < $gcoin_rs )
{
echo "Không có đủ gcoin yêu cầu Reset. Bạn đang Reset $row[1] lần. Bạn cần có $gcoin_rs gcoin chi phí Reset VIP"; exit();
}
else {
if ( $gcoin_rs <= $gcoin_km )
{
$gcoin_km -= $gcoin_rs;
}
else
{
$gcoinnew -= $gcoin_rs - $gcoin_km;
$gcoin_km = 0;
}

}
} elseif ($tiente == 'vpoint') {
$vpoint_reset_vip = $gcoin_reset_vip * ( 1 + $vpoint_extra / 100 );
if ( $vpointnew < $vpoint_reset_vip )
{
echo "Không có đủ Vpoint yêu cầu Reset. Bạn đang Reset ";
echo $row['1'];
echo " lần. Bạn cần có ";
echo $vpoint_reset_vip;
echo " Vpoint chi phí Reset VIP";
exit( );
}
$vpointnew -= $vpoint_reset_vip;
} else { echo "Sai loại tiền tệ"; exit(); }

//Begin hỗ trợ tân thủ
if ($hotrotanthu == 1) {
$Resetnow = $row[1];
$Relifenow = $row[5];
if ( 1 <= $capsudung && $cap1_reset_min <= $row[1] && $row[1] <= $cap1_reset_max && $cap1_relife_min <= $row[5] && $row[5] <= $cap1_relife_max )
{
$level -= $cap1_levelgiam;
}
else if ( 2 <= $capsudung && $cap2_reset_min <= $row[1] && $row[1] <= $cap2_reset_max && $cap2_relife_min <= $row[5] && $row[5] <= $cap2_relife_max )
{
$level -= $cap2_levelgiam;
}
else if ( 3 <= $capsudung && $cap3_reset_min <= $row[1] && $row[1] <= $cap3_reset_max && $cap3_relife_min <= $row[5] && $row[5] <= $cap3_relife_max )
{
$level -= $cap3_levelgiam;
}
else if ( 4 <= $capsudung && $cap4_reset_min <= $row[1] && $row[1] <= $cap4_reset_max && $cap4_relife_min <= $row[5] && $row[5] <= $cap4_relife_max )
{
$level -= $cap4_levelgiam;
}
else if ( 5 <= $capsudung && $cap5_reset_min <= $row[1] && $row[1] <= $cap5_reset_max && $cap5_relife_min <= $row[5] && $row[5] <= $cap5_relife_max )
{
$level -= $cap5_levelgiam;
}
}
//End hỗ trợ tân thủ

$relife = $row[5];
$resetold = $row[1]; $resetold = abs(intval($resetold));
$resetup = $resetold + 1;
list( , $resetold, , , , $relife ) = $row;
$resetold = abs( intval( $resetold ) );
$resetup = $resetold + 1;
if ($row[0] < $level) {echo "$name cần $level level để Reset lần $resetup."; exit();}


$time_reset_next = $row[7]+$time_reset_next*60;
if ($time_reset_next > $timestamp) {
$time_free = $time_reset_next - $timestamp;
echo "$name cần $time_free giây nữa để Reset lần tiếp theo."; exit();
}

switch ($row[5]) {
case 0:
$reset_relifes = $rl_reset_relife1;
$point_relifes = 0;
$ml_relifes = 0;
break;
case 1:
$reset_relifes = $rl_reset_relife2;
$point_relifes = $rl_point_relife1;
$ml_relifes = $rl_ml_relife1;
break;
case 2:
$reset_relifes = $rl_reset_relife3;
$point_relifes = $rl_point_relife2;
$ml_relifes = $rl_ml_relife2;
break;
case 3:
$reset_relifes = $rl_reset_relife4;
$point_relifes = $rl_point_relife3;
$ml_relifes = $rl_ml_relife3;
break;
case 4:
$reset_relifes = $rl_reset_relife5;
$point_relifes = $rl_point_relife4;
$ml_relifes = $rl_ml_relife4;
break;
case 5:
$reset_relifes = $rl_reset_relife6;
$point_relifes = $rl_point_relife5;
$ml_relifes = $rl_ml_relife5;
break;
case 6:
$reset_relifes = $rl_reset_relife7;
$point_relifes = $rl_point_relife6;
$ml_relifes = $rl_ml_relife6;
break;
case 7;
$reset_relifes = $rl_reset_relife8;
$point_relifes = $rl_point_relife7;
$ml_relifes = $rl_ml_relife7;
break;
case 8:
$reset_relifes = $rl_reset_relife9;
$point_relifes = $rl_point_relife8;
$ml_relifes = $rl_ml_relife8;
break;
case 9:
$reset_relifes = $rl_reset_relife10;
$point_relifes = $rl_point_relife9;
$ml_relifes = $rl_ml_relife9;
break;
case 10:
$reset_relifes = $rl_reset_relife11;
$point_relifes = $rl_point_relife10;
$ml_relifes = $rl_ml_relife10;
break;
}

if ( $row[1] >= $reset_relifes ) {
echo "$name đang ReLife: $row[5] - Reset: $row[1]. Để Reset tiếp bạn cần phải ReLife."; exit();
}

//Reset lần 1
if ($row[1] == $reset_cap_0)
{
$resetpoint=$point_relifes+$point_cap_1_vip;
$leadership = $ml_relifes+$ml_cap_1_vip;
}
//Reset cấp 1
elseif ($row[1] < $reset_cap_1)
{
$resetpoint=$point_relifes+$point_cap_1_vip+$row[1]*$point_cap_1_vip;
$leadership = $ml_relifes+$ml_relifes+$ml_cap_1_vip+$row[1]*$ml_cap_1_vip;
}
//Reset cấp 1 -> 2
elseif ($row[1] >= $reset_cap_1 AND $row[1] < $reset_cap_2)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($row[1]-($reset_cap_1-1))*$point_cap_2_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($row[1]-($reset_cap_1-1))*$ml_cap_2_vip;
}
//Reset cấp 2 -> 3
elseif ($row[1] >= $reset_cap_2 AND $row[1] < $reset_cap_3)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$point_cap_3_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($row[1]-($reset_cap_2-1))*$ml_cap_3_vip;
}
//Reset cấp 3 -> 4
elseif ($row[1] >= $reset_cap_3 AND $row[1] < $reset_cap_4)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$point_cap_4_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($row[1]-($reset_cap_3-1))*$ml_cap_4_vip;
}
//Reset cấp 4 -> 5
elseif ($row[1] >= $reset_cap_4 AND $row[1] < $reset_cap_5)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$point_cap_5_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($row[1]-($reset_cap_4-1))*$ml_cap_5_vip;
}
//Reset cấp 5 -> 6
elseif ($row[1] >= $reset_cap_5 AND $row[1] < $reset_cap_6)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$point_cap_6_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($row[1]-($reset_cap_5-1))*$ml_cap_6_vip;
}
//Reset cấp 6 -> 7
elseif ($row[1] >= $reset_cap_6 AND $row[1] < $reset_cap_7)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$point_cap_7_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($row[1]-($reset_cap_6-1))*$ml_cap_7_vip;
}
//Reset cấp 7 -> 8
elseif ($row[1] >= $reset_cap_7 AND $row[1] < $reset_cap_8)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$point_cap_8_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($row[1]-($reset_cap_7-1))*$ml_cap_8_vip;
}
//Reset cấp 8 -> 9
elseif ($row[1] >= $reset_cap_8 AND $row[1] < $reset_cap_9)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$point_cap_9_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($row[1]-($reset_cap_8-1))*$ml_cap_9_vip;
}
//Reset cấp 9 -> 10
elseif ($row[1] >= $reset_cap_9 AND $row[1] < $reset_cap_10)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$point_cap_10_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($row[1]-($reset_cap_9-1))*$ml_cap_10_vip;
}
//Reset cấp 10 -> 11
elseif ($row[1] >= $reset_cap_10 AND $row[1] < $reset_cap_11)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$point_cap_11_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($row[1]-($reset_cap_10-1))*$ml_cap_11_vip;
}
//Reset cấp 11 -> 12
elseif ($row[1] >= $reset_cap_11 AND $row[1] < $reset_cap_12)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$point_cap_12_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($row[1]-($reset_cap_11-1))*$ml_cap_12_vip;
}
//Reset cấp 12 -> 13
elseif ($row[1] >= $reset_cap_12 AND $row[1] < $reset_cap_13)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$point_cap_13_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($row[1]-($reset_cap_12-1))*$ml_cap_13_vip;
}
//Reset cấp 13 -> 14
elseif ($row[1] >= $reset_cap_13 AND $row[1] < $reset_cap_14)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$point_cap_14_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($row[1]-($reset_cap_13-1))*$ml_cap_14_vip;
}
//Reset cấp 14 -> 15
elseif ($row[1] >= $reset_cap_14 AND $row[1] < $reset_cap_15)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$point_cap_15_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($row[1]-($reset_cap_14-1))*$ml_cap_15_vip;
}
//Reset cấp 15 -> 16
elseif ($row[1] >= $reset_cap_15 AND $row[1] < $reset_cap_16)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$point_cap_16_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($row[1]-($reset_cap_15-1))*$ml_cap_16_vip;
}
//Reset cấp 16 -> 17
elseif ($row[1] >= $reset_cap_16 AND $row[1] < $reset_cap_17)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$point_cap_17_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($row[1]-($reset_cap_16-1))*$ml_cap_17_vip;
}
//Reset cấp 17 -> 18
elseif ($row[1] >= $reset_cap_17 AND $row[1] < $reset_cap_18)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($point_cap_17_vip*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$point_cap_18_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($ml_cap_17_vip*($reset_cap_17-$reset_cap_16))+($row[1]-($reset_cap_17-1))*$ml_cap_18_vip;
}
//Reset cấp 18 -> 19
elseif ($row[1] >= $reset_cap_18 AND $row[1] < $reset_cap_19)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($point_cap_17_vip*($reset_cap_17-$reset_cap_16))+($point_cap_18_vip*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$point_cap_19_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($ml_cap_17_vip*($reset_cap_17-$reset_cap_16))+($ml_cap_18_vip*($reset_cap_18-$reset_cap_17))+($row[1]-($reset_cap_18-1))*$ml_cap_19_vip;
}
//Reset cấp 19 -> 20
elseif ($row[1] >= $reset_cap_19 AND $row[1] < $reset_cap_20)
{
$resetpoint=$point_relifes+($point_cap_1_vip*$rese t_cap_1)+($point_cap_2_vip*($reset_cap_2-$reset_cap_1))+($point_cap_3_vip*($reset_cap_3-$reset_cap_2))+($point_cap_4_vip*($reset_cap_4-$reset_cap_3))+($point_cap_5_vip*($reset_cap_5-$reset_cap_4))+($point_cap_6_vip*($reset_cap_6-$reset_cap_5))+($point_cap_7_vip*($reset_cap_7-$reset_cap_6))+($point_cap_8_vip*($reset_cap_8-$reset_cap_7))+($point_cap_9_vip*($reset_cap_9-$reset_cap_8))+($point_cap_10_vip*($reset_cap_10-$reset_cap_9))+($point_cap_11_vip*($reset_cap_11-$reset_cap_10))+($point_cap_12_vip*($reset_cap_12-$reset_cap_11))+($point_cap_13_vip*($reset_cap_13-$reset_cap_12))+($point_cap_14_vip*($reset_cap_14-$reset_cap_13))+($point_cap_15_vip*($reset_cap_15-$reset_cap_14))+($point_cap_16_vip*($reset_cap_16-$reset_cap_15))+($point_cap_17_vip*($reset_cap_17-$reset_cap_16))+($point_cap_18_vip*($reset_cap_18-$reset_cap_17))+($point_cap_19_vip*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$point_cap_20_vip;
$leadership=$ml_relifes+($ml_cap_1_vip*$reset_cap_ 1)+($ml_cap_2_vip*($reset_cap_2-$reset_cap_1))+($ml_cap_3_vip*($reset_cap_3-$reset_cap_2))+($ml_cap_4_vip*($reset_cap_4-$reset_cap_3))+($ml_cap_5_vip*($reset_cap_5-$reset_cap_4))+($ml_cap_6_vip*($reset_cap_6-$reset_cap_5))+($ml_cap_7_vip*($reset_cap_7-$reset_cap_6))+($ml_cap_8_vip*($reset_cap_8-$reset_cap_7))+($ml_cap_9_vip*($reset_cap_9-$reset_cap_8))+($ml_cap_10_vip*($reset_cap_10-$reset_cap_9))+($ml_cap_11_vip*($reset_cap_11-$reset_cap_10))+($ml_cap_12_vip*($reset_cap_12-$reset_cap_11))+($ml_cap_13_vip*($reset_cap_13-$reset_cap_12))+($ml_cap_14_vip*($reset_cap_14-$reset_cap_13))+($ml_cap_15_vip*($reset_cap_15-$reset_cap_14))+($ml_cap_16_vip*($reset_cap_16-$reset_cap_15))+($ml_cap_17_vip*($reset_cap_17-$reset_cap_16))+($ml_cap_18_vip*($reset_cap_18-$reset_cap_17))+($ml_cap_19_vip*($reset_cap_19-$reset_cap_18))+($row[1]-($reset_cap_19-1))*$ml_cap_20_vip;
}
//Fix Menh lenh DarkLord > 32k
if ( $leadership>32000 ) $leadership=32000;


$ClassType = $row[4];
switch ($ClassType){
case 0:
case 1:
case 2:
case 3:
$Class_Default = 0;
break;

case 16:
case 17:
case 18:
case 19:
$Class_Default = 16;
break;

case 32:
case 33:
case 34:
case 35:
$Class_Default = 32;
break;

case 48:
case 49:
case 50:
$Class_Default = 48;
break;

case 64:
case 65:
case 66:
$Class_Default = 64;
break;

case 80:
case 81:
case 82:
case 83:
$Class_Default = 80;
break;

case 96:
case 97:
case 98:
$Class_Default = 96;
break;

default :
$Class_Default = 0;
}
$default_query = "SELECT Strength, Dexterity, Vitality, Energy, Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY FROM DefaultClassType WHERE Class=" . $Class_Default;
$default_result = $db->execute($default_query);
$Date = date("h:i:sA, d/m/Y");
$fp = fopen("log_rs.txt", "a+");
fputs ($fp, "Lúc: $Date. $default_query \n");
fclose($fp);
check_queryerror($default_query, $default_result);
$point_default = $default_result->fetchrow();
$Strength_Default = $point_default[0];
$Dexterity_Default = $point_default[1];
$Vitality_Default = $point_default[2];
$Energy_Default = $point_default[3];
$Life_Default = $point_default[4];
$MaxLife_Default = $point_default[5];
$Mana_Default = $point_default[6];
$MaxMana_Default = $point_default[7];
$MapNumber_Default = $point_default[8];
$MapPosX_Default = $point_default[9];
$MapPosY_Default = $point_default[10];


$Strength = $Strength_Default;
$Dexterity = $Dexterity_Default;
$Vitality = $Vitality_Default;
$Energy = $Energy_Default;
$Life = $Life_Default;
$MaxLife = $MaxLife_Default;
$Mana = $Mana_Default;
$MaxMana = $MaxMana_Default;
$MapNumber = $MapNumber_Default;
$MapPosX = $MapPosX_Default;
$MapPosY = $MapPosY_Default;
$Mapdir=0;

$Point_Default_total = $Strength + $Dexterity + $Vitality + $Energy;
//End Cong thuc Reset

//Tat ca cac Quest
$all_quest="Update character set Quest=0xaaeaffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffff where name='$name'";
if( intval($level_after_reset) >1 ) $clevel = $level_after_reset;
else $clevel = 1;

$point_event_query = "SELECT point_event FROM Character WHERE Name='$name'";
$point_event_qr = $db->Execute($point_event_query);
check_queryerror($point_event_query, $point_event_qr);
$point_event = $point_event_qr->fetchrow();
$resetpoint = $resetpoint + $point_event[0];


if( $resetpoint > 65000) {
$pointup = 65000;
$resetpoint = $resetpoint - 65000;
} else {
$pointup = $resetpoint;
$resetpoint = 0;
}

switch ($month)
{
case '01' : $fieldtopmonth = 'TopMonth01'; break;
case '02' : $fieldtopmonth = 'TopMonth02'; break;
case '03' : $fieldtopmonth = 'TopMonth03'; break;
case '04' : $fieldtopmonth = 'TopMonth04'; break;
case '05' : $fieldtopmonth = 'TopMonth05'; break;
case '06' : $fieldtopmonth = 'TopMonth06'; break;
case '07' : $fieldtopmonth = 'TopMonth07'; break;
case '08' : $fieldtopmonth = 'TopMonth08'; break;
case '09' : $fieldtopmonth = 'TopMonth09'; break;
case '10' : $fieldtopmonth = 'TopMonth10'; break;
case '11' : $fieldtopmonth = 'TopMonth11'; break;
case '12' : $fieldtopmonth = 'TopMonth12'; break;
default : $fieldtopmonth = 'TopMonth01';
}

kiemtra_doinv($login,$name);
kiemtra_online($login);

// Reset nhan vat la Darklord
if ($row[4] == 64 OR $row[4] == 65 OR $row[4] == 66)
{
$sql_reset_script="Update dbo.character set [clevel]='$clevel',[experience]='0',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='0',[Leadership]='$leadership',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='1',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script);
check_queryerror($sql_reset_script, $sql_reset_exec);

//Nhan vat dang ki tai sinh
if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup,[LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Leadership]='$leadership',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
check_queryerror($msquery,$msresults);
}
}

//Reset nhan vat khong phai la DarkLord
else
{
$sql_reset_script="Update Character set [clevel]='$clevel',[experience]='0',[LevelUpPoint]='$pointup',[pointdutru]='$resetpoint',[resets]=$resetup, ResetNBB=$resetup,[strength]='$Strength',[dexterity]='$Dexterity',[vitality]='$Vitality',[energy]='$Energy',[Life]='$Life',[MaxLife]='$MaxLife',[Mana]='$Mana',[MaxMana]='$MaxMana',[MapNumber]='$MapNumber',[MapPosX]='$MapPosX',[MapPosY]='$MapPosY',[MapDir]='$Mapdir',[Leadership]='0',[isThuePoint]='0',[NoResetInDay]=$CountNoResetInDay,[". $fieldtopmonth ."]=". $fieldtopmonth ."+1,[Resets_Time]='$timestamp',[ResetVIP]='1',[PointThue]='0' where name='$name'";
$sql_reset_exec = $db->Execute($sql_reset_script);
check_queryerror($sql_reset_script, $sql_reset_exec);

//All Quest For Class 3
//if ($row[4] == $class_dw_3 OR $row[4] == $class_dk_3 OR $row[4] == $class_elf_3 OR $row[4] == $class_mg_2 OR $row[4] == $class_dl_2 OR $row[4] == $class_sum_3) {
// $sql_all_quest = $db->Execute($all_quest);
// check_queryerror($all_quest,$sql_all_quest);
// }

if ($char_back_reged_check > 0) {
$msquery = "Update Character_back set [Resets]=$resetup,[LevelUpPoint]='$resetpoint',[Class]='$row[4]',[Relifes]='$row[5]' where name='$name'";
$msresults= $db->Execute($msquery);
check_queryerror($msquery, $msquery);
}
}

//Reset Point Master Skill
//include_once('MasterLV.php');

$tru_vpoint_query = "UPDATE MEMB_INFO SET [vpoint]=$vpointnew WHERE memb___id='$login'";
$tru_vpoint = $db->Execute($tru_vpoint_query);
check_queryerror($tru_vpoint_query, $tru_vpoint);

$tru_gcoin_query = "UPDATE MEMB_INFO SET [gcoin]=$gcoinnew,gcoin_km=$gcoin_km WHERE memb___id='$login'";
$tru_gcoin = $db->Execute($tru_gcoin_query);
check_queryerror($tru_gcoin_query, $tru_gcoin);

//Event TOP Reset in Time
include_once('event_toprs_intime.php');

top50();

//Ghi vào Log nhung nhan vàt Reset VIP
/*
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
$log_price = "";
$log_Des = "";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
*/
$info_log_query = "SELECT gcoin, gcoin_km, vpoint FROM MEMB_INFO WHERE memb___id='$login'";
$info_log_result = $db->Execute($info_log_query);
check_queryerror($info_log_query, $info_log_result);
$info_log = $info_log_result->fetchrow();

$log_acc = "$login";
$log_gcoin = $info_log[0];
$log_gcoin_km = $info_log[1];
$log_vpoint = $info_log[2];
if ($tiente == 'vpoint')
{
$log_price = "- $vpoint_reset_vip Vpoint";
} else
{
$log_price = " - $gcoin_rs Gcoin";
}

$log_Des = "<b>$name</b> Reset VIP lần thứ <b>$resetup</b> khi ". $row[0] ." Level/". $resetold ." Reset, Relife $relife";
$log_time = $timestamp;

$insert_log_query = "INSERT INTO Log_TienTe (acc, gcoin, gcoin_km, vpoint, price, Des, time) VALUES ('$log_acc', $log_gcoin, $log_gcoin_km, $log_vpoint, '$log_price', '$log_Des', $log_time)";
$insert_log_result = $db->execute($insert_log_query);
check_queryerror($insert_log_query, $insert_log_result);
//End Ghi vào Log nhung nhan vàt Reset tren 0 lan

$reponse = "<info>OK</info>
<gcoin>$gcoinnew</gcoin>
<gcoin_km>$gcoin_km</gcoin_km>
<vpoint>$vpointnew</vpoint>
<resetpoint>$pointup</resetpoint>
<pointdutru>$resetpoint</pointdutru>
<messenge>$name Reset VIP lần thứ $resetup thành công!";
if($resetpoint > 0) {
$reponse .= " Point sau khi Reset trên 65.000 Point. Bạn vào Game cộng điểm sau đó vào phần <b>Rút Point</b> để lấy Point còn lại";
}
$reponse .= "</messenge>";

echo $reponse;
}
?>
Ông không nói ở file nào bố ao mà tìm đc :(

cuocdoisp
27-03-13, 08:18 AM
Ông không nói ở file nào bố ao mà tìm đc :(
không biết thì nên hỏi chứ nói vậy người chỉ sẽ buồn đó
. Anh gà lên chỉ biết mò thôi , để ý thấy code có dòng check Security lên mò thư mục nào có security và config thì tìm . Anh mò ra 1 cái nè
/ server/sms_reset.php