PDA

View Full Version : |Jobs/Query| Ranking Diário, Semanal e Mensal [MuEMU]



s00x
29/03/2017, 11:56 AM
Olá galera, conforme o titulo... lá vai.

Colunas a serem inseridas na tabela Character:

Use [MuOnline]

GO

ALTER TABLE [MuOnline].[dbo].[Character] ADD ResetDay INT NOT NULL DEFAULT ((0))
ALTER TABLE [MuOnline].[dbo].[Character] ADD ResetWek INT NOT NULL DEFAULT ((0))
ALTER TABLE [MuOnline].[dbo].[Character] ADD ResetMon INT NOT NULL DEFAULT ((0))


Trigger para contabilizar os Rankings:

USE [MuOnline]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [dbo].[resetrank]
ON [dbo].[Character]

AFTER UPDATE
AS

IF UPDATE(ResetCount)
BEGIN SET NOCOUNT ON;
UPDATE [Character] set [Character].ResetDay=ResetDay+1, ResetWek=ResetWek+1, ResetMon=ResetMon+1
WHERE [Character].accountid=(SELECT accountid FROM Inserted)
AND [Character].name=(SELECT name FROM Inserted)
END

Jobs para resetar os respectivos Rankings.

JobName: ResetDay


BEGIN TRANSACTION
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[uncategorized (Local)]') < 1
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
BEGIN

[Only registered and activated users can see links]
BEGIN

RAISERROR (N'Unable to import job ''ResetDay'' since there is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
[Only registered and activated users can see links]
[Only registered and activated users can see links]
END

BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

END
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
[Only registered and activated users can see links]
EndSave:


JobName: ResetWek


BEGIN TRANSACTION
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[uncategorized (Local)]') < 1
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
BEGIN

[Only registered and activated users can see links]
BEGIN

RAISERROR (N'Unable to import job ''ResetWek'' since there is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
[Only registered and activated users can see links]
[Only registered and activated users can see links]
END

BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

END
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
[Only registered and activated users can see links]
EndSave:


JobName: ResetMon


BEGIN TRANSACTION
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[uncategorized (Local)]') < 1
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
BEGIN

[Only registered and activated users can see links]
BEGIN

RAISERROR (N'Unable to import job ''ResetMon'' since there is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
[Only registered and activated users can see links]
[Only registered and activated users can see links]
END

BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

END
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
[Only registered and activated users can see links]
EndSave:




As tabelas aqui usadas foram baseadas nas citadas no tópico, se for diferente das daqui citadas, não irá funcionar, segui a estrutura dos nomes, de acordo com as do contido no Código Fonte da X-Team vulgo MuEMU.

Obs: Seguindo a estrutura das tabelas serve para qualquer WebSite (meio obvio).

Créditos:
s00x (EU)
Microsoft SQLServer

iTechTeam
29/03/2017, 03:09 PM
Cara me salvo, agora queria saber porque no meu servidor tem as tabelas de horas online e elas não contabilizam sempre fica 0 "zero" ?

s00x
29/03/2017, 05:22 PM
Cara me salvo, agora queria saber porque no meu servidor tem as tabelas de horas online e elas não contabilizam sempre fica 0 "zero" ?

Então meu Jovem, vamos la:

Tabelas a serem criadas:


USE [MUOnline]
GO

ALTER TABLE [dbo].[MEMB_STAT]
ALTER COLUMN [ConnectTM] [datetime] NULL
GO

ALTER TABLE [dbo].[MEMB_STAT]
ALTER COLUMN [DisConnectTM] [datetime] NULL
GO

ALTER TABLE [dbo].[MEMB_INFO]
ADD [TimeON] [bigint] NOT NULL DEFAULT 0
GO

ALTER TABLE [dbo].[Character]
ADD [ConnectTM] [datetime] NULL
GO

ALTER TABLE [dbo].[Character]
ADD [DisConnectTM] [datetime] NULL
GO

ALTER TABLE [dbo].[Character]
ADD [TimeON] [bigint] DEFAULT ((0)) NOT NULL
GO


Cria essa Trigger


/*
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
*/

USE MuOnline
GO

IF EXISTS (SELECT name FROM sysobjects WHERE name = 'AccountCharacter_Online' AND type = 'TR')
DROP TRIGGER [AccountCharacter_Online]
GO

CREATE TRIGGER [AccountCharacter_Online] ON [dbo].[AccountCharacter]
AFTER UPDATE AS
SET NOCOUNT ON

/*
| Hipóteses
|
|
| 1 - Se GameIDC foi atualizado, algum char foi foi logado. Surgem hipóteses:
|
| 1.1 - GameIDC e Old_GameIDC são diferentes:
|
| 1.1.1 - Old_GameIDC é NULL, logo é o primeiro char logado (e possivelmente o primeiro criado) na conta,
| pois não existe GameIDC anterior.
| 1.1.2 - Já existe um GameIDC anterior, logo significa que o cara acessou outro char. Surgem 2 hipóteses:
|
| 1.1.2.1 - O cara simplesmente trocou de char sem deslogar a conta:
| 1.1.2.1.1 - O cara logou um char, deletou ele e entrou em outro.
| 1.1.2.2 - O cara relogou a conta e entrou em outro char.
| 1.1.2.2.1 - O cara logou um char, deletou ele, saiu da conta, voltou e entrou em outro.
|
| 1.2 GameIDC e Old_GameIDC são iguais:
|
| 1.2.1 - O cara relogou o char.
| 1.2.2 - O cara relogou a conta e entrou no mesmo char.
|
| 2. Se GameIDC não foi atualizado, não precisa fazer nada, porque significa:
|
| 2.1 - Que um char foi criado, mas não foi logado.
| 2.2 - Que um char foi deletado sem nem mesmo ter sido logado.
|
|
*/

-- Hipótese 1
IF UPDATE(GameIDC) BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

-- Hipótese 1.1
[Only registered and activated users can see links]

-- Hipótese 1.1.1
[Only registered and activated users can see links]

[Only registered and activated users can see links]

END
-- Hipótese 1.1.2
ELSE BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]

-- Hipótese 1.1.2.1
[Only registered and activated users can see links]

-- Verificação da Hipótese 1.1.2.1.1
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]

END

END
-- Hipótese 1.1.2.2 e "fim" da Hipótese 1.1.2.1
-- A query é a mesma e um "else" é desnecessário.
/*
| Não é necessário atualizar tempo on, porque se o cara relogou a conta
| a WZ_DISCONNECT_MEMB já fez o serviço. Só precisamos atualizar o momento
| de connect do novo char.
*/
[Only registered and activated users can see links]

END

END
--Hipótese 1.2.
ELSE BEGIN
-- Apenas precaução...
[Only registered and activated users can see links]

/*
| Desnecessário checar se o char existe, porque se essa parte
| do script está sendo executada, é porque o char foi logado
| agora, logo é presumível que existe.
*/

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

-- Hipótese 1.2.1
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

END
-- Hipótese 1.2.2
ELSE BEGIN
/*
Não é necessário atualizar tempo on, porque se o cara relogou a conta
a WZ_DISCONNECT_MEMB já fez o serviço.
*/
[Only registered and activated users can see links]

END

END

END
SET NOCOUNT OFF
END


Agora vamos criar a Procedure:


/*
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
*/

USE MuOnline
GO

IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'WZ_DISCONNECT_MEMB')
DROP PROCEDURE [DBO].[WZ_DISCONNECT_MEMB]
GO

