PHP Code:
class Vip {
function VipProcess($userid,$plan) {
global $common;
$plan = Decode($plan);
if(check_value($userid) && Validator::Number($userid)) {
$planData = $this->PlanInfo($plan);
$userData = $common->accountInformation($userid);
if(is_array($userData) && is_array($planData)) {
// data
$username = $userData[_CLMN_USERNM_];
$vipstamp = $userData[_CLMN_VIP_STAMP_];
$plandays = $planData['days'];
$plandiscount = $planData['discount_percent'];
$planprice = $this->CalculatePlanCost($plandays,$plandiscount);
if(!$common->accountOnline($username)) {
// deduct credits
$deduct = $common->substractCredits($userid,$planprice);
if($deduct) {
if($this->isVIP($userid)) {
// Extend Timestamp
$new_timestamp = $this->CalculateExtension($vipstamp,$plandays);
$update = $common->updateVipTimeStamp($userid,$new_timestamp);
if($update) {
// success
message('success', lang('success_13',true));
} else {
// unkown error
message('error', lang('error_23',true));
}
} else {
// New timestamp
$new_timestamp = $this->CalculateTimestamp($plandays);
if(mconfig('vip_enable_promotion')) {
if($this->vipGetsPromotion()) {
$new_timestamp = $this->addPromotionDays($new_timestamp);
$gotFreeDays = true;
} else {
$gotFreeDays = false;
}
}
$update = $common->updateVipTimeStamp($userid,$new_timestamp);
if($update) {
// success
message('success', lang('success_14',true));
if($gotFreeDays) {
message('success', lang('vip_reward_1b',true).mconfig('vip_promotion_reward_days').lang('vip_reward_1c',true), lang('vip_reward_1a',true));
}
} else {
// unkown error
message('error', lang('error_23',true));
}
}
} else {
// not enough credits
message('error', lang('error_40',true));
}
} else {
// account is online
message('error', lang('error_14',true));
}
} else {
// invalid user (unknown error)
message('error', lang('error_23',true));
}
} else {
// missing data (unknown error)
message('error', lang('error_23',true));
}
}
function PackageExists($id) {
$VipPlans = mconfig('vip_plans');
if(is_array($VipPlans)) {
if(array_key_exists(0, $VipPlans)) {
if(is_array($VipPlans[$id])) {
return true;
}
} else {
return true;
}
}
}
function PlanInfo($id) {
if($this->PackageExists($id)) {
$VipPlans = mconfig('vip_plans');
if(array_key_exists(0, $VipPlans)) {
return $VipPlans[$id];
} else {
return $VipPlans;
}
}
}
function CalculateTimestamp($days) {
if(check_value($days) && Validator::Number($days) && $days >= 1) {
$vip_days = 60*60*24*$days;
$free_time = 3600;
$result = time() + $free_time + $vip_days;
return $result;
}
}
function CalculateExtension($timestamp,$days) {
if(check_value($timestamp) && check_value($days) && Validator::Number($days) && $days >= 1) {
$vip_days = 60*60*24*$days;
$result = $timestamp + $vip_days;
return $result;
}
}
function isVIP($userid) {
global $common;
if(check_value($userid) && Validator::Number($userid)) {
$accountInfo = $common->accountInformation($userid);
if($accountInfo) {
$vipTimestamp = $accountInfo[_CLMN_VIP_STAMP_];
if($vipTimestamp > time()) {
return true;
}
}
}
}
function RemainingVIP($timestamp) {
if(check_value($timestamp) && Validator::Number($timestamp)) {
$calculate = ($timestamp - time()) / (60*60*24);
return round($calculate);
}
}
function vipGetsPromotion() {
$success_rate = mconfig('vip_promotion_success_percent');
$random = rand(1,100);
if($random <= $success_rate) {
return true;
}
}
function addPromotionDays($timestamp) {
if(check_value($timestamp) && Validator::Number($timestamp)) {
$promotion_days = 60*60*24*mconfig('vip_promotion_reward_days');
return $timestamp+$promotion_days;
}
}
function CalculatePlanCost($days,$discount=0) {
if(check_value($days) && Validator::Number($days)) {
$vip_day_cost = mconfig('vip_day_cost');
$calculate_days_cost = round($days*$vip_day_cost);
if($discount >= 1) {
// Formula: original price - ( (discount % / 100) * original price )
$discounted_price = $calculate_days_cost - (($discount/100)*$calculate_days_cost);
return round($discounted_price);
} else {
return round($calculate_days_cost);
}
}
}
}
Result:



What/how do i insert something on the script so that it would also update/post/put/insert something on AccountLevel and AccountExpireDate? These columns are the ones affecting VIP in game.
@RevolGaming
@natzugen
Help please...
Thanks :)
- - - Updated - - -
@Edit


So i manged to point the stamping of vip system to muemu's AccountExpireDate column by modifying the script below:
PHP Code:
class Vip {
function VipProcess($userid,$plan) {
global $common;
$plan = Decode($plan);
if(check_value($userid) && Validator::Number($userid)) {
$planData = $this->PlanInfo($plan);
$userData = $common->accountInformation($userid);
if(is_array($userData) && is_array($planData)) {
// data
$username = $userData[_CLMN_USERNM_];
$vipstamp = $userData[_CLMN_VIP_STAMP_];
$plandays = $planData['days'];
$plandiscount = $planData['discount_percent'];
$planprice = $this->CalculatePlanCost($plandays,$plandiscount);
if(!$common->accountOnline($username)) {
// deduct credits
$deduct = $common->substractCredits($userid,$planprice);
if($deduct) {
if($this->isVIP($userid)) {
// Extend Timestamp
$new_timestamp = $this->CalculateExtension($vipstamp,$plandays);
$update = $common->updateVipTimeStamp($userid,$new_timestamp);
if($update) {
// success
message('success', lang('success_13',true));
} else {
// unkown error
message('error', lang('error_23',true));
}
} else {
// New timestamp
$new_timestamp = $this->CalculateTimestamp($plandays);
if(mconfig('vip_enable_promotion')) {
if($this->vipGetsPromotion()) {
$new_timestamp = $this->addPromotionDays($new_timestamp);
$gotFreeDays = true;
} else {
$gotFreeDays = false;
}
}
$update = $common->updateVipTimeStamp($userid,$new_timestamp);
if($update) {
// success
message('success', lang('success_14',true));
if($gotFreeDays) {
message('success', lang('vip_reward_1b',true).mconfig('vip_promotion_reward_days').lang('vip_reward_1c',true), lang('vip_reward_1a',true));
}
} else {
// unkown error
message('error', lang('error_23',true));
}
}
} else {
// not enough credits
message('error', lang('error_40',true));
}
} else {
// account is online
message('error', lang('error_14',true));
}
} else {
// invalid user (unknown error)
message('error', lang('error_23',true));
}
} else {
// missing data (unknown error)
message('error', lang('error_23',true));
}
}
function PackageExists($id) {
$VipPlans = mconfig('vip_plans');
if(is_array($VipPlans)) {
if(array_key_exists(0, $VipPlans)) {
if(is_array($VipPlans[$id])) {
return true;
}
} else {
return true;
}
}
}
function PlanInfo($id) {
if($this->PackageExists($id)) {
$VipPlans = mconfig('vip_plans');
if(array_key_exists(0, $VipPlans)) {
return $VipPlans[$id];
} else {
return $VipPlans;
}
}
}
function CalculateTimestamp($days) {
if(check_value($days) && Validator::Number($days) && $days >= 1) {
//$vip_days = 60*60*24*$days;
//$free_time = 3600;
$result = date('Y-m-d H:i:s', strtotime("+ " .$days. " day"));
return $result;
}
}
function CalculateExtension($timestamp,$days) {
if(check_value($timestamp) && check_value($days) && Validator::Number($days) && $days >= 1) {
$vip_days = 60*60*24*$days;
$tsnum = strtotime($timestamp);
$tsnumvip = $tsnum + $vip_days;
$extendtime = date('Y-m-d H:i:s', $tsnumvip);
//$result = $timestamp + $vip_days;
return $extendtime;
}
}
function isVIP($userid) {
global $common;
if(check_value($userid) && Validator::Number($userid)) {
$accountInfo = $common->accountInformation($userid);
if($accountInfo) {
$vipTimestamp = $accountInfo[_CLMN_VIP_STAMP_];
if($vipTimestamp > date('Y-m-d H:i:s', time())) {
return true;
}
}
}
}
function RemainingVIP($timestamp) {
if(check_value($timestamp) && Validator::Date($timestamp)) {
//$calculate = ($timestamp - time()) / (60*60*24);
return $timestamp;
}
}
function vipGetsPromotion() {
$success_rate = mconfig('vip_promotion_success_percent');
$random = rand(1,100);
if($random <= $success_rate) {
return true;
}
}
function addPromotionDays($timestamp) {
if(check_value($timestamp) && Validator::Number($timestamp)) {
$promotion_days = 60*60*24*mconfig('vip_promotion_reward_days');
return $timestamp+$promotion_days;
}
}
function CalculatePlanCost($days,$discount=0) {
if(check_value($days) && Validator::Number($days)) {
$vip_day_cost = mconfig('vip_day_cost');
$calculate_days_cost = round($days*$vip_day_cost);
if($discount >= 1) {
// Formula: original price - ( (discount % / 100) * original price )
$discounted_price = $calculate_days_cost - (($discount/100)*$calculate_days_cost);
return round($discounted_price);
} else {
return round($calculate_days_cost);
}
}
}
}
But the problem is with modifying the column AccountLevel.
i tried to use original automatic vip expiry procedure which is originally working with expiration:
Code:
USE [MuOnline]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[WZ_GetAccountLevel]
@account varchar(10)
AS
BEGIN
SET NOCOUNT ON
SET XACT_ABORT ON
DECLARE @CurrentAccountLevel int
DECLARE @CurrentAccountExpireDate smalldatetime
SELECT @CurrentAccountLevel = AccountLevel, @CurrentAccountExpireDate = AccountExpireDate FROM MEMB_INFO WHERE memb___id = @account
IF (@CurrentAccountLevel <> 0 AND GETDATE() > @CurrentAccountExpireDate)
BEGIN
SET @CurrentAccountLevel = 0
UPDATE MEMB_INFO SET AccountLevel = @CurrentAccountLevel, AccountExpireDate = @CurrentAccountExpireDate WHERE memb___id = @account
END
SELECT @CurrentAccountLevel as AccountLevel, @CurrentAccountExpireDate as AccountExpireDate
SET NOCOUNT OFF
SET XACT_ABORT OFF
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
Into:
Code:
USE [MuOnline]
GO
/****** Object: StoredProcedure [dbo].[WZ_GetAccountLevel] Script Date: 11/30/2016 21:32:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[WZ_GetAccountLevel]
@account varchar(10)
AS
BEGIN
SET NOCOUNT ON
SET XACT_ABORT ON
DECLARE @CurrentAccountLevel int
DECLARE @CurrentAccountExpireDate smalldatetime
SELECT @CurrentAccountLevel = AccountLevel, @CurrentAccountExpireDate = AccountExpireDate FROM MEMB_INFO WHERE memb___id = @account
IF (@CurrentAccountLevel <> 0 AND GETDATE() > @CurrentAccountExpireDate)
BEGIN
SET @CurrentAccountLevel = 0
UPDATE MEMB_INFO SET AccountLevel = @CurrentAccountLevel, AccountExpireDate = @CurrentAccountExpireDate WHERE memb___id = @account
END
ELSE
IF (@CurrentAccountLevel = 0 AND GETDATE() < @CurrentAccountExpireDate)
BEGIN
SET @CurrentAccountLevel = 0
UPDATE MEMB_INFO SET AccountLevel = @CurrentAccountLevel, AccountExpireDate = @CurrentAccountExpireDate WHERE memb___id = @account
END
SELECT @CurrentAccountLevel as AccountLevel, @CurrentAccountExpireDate as AccountExpireDate
SET NOCOUNT OFF
SET XACT_ABORT OFF
END
But it is not working......
i also tried:
Code:
USE [MuOnline]
GO
/****** Object: StoredProcedure [dbo].[WZ_GetAccountLevelVIP] Script Date: 11/30/2016 21:34:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[WZ_GetAccountLevelVIP]
@account varchar(10)
AS
BEGIN
SET NOCOUNT ON
SET XACT_ABORT ON
DECLARE @CurAccountLevel int
DECLARE @CurAccountExpireDate smalldatetime
SELECT @CurAccountLevel = AccountLevel, @CurAccountExpireDate = AccountExpireDate FROM MEMB_INFO WHERE memb___id = @account
IF (@CurAccountLevel = 0 AND @CurAccountExpireDate < Getdate())
BEGIN
SET @CurAccountLevel = 1
UPDATE MEMB_INFO SET AccountLevel = @CurAccountLevel, AccountExpireDate = @CurAccountExpireDate WHERE memb___id = @account
END
SELECT @CurAccountLevel as AccountLevel, @CurAccountExpireDate as AccountExpireDate
SET NOCOUNT OFF
SET XACT_ABORT OFF
END
Still not working....
Any idea how to make it work?, holiday is ending so fast xD....