| Setokaiba |
09-08-2013 05:12 PM |
Rastreio de Itens Trocados no Servidor L2oFF
4 Anexo(s)
Essa Query cria no seu banco de dados algo que feito manualmente torna-se estressante para muitos administradores, nos casos de roubos de itens... Ao invés de você ficar tentando procurar no txt de Log, pode criar uma tabela e inserir essa Query.
Ela rastreará somente itens individuais (consume_type_normal), pois tentar localizar outro tipo de itens é um pouco difícil (se não quase impossível) devido as mudanças de item_id.
Lembrando que isso resultará num aumento significativo de tamanho no seu banco de dados, porém, se você não tiver problemas quanto a isso, vá em frente.
Precisamos criar uma nova tabela, nesta tabela serão armazenadas as informações dos itens e haverá outro campo, que serão as informações da data exata em que ocorreu a troca.
Primeiro passo, crie a tabela:
Código:
USE [lin2world]
GO
/****** Object: Table [dbo].[user_item_log] Script Date: 08/06/2008 20:52:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[user_item_log](
[item_id] [int] NOT NULL,
[char_id] [int] NOT NULL,
[item_type] [int] NOT NULL,
[amount] [int] NOT NULL,
[enchant] [int] NOT NULL,
[eroded] [int] NOT NULL,
[bless] [tinyint] NOT NULL,
[ident] [int] NOT NULL,
[wished] [tinyint] NOT NULL,
[warehouse] [int] NOT NULL,
[date] [datetime] NOT NULL CONSTRAINT [DF_Table_1_create_date] DEFAULT (getdate())
) ON [PRIMARY]
-----------------------------------------------------------------------------------------------
Second step: Modifying lin_UpdateUserItem Store Procedure.
Senha Para Descompactar este e os demais arquivos SQL:
Senha: www.secretexperience.net
Query 1:
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
Após, rode as próximas Querys 2 e 3.
E caso veja necessidade, a 4 também.
Código:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
/****** Object: Stored Procedure dbo.lin_UpdateUserItem Script Date: 2003-09-20 ?? 11:51:57 ******/
/********************************************
lin_UpdateUserItem
INPUT
@char_id INT,
@item_type INT,
@amount INT,
@enchant INT,
@eroded INT,
@bless INT,
@ident INT,
@wished INT,
@warehouse INT,
@item_id INT
OUTPUT
return
made by
carrot
date
2002-06-09
********************************************/
ALTER PROCEDURE [dbo].[lin_UpdateUserItem]
(
@char_id INT,
@item_type INT,
@amount INT,
@enchant INT,
@eroded INT,
@bless INT,
@ident INT,
@wished INT,
@warehouse INT,
@item_id INT
)
AS
SET NOCOUNT ON
-- START FidoW addon item tracker
DECLARE @isOK INT
SELECT @isOK = id FROM itemdata WHERE isQuest = 0 AND consumetype = 'consume_type_normal' AND id = @item_type
IF (@isOK IS NOT NULL)
BEGIN
DECLARE @old_char_id int
SELECT @old_char_id = char_id FROM user_item WHERE item_id = @item_id
IF (@old_char_id <> @char_id)
BEGIN
INSERT INTO user_item_log (item_id,char_id,item_type,amount,enchant,eroded,bless,ident,wished,warehouse,date)
VALUES (@item_id,@char_id,@item_type,@amount,@enchant,@eroded,@bless,@ident,@wished,@warehouse,GETDATE())
END
END
-- END FidoW addon item tracker
UPDATE user_item set char_id=@char_id, item_type=@item_type, amount=@amount, enchant=@enchant, eroded=@eroded, bless=@bless, ident=@ident, wished=@wished, warehouse=@warehouse WHERE item_id=@item_id
---------------------------------------------------------------------------------------------------
Step three: Update lin_CreateItem Store Proceduce.
Query 2:
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
Código:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
/****** Object: Stored Procedure dbo.lin_CreateItem Script Date: 2003-09-20 ?? 11:51:57 ******/
/********************************************
lin_CreateItem
create item sp
INPUT
@char_id INT,
@item_type INT,
@amount INT,
@enchant INT,
@eroded INT,
@bless TINYINT,
@ident TINYINT,
@ready TINYINT,
@wished TINYINT,
@warehouse INT
OUTPUT
Item_ID, @@IDENTITY
return
made by
carrot
date
2002-01-31
********************************************/
ALTER PROCEDURE [dbo].[lin_CreateItem]
(
@char_id INT,
@item_type INT,
@amount INT,
@enchant INT,
@eroded INT,
@bless TINYINT,
@ident TINYINT,
@wished TINYINT,
@warehouse INT
)
AS
SET NOCOUNT ON
insert into user_item
(char_id , item_type , amount , enchant , eroded , bless , ident , wished , warehouse)
values
(@char_id, @item_type , @amount , @enchant , @eroded , @bless , @ident , @wished , @warehouse)
SELECT @@IDENTITY
-- START FidoW addon item tracker
DECLARE @isOK INT
SELECT @isOK = id FROM itemdata WHERE isQuest = 0 AND consumetype = 'consume_type_normal' AND id = @item_type
IF (@isOK IS NOT NULL)
BEGIN
DECLARE @item_id INT
SELECT TOP 1 @item_id = item_id FROM user_item
WHERE char_id = @char_id AND item_type = @item_type AND amount = @amount AND enchant = @enchant AND eroded = @eroded AND bless = @bless AND ident = @ident AND wished = @wished AND warehouse = @warehouse
ORDER BY item_id DESC
INSERT INTO user_item_log (item_id,char_id,item_type,amount,enchant,eroded,bless,ident,wished,warehouse,date)
VALUES (@item_id,@char_id,@item_type,@amount,@enchant,@eroded,@bless,@ident,@wished,@warehouse,GETDATE())
END
-- END FidoW addon item tracker
--------------------------------------------------------------------------------------------------
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
/****** Object: Stored Procedure dbo.lin_CreateItem Script Date: 2003-09-20 ?? 11:51:57 ******/
/********************************************
lin_CreateItem
create item sp
INPUT
@char_id INT,
@item_type INT,
@amount INT,
@enchant INT,
@eroded INT,
@bless TINYINT,
@ident TINYINT,
@ready TINYINT,
@wished TINYINT,
@warehouse INT
OUTPUT
Item_ID, @@IDENTITY
return
made by
carrot
date
2002-01-31
********************************************/
ALTER PROCEDURE [dbo].[lin_CreateItem]
(
@char_id INT,
@item_type INT,
@amount INT,
@enchant INT,
@eroded INT,
@bless TINYINT,
@ident TINYINT,
@wished TINYINT,
@warehouse INT
)
AS
SET NOCOUNT ON
insert into user_item
(char_id , item_type , amount , enchant , eroded , bless , ident , wished , warehouse)
values
(@char_id, @item_type , @amount , @enchant , @eroded , @bless , @ident , @wished , @warehouse)
SELECT @@IDENTITY
-- START FidoW addon item tracker
DECLARE @isOK INT
SELECT @isOK = id FROM itemdata WHERE isQuest = 0 AND consumetype = 'consume_type_normal' AND id = @item_type
IF (@isOK IS NOT NULL)
BEGIN
DECLARE @item_id INT
SELECT TOP 1 @item_id = item_id FROM user_item
WHERE char_id = @char_id AND item_type = @item_type AND amount = @amount AND enchant = @enchant AND eroded = @eroded AND bless = @bless AND ident = @ident AND wished = @wished AND warehouse = @warehouse
ORDER BY item_id DESC
INSERT INTO user_item_log (item_id,char_id,item_type,amount,enchant,eroded,bless,ident,wished,warehouse,date)
VALUES (@item_id,@char_id,@item_type,@amount,@enchant,@eroded,@bless,@ident,@wished,@warehouse,GETDATE())
END
-- END FidoW addon item tracker
--------------------------------------------------------------------------------------------------
Query 3:
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
Isso não funcionará se você tiver esvaziado a tabela ItemData ou não tiver atualizado (dado update) no CacheD e no CachedScript do servidor.
Como usar? Basta executar ambas as querys em MsSQL, feito isso e ele começará a registrar as informações supracitadas.
A idealização dessa Query é para o caso de controle de itens roubados de uma determinada conta, sem necessitar ficar espionando igual a um detetive no Log que é imenso e não nos trás o resultado esperado.
Espero que achem isso útil.
Caso queira iniciar uma tabela user_item_log já com dados armazenados, pode executar a seguinte Query:
Código:
INSERT INTO user_item_log
SELECT item_id,char_id,item_type,amount,enchant,eroded,bless,ident,wished,warehouse,'2001-01-01 00:00:00'
FROM user_item
WHERE item_id NOT IN (SELECT DISTINCT item_id FROM user_item_log)
AND item_type IN (SELECT id FROM itemdata WHERE isQuest = 0 AND consumetype = 'consume_type_normal')
Query 4:
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
Claramente não teremos a data exata neste caso, porém, teremos armazenado quem é o atual proprietário até a próxima mudança.
Códigos by: FidoW
Descrição da Função, Criação dos SQL Query e Upload by: Setokaiba.
|