USE [SRO_VT_SYSTEM_]
GO
/****** Object: StoredProcedure [dbo].[_JobSystem] Script Date: 01/06/2014 02:22:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[_JobSystem]
@CharID INT,
@Desc varchar(128)
AS
declare @Hisname varchar(500) = (select LEFT((Select Substring(@desc, PATINDEX('%(%',@desc) + 1, LEN(@desc))), CHARINDEX(')', (Select Substring(@desc, PATINDEX('%(%',@desc) + 1, LEN(@desc)))) - 1) WHERE CHARINDEX(')',(Select Substring(@desc, PATINDEX('%(%',@desc) + 1, LEN(@desc)))) > 0)
declare @HisJob varchar(300) = (select 'JobType' = Case When JobType = 1 Then 'Trader' When JobType = 2 Then 'Robber' When JobType = 3 Then 'Hunter' End From SRO_VT_SHARD.dbo._CharTrijob where CharID = (Select CharID From SRO_VT_SHARD.dbo._Char Where CharName16 = @HisName))
declare @MyCharName varchar(200) = (Select CharName16 From SRO_VT_SHARD.dbo._Char Where CharID = @CharID)
declare @MyJob varchar(300) = (select 'JobType' = Case When JobType = 1 Then 'Trader' When JobType = 2 Then 'Robber' When JobType = 3 Then 'Hunter' End From SRO_VT_SHARD.dbo._CharTrijob where CharID = @CharID)
declare @TotalKill int = (Select TotalKillCount From _JobKillLog Where CharID = @CharID And HisName = @Hisname)
declare @Penalty varchar(max) = (select SUM(TotalKillCount) from _JobKillLog where MyCharName = @MyCharName)
declare @IP1 varchar(max) = (select IP from _IPLogs Where Charname = @MyCharName)
declare @IP2 varchar(max) = (select IP from _IPLogs Where Charname = @Hisname)
declare @silk int = '1'
declare @JID int = (Select UserJID from SRO_VT_SHARD.dbo._User Where CharID = (Select CharID From SRO_VT_SHARD.dbo._Char Where CharName16 = @MyCharName))
declare @ID varchar(200) = (Select StrUserID From SRO_VT_ACCOUNT.dbo.TB_User Where JID = @JID)
if not exists (Select CharID From _JobKillLog Where CharID = @CharID And HisName = @Hisname) And (@MyCharName not in (select CharName from _PenatlyJOB Where CharName = @MyCharName))
begin
Insert Into _JobKillLog values (@CharID,@MyJob,@MyCharName,@Hisname,@HisJob,1,Get Date(),NULL)
EXEC [SRO_VT_ACCOUNT].[CGI].[CGI_WebPurchaseSilk] @OrderID = NULL, @UserID = @ID, @PkgID = NULL, @NumSilk = @Silk, @Price = NULL
end
if exists (select CharID,HisName from _JobKillLog Where CharID = @CharID and HisName = @Hisname and EndDate is null) and (@TotalKill < 5) And (@MyCharName not in (select CharName from _PenatlyJOB Where CharName = @MyCharName))
and (@IP1 != @IP2)
begin
update _JobKillLog
set TotalKillCount += 1
where CharID = @CharID
and Hisname = @Hisname
EXEC [SRO_VT_ACCOUNT].[CGI].[CGI_WebPurchaseSilk] @OrderID = NULL, @UserID = @ID, @PkgID = NULL, @NumSilk = @Silk, @Price = NULL
end
else if exists (select CharID from _JobKillLog Where CharID = @CharID and HisName = @Hisname and EndDate is null) and (@TotalKill = 5) And (@MyCharName not in (select CharName from _PenatlyJOB Where CharName = @MyCharName))
and (@IP1 != @IP2)
begin
update _JobKillLog
set EndDate = DATEADD (DAY,1,GETDATE())
where CharID = @CharID
and HisName = @Hisname
EXEC [SRO_VT_ACCOUNT].[CGI].[CGI_WebPurchaseSilk] @OrderID = NULL, @UserID = @ID, @PkgID = NULL, @NumSilk = @Silk, @Price = NULL
end
if exists (select CharID,HisName,EndDate from _JobKillLog Where CharID = @CharID and HisName = @Hisname and EndDate <= GETDATE())
and (@IP1 != @IP2)
begin
update _JobKillLog
set TotalKillCount = 0,
EndDate = NULL
Where CharID = @CharID
and HisName = @Hisname
EXEC [SRO_VT_ACCOUNT].[CGI].[CGI_WebPurchaseSilk] @OrderID = NULL, @UserID = @ID, @PkgID = NULL, @NumSilk = @Silk, @Price = NULL
end
if (@Penalty = 100)
begin
insert into _PenatlyJOB values (@MyCharName , DATEADD (DAY,1,GETDATE()))
update _JobKillLog
set EndDate = (select PenaltyTime from _PenatlyJOB Where CharName = @MyCharName)
where MyCharName = @MyCharName
EXEC [SRO_VT_ACCOUNT].[CGI].[CGI_WebPurchaseSilk] @OrderID = NULL, @UserID = @ID, @PkgID = NULL, @NumSilk = @Silk, @Price = NULL
end
if exists (select CharName from _PenatlyJOB Where CharName = @MyCharName and PenaltyTime <= GETDATE())
begin
delete from _PenatlyJOB Where CharName = @MyCharName
update _JobKillLog
set TotalKillCount = 0,
EndDate = NULL
Where CharID = @CharID
EXEC [SRO_VT_ACCOUNT].[CGI].[CGI_WebPurchaseSilk] @OrderID = NULL, @UserID = @ID, @PkgID = NULL, @NumSilk = @Silk, @Price = NULL
end
|