[Only registered and activated users can see links]

SET NOCOUNT ON

[Only registered and activated users can see links]
@ConnectStat TINYINT,
@LoginTime INT,
@LogoutTime INT,
@ConnectTM INT,
@DisConnectTM INT,
@TimeON_Account BIGINT,
@TimeON_Char BIGINT,
@GameIDC VARCHAR(10),
@CharConnectTM DATETIME,
@CharConnectTM_Int INT,
@Now DATETIME,
@Now_Int INT;

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]


/*
Selecionamos os momentos de login e logout da conta e convertemos para números inteiros.
*/

[Only registered and activated users can see links]
[Only registered and activated users can see links]


/*
Executamos os cálculos para obtermos o tempo total online da conta.
*/

[Only registered and activated users can see links]

/*
Atualizamos o tempo total online da conta.
*/

[Only registered and activated users can see links]


/*
Selecionando nick do último char logado
*/

[Only registered and activated users can see links]

/*
Algum char foi logado antes de sair da conta.
Mesmo que o cara tenha logado na conta e criado o char, o GameIDC
só vai ser preenchido se o cara logar na conta.
Sendo assim, se GameIDC for NULL, indica que nenhum char
nunca foi logado nessa conta, então não tem necessidade de contar tempo on.
*/
[Only registered and activated users can see links]

/*
Verificamos se esse char existe.
Motivo: o cara pode ter clicado em "selecionar char", deletado o char
e depois deslogado da conta.
Se não existe, não precisa fazer nada.
*/
[Only registered and activated users can see links]

