_AddLogChar
_AddLogItemCode:/** author : syloxx created date : 2015-03-11 description : Log players activities. return value : 0 = There is no error. 1 = The transaction is in an uncommittable state. Rolling back transaction. **/ CREATE PROCEDURE dbo._AddLogChar @CharID int , @eventID tinyint , @DaTa1 int , @DaTa2 int , @strPos varchar(64) , @desc varchar(128) AS SET NOCOUNT ON; SET XACT_ABORT ON; DECLARE @returnValue int; /**_# Rollback and return if inside an uncommittable transaction.*/ IF XACT_STATE() = -1 BEGIN SET @returnValue = 1; GOTO ErrorHandler; END BEGIN TRY /**_# Log players activities.*/ INSERT dbo._LogEventChar (CharID, EventTime, EventID, Data1, Data2, EventPos, strDesc) VALUES @CharID, GETDATE(), @eventID, @DaTa1, @DaTa2, CASE WHEN @strPos = '' THEN NULL ELSE @strPos END, CASE WHEN @desc = '' THEN NULL ELSE @desc END); END TRY BEGIN CATCH GOTO ErrorHandler; END CATCH; RETURN 0; ErrorHandler: IF XACT_STATE() <> 0 ROLLBACK TRANSACTION; RETURN @returnValue
Code:/** author : syloxx created date : 2015-03-11 description : Log players item interactions. return value : 0 = There is no error. 1 = The transaction is in an uncommittable state. Rolling back transaction. **/ CREATE PROCEDURE dbo._AddLogItem @CharID int , @ItemRefID int , @ItemSerial bigint , @dwData int , @TargetStorage tinyint , @operation tinyint , @slot_From tinyint , @slot_To tinyint , @eventPos varchar(64) , @strDesc varchar(128) , @Gold bigint AS SET NOCOUNT ON; SET XACT_ABORT ON; DECLARE @returnValue int; /**_# Rollback and return if inside an uncommittable transaction.*/ IF XACT_STATE() = -1 BEGIN SET @returnValue = 1; GOTO ErrorHandler; END BEGIN TRY /**_# Log players item interactions.*/ INSERT dbo._LogEventItem (EventTime, CharID, ItemRefID, dwData, TargetStorage, Operation, Slot_From, Slot_To, EventPos, strDesc, Serial64, Gold) VALUES (GETDATE(), @CharID, @ItemRefID, @dwData, @TargetStorage, @operation, @slot_From, @slot_To, CASE WHEN @eventPos = '' THEN NULL ELSE @eventPos END, CASE WHEN @strDesc = '' THEN NULL ELSE @strDesc END, @ItemSerial, @Gold) /**_# Log purchased cash items.*/ IF @operation = 35 INSERT dbo._LogCashItem (RefItemID, CharID, Cnt, EventTime, Serial64) VALUES (@ItemRefID, @CharID, @dwData, GETDATE(), @ItemSerial) END TRY BEGIN CATCH GOTO ErrorHandler; END CATCH; RETURN 0; ErrorHandler: IF XACT_STATE() <> 0 ROLLBACK TRANSACTION; RETURN @returnValue



Reply With Quote![[RELEASE] VSRO v1.188 improved Log queries](http://ragezone.com/hyper728.png)




