USE [PS_GameLog]

GO

/****** Object: StoredProcedure [dbo].[usp_Insert_Action_Log_E] Script Date: 08/09/2014 18:17:08 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER Proc [dbo].[usp_Insert_Action_Log_E]

@UserID varchar(18),

@UserUID int,

@CharID int,

@CharName varchar(50),

@CharLevel tinyint,

@CharExp int,

@MapID smallint,

@PosX real,

@PosY real,

@PosZ real,

@ActionTime datetime,

@ActionType tinyint,

@Value1 bigint = null,

@Value2 int = null,

@Value3 int = null,

@Value4 bigint = null,

@Value5 int = null,

@Value6 int = null,

@Value7 int = null,

@Value8 int = null,

@Value9 int = null,

@Value10 int = null,

@Text1 varchar(100) = '',

@Text2 varchar(100) = '',

@Text3 varchar(100) = '',

@Text4 varchar(100) = '',

@Sql nvarchar(4000) = '',

@yyyy varchar(4) = '',

@mm varchar(2) = '',

@dd varchar(2) = '',

@Bucket smallint = -1

AS

IF @ActionType = 112

BEGIN

IF @Text2 = 'use_item'

BEGIN

IF @Value2 / 1000 = 100 AND @Value2 % 100 BETWEEN 1 AND 10

BEGIN

INSERT SetToCostumeRuneLog VALUES (@CharID, @Value2 % 100 - 0, GETDATE(), 0)

END

END

END

--IF @ActionType = 108

--BEGIN

-- IF EXISTS (SELECT RowID FROM SetToCostumeRuneLog WHERE CharID = @CharID AND Applied = 0)

-- BEGIN

-- DECLARE @CostumeID TINYINT = (SELECT TOP 1 CostumeID FROM SetToCostumeRuneLog WHERE CharID = @CharID AND Applied = 0)

-- UPDATE ci

-- SET ci.ItemID = stc.CostumeItemID, ci.Type = stc.CostumeItemID / 1000, ci.TypeID = stc.CostumeItemID % 1000

-- FROM PS_GameData.dbo.CharItems ci

-- INNER JOIN PS_GameDefs.dbo.SetToCostume stc

-- ON ci.ItemID = stc.SetItemID

-- WHERE ci.CharID = @CharID AND ((ci.Bag = 0 AND ci.Slot BETWEEN 0 AND 4) OR (ci.Bag = 1 AND ci.Slot IN (0,1,2) AND ci.Type IN (17,32)))

-- AND stc.CostumeID = @CostumeID

-- INSERT SetToCostumeLog

-- SELECT @CharID, ItemUID, GETDATE() FROM PS_GameData.dbo.CharItems

-- WHERE CharID = @CharID AND ((Bag = 0 AND Slot BETWEEN 0 AND 4) OR (Bag = 1 AND Slot IN (0,1,2) AND Type IN (17,32)))

-- UPDATE SetToCostumeRuneLog

-- SET Applied = 1

-- WHERE CharID = @CharID

-- END

-- IF EXISTS (SELECT RowID FROM SetToCostumeLog WHERE CharID = @CharID AND DATEDIFF(DAY, TransformDate, GETDATE()) >= 30)

-- BEGIN

-- UPDATE ci

-- SET ci.ItemID = stc.SetItemID, ci.Type = stc.SetItemID / 1000, ci.TypeID = stc.SetItemID % 1000

-- FROM PS_GameData.dbo.CharItems ci

-- INNER JOIN PS_GameDefs.dbo.SetToCostume stc

-- ON ci.ItemID = stc.CostumeItemID

-- WHERE ci.CharID = @CharID AND ci.ItemUID IN (SELECT ItemUID FROM SetToCostumeLog WHERE CharID = @CharID AND DATEDIFF(DAY, TransformDate, GETDATE()) >= 30)

-- DELETE SetToCostumeLog WHERE CharID = @CharID AND DATEDIFF(DAY, TransformDate, GETDATE()) >= 30

-- END

--END

DECLARE @CharLeave int

SET @yyyy = datepart(yyyy, @ActionTime)

SET @mm = datepart(mm, @ActionTime)

SET @dd = datepart(dd, @ActionTime)

SET @CharLeave = 1

IF @ActionType = '116'--Trade Item-remove item from originator

BEGIN

WAITFOR DELAY '00:00:05'--Time delay to give the duper time to log out fully

SELECT @CharLeave=Leave

FROM PS_userdata.dbo.Users_Master

WHERE

[email protected]
IF @CharLeave=0

BEGIN

EXEC PS_GameData.dbo.usp_Save_Char_Item_Del_E @

[email protected], @

[email protected]
END

END

IF @ActionType = '164'--Trade Gold-remove gold from originator

BEGIN

WAITFOR DELAY '00:00:05'--Time delay to give the duper time to log out fully

SELECT @CharLeave=Leave

FROM PS_userdata.dbo.Users_Master

WHERE

[email protected]
IF @CharLeave=0

BEGIN

UPDATE PS_GameData.dbo.Chars

SET [Money]

[email protected]
WHERE

[email protected]
END

END

IF (@ActionType = 116)

BEGIN

IF (@Value2 IN (SELECT ItemID FROM PS_GameDefs.dbo.Items WHERE ReqOg = 1))

BEGIN

INSERT INTO Illegal_Transaction_Log VALUES (@UserUID, @UserID, @CharID, @CharName, @Value3, @Text2, @Value1, @Value2, @Text1, @ActionTime)

UPDATE PS_UserData.dbo.Users_Master

SET Status = -5

WHERE UserUID = @UserUID

END

END

SET @Sql = N'

INSERT INTO PS_GameLog.dbo.ActionLog

(UserID, UserUID, CharID, CharName, CharLevel, CharExp, MapID, PosX, PosY, PosZ, ActionTime, ActionType,

Value1, Value2, Value3, Value4, Value5, Value6, Value7, Value8, Value9, Value10, Text1, Text2, Text3, Text4)

VALUES(@UserID, @UserUID, @CharID, @CharName, @CharLevel, @CharExp, @MapID, @PosX, @PosY, @PosZ, @ActionTime, @ActionType,

@Value1, @Value2, @Value3, @Value4, @Value5, @Value6, @Value7, @Value8, @Value9, @Value10, @Text1, @Text2, @Text3, @Text4)'

EXEC sp_executesql @Sql,

N'@UserID varchar(18), @UserUID int, @CharID int, @CharName varchar(50),

@CharLevel tinyint, @CharExp int, @MapID smallint, @PosX real, @PosY real, @PosZ real, @ActionTime datetime, @ActionType tinyint,

@Value1 bigint, @Value2 int, @Value3 int, @Value4 bigint, @Value5 int, @Value6 int, @Value7 int, @Value8 int,

@Value9 int, @Value10 int, @Text1 varchar(100), @Text2 varchar(100), @Text3 varchar(100), @Text4 varchar(100)',

@UserID, @UserUID, @CharID, @CharName, @CharLevel, @CharExp, @MapID, @PosX, @PosY, @PosZ, @ActionTime, @ActionType,

@Value1, @Value2, @Value3, @Value4, @Value5, @Value6, @Value7, @Value8, @Value9, @Value10, @Text1, @Text2, @Text3, @Text4