/*
Verificação: quando foi o último connect desse char que acabou de deslogar?
Se for nulo, significa que ocorreu algum problema na trigger, então
adicionamos o valor de "agora" convertido em timestamp para possibilitar o cálculo.
*/

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
END
/*
Se não for nulo, convertemos para timestamp.
*/
ELSE BEGIN
[Only registered and activated users can see links]
END

/*
Executamos os cálculos para obtermos o tempo total online
do último char logado.
*/

[Only registered and activated users can see links]

/*
Atualizamos o tempo total online do último char logado.
*/

[Only registered and activated users can see links]

END
END
END
SET NOCOUNT OFF
END


Caso queira informar isso no seu WebSite:


<?php
$find = mssql_query("SELECT TimeON FROM MEMB_INFO WHERE memb___id='".$login."'");
$fetch = mssql_fetch_object($find);
$seconds = $fetch->TimeON;
$hours = floor($seconds / 3600);
$seconds -= $hours * 3600;
$minutes = floor($seconds / 60);
$seconds -= $minutes * 60;
$timeON = (''.$hours.'h'.$minutes.'min'.$seconds.'sec');
echo $timeON;
?>


Esse código está exibindo as horas online da Conta, caso queira exibir as horas online do Char, recomendo utilizar isso:


$find = mssql_query("SELECT TimeON FROM MEMB_INFO WHERE memb___id='".$name."'");


Esse código/procedimento está perfeito, é até burrice tentar criar algo semelhante com isso já pronto.
Meu jovem, caso tenha feito algum procedimento para contabilizar as horas, recomendo você remover antes de executar esses procedimentos.

Recomendações Mínimas: Microsoft SQL Server 2008 R2

Créditos
Renato Valer

iTechTeam
29/03/2017, 09:21 PM
Apenas agradeço o conhecimento passado agora funcionou obrigado s00x ,sempre passando conhecimento e disposto ajudar ! #ComunidadeEvoluindo

kellviss20
14/07/2017, 10:35 PM
caro amigo, você me ajudou bastante, não só a mim quanto a varias outras pessoas, tenho só mais uma pergunta usando esses comando teria como premiar os 3 ou 5 top dos ranking se sim vc poderia me ajuda? agradeço deis de já muito obrigado.



Olá galera, conforme o titulo... lá vai.


Colunas a serem inseridas na tabela Character:

Use [MuOnline]

GO

ALTER TABLE [MuOnline].[dbo].[Character] ADD ResetDay INT NOT NULL DEFAULT ((0))
ALTER TABLE [MuOnline].[dbo].[Character] ADD ResetWek INT NOT NULL DEFAULT ((0))
ALTER TABLE [MuOnline].[dbo].[Character] ADD ResetMon INT NOT NULL DEFAULT ((0))


Trigger para contabilizar os Rankings:

USE [MuOnline]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [dbo].[resetrank]
ON [dbo].[Character]

AFTER UPDATE
AS

IF UPDATE(ResetCount)
BEGIN SET NOCOUNT ON;
UPDATE [Character] set [Character].ResetDay=ResetDay+1, ResetWek=ResetWek+1, ResetMon=ResetMon+1
WHERE [Character].accountid=(SELECT accountid FROM Inserted)
AND [Character].name=(SELECT name FROM Inserted)
END

Jobs para resetar os respectivos Rankings.

JobName: ResetDay


BEGIN TRANSACTION
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[uncategorized (Local)]') < 1
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
BEGIN

[Only registered and activated users can see links]
BEGIN

RAISERROR (N'Unable to import job ''ResetDay'' since there is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
[Only registered and activated users can see links]
[Only registered and activated users can see links]
END

BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

END
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
[Only registered and activated users can see links]
EndSave:


JobName: ResetWek


BEGIN TRANSACTION
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[uncategorized (Local)]') < 1
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
BEGIN

[Only registered and activated users can see links]
BEGIN

RAISERROR (N'Unable to import job ''ResetWek'' since there is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
[Only registered and activated users can see links]
[Only registered and activated users can see links]
END

BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

END
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
[Only registered and activated users can see links]
EndSave:


JobName: ResetMon


BEGIN TRANSACTION
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[uncategorized (Local)]') < 1
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
BEGIN

[Only registered and activated users can see links]
BEGIN

RAISERROR (N'Unable to import job ''ResetMon'' since there is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
[Only registered and activated users can see links]
[Only registered and activated users can see links]
END

BEGIN

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

[Only registered and activated users can see links]
[Only registered and activated users can see links]

END
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
[Only registered and activated users can see links]
EndSave:




As tabelas aqui usadas foram baseadas nas citadas no tópico, se for diferente das daqui citadas, não irá funcionar, segui a estrutura dos nomes, de acordo com as do contido no Código Fonte da X-Team vulgo MuEMU.

Obs: Seguindo a estrutura das tabelas serve para qualquer WebSite (meio obvio).

Créditos:
s00x (EU)
Microsoft SQLServer

lordlance
07/08/2017, 12:38 PM
galera e se no caso eu querer que contabilize os leveis ?

jhonhy™
13/09/2017, 06:05 PM
Não tem necessidade de fazer job's no servidor da x-team/muemu, só se for outros .. O próprio servidor xteam/muemu já tem suas procedures para tal sistema...

"Mas o que vale é a intenção das pessoas ajudar"

Mas creio que muitos não tem conhecimento com as files..

Mas basta ir nas procedures:
MuOnline ~> Programmability ~> Stored Procedures:

WZ_GetResetInfo
WZ_SetResetInfo

WZ_GetMasterResetInfo
WZ_SetMasterResetInfo

Só editar de acordo com suas tabelas de resets.

Abraços;

[]'s

misterclir
16/10/2017, 04:11 AM
sobre a premiação que um camarada falo ali encima tem como ajudar?

jeickenwes
02/11/2018, 11:36 PM
Poderia fazer ums vídeos ajudaria muito novatos aprender se assunto tão simples igual vcs falam não concordao?

Gengar
16/02/2019, 03:03 PM
o meu ta contando x2 como resolver isso

cleniojr
15/05/2019, 02:18 PM
Boa tarde. Você saberia como utilizar somente o comando para zerar as tabelas? Pois eu uso o SQL express, dessa forma só posso criar jobs com ações em lotes. E dessa forma, eu devo colocar um horário para executar automaticamente a job.

Então, queria saber se você teria somente uma "update" para colocar zero o ResetDay, Wek e Mon. Ou se eu colocar como ai está, sendo em ações em lotes, de quanto em quanto tempo coloca para exectuar? Lembrando que o mínimo tem que ser 1 segundo

s00x
15/05/2019, 03:19 PM
o meu ta contando x2 como resolver isso
Provavelmente você já deve ter algo executando essa ação.


Boa tarde. Você saberia como utilizar somente o comando para zerar as tabelas? Pois eu uso o SQL express, dessa forma só posso criar jobs com ações em lotes. E dessa forma, eu devo colocar um horário para executar automaticamente a job.

Então, queria saber se você teria somente uma "update" para colocar zero o ResetDay, Wek e Mon. Ou se eu colocar como ai está, sendo em ações em lotes, de quanto em quanto tempo coloca para exectuar? Lembrando que o mínimo tem que ser 1 segundo
Acredito que, o que o colega disse aqui vai te ajudar:
[Only registered and activated users can see links]

cleniojr
15/05/2019, 06:11 PM
Obrigado! Vou estar tentando mais tarde e volto para dizer se funcionou

6 Dias 22 Horas:------- Atualizado -------


Não tem necessidade de fazer job's no servidor da x-team/muemu, só se for outros .. O próprio servidor xteam/muemu já tem suas procedures para tal sistema...

"Mas o que vale é a intenção das pessoas ajudar"

Mas creio que muitos não tem conhecimento com as files..

Mas basta ir nas procedures:
MuOnline ~> Programmability ~> Stored Procedures:

WZ_GetResetInfo
WZ_SetResetInfo

WZ_GetMasterResetInfo
WZ_SetMasterResetInfo

Só editar de acordo com suas tabelas de resets.

Abraços;

[]'s
Aqui não pegou, ficou dizendo que eu já tinha atingindo a quantidade de resets máximos, me impedindo de resetar

1 Dia 7 Horas:------- Atualizado -------



Acredito que, o que o colega disse aqui vai te ajudar:
[Only registered and activated users can see links]

consegui a job para fazer resetar, como eu queria. Valeuuuuu

mudamned
07/08/2019, 09:54 PM
cara quando eu coloco para executar ele fica rodando infinitamente não da que deu bom nem que deu erro, então como vou saber que funciona no meu?

_SavagE_
26/02/2020, 08:40 PM
Aqui com update 13 season 4, não contabiliza de jeito nenhum os resets diarios, semanais, e mensais.
Fiz do jieto que está aqui o topico e fiz tambem = o jhonhy disse.

WZ_GetResetInfo
WZ_SetResetInfo

WZ_GetMasterResetInfo
WZ_SetMasterResetInfo

Aqui está tudo normal = ResetDay, ResetWek, ResetMon.

@Edit
----------------------------------------
Agora está contabilizando de 2 em 2^^