USE [MuOnline]
GO
DROP PROCEDURE [dbo].[VERIFICAR_ITENS]
GO
DROP PROCEDURE [dbo].[chat_atualizar]
GO
DROP PROCEDURE [dbo].[WZ_GetMasterResetInfo]
GO
DROP PROCEDURE [dbo].[WZ_GetResetInfo]
GO
DROP PROCEDURE [dbo].[WZ_SetMasterResetInfo]
GO
DROP PROCEDURE [dbo].[WZ_SetResetInfo]
GO
DROP TABLE [dbo].[MK_Quest]
GO
DROP TABLE [dbo].[MK_MEDALHAS]
GO
DROP TABLE [dbo].[MK_Chat_online]
GO
DROP PROCEDURE [dbo].[EVENTO_ITENS]
GO
DROP PROCEDURE [dbo].[WZ_CS_ModifyTaxRate]
GO
DROP PROCEDURE [dbo].[WZ_GetAccountLevel]
GO
DROP TABLE [dbo].[MK_Chat_staff]
GO
DROP TABLE [dbo].[MK_DV]
GO
DROP TABLE [dbo].[MK_Reputacao]
GO
DROP TABLE [dbo].[MK_Server]
GO
DROP TABLE [dbo].[TOP_Diario]
GO
DROP TABLE [dbo].[TOP_Mensal]
GO
DROP TABLE [dbo].[TOP_Semanal]
GO
DROP TABLE [dbo].[MK_Mensagens]
GO
DROP TABLE [dbo].[MK_Mudar_Mail]
GO
DROP TABLE [dbo].[MK_Murkut_News]
GO
DROP TABLE [dbo].[MK_Online_today]
GO
DROP TABLE [dbo].[MK_Pagamentos]
GO
DROP TABLE [dbo].[LOG_ACESSO_N]
GO
DROP TABLE [dbo].[LOG_ADM]
GO
DROP TABLE [dbo].[LOG_AGRADECIMENTOS]
GO
DROP TABLE [dbo].[LOG_BAN]
GO
DROP TABLE [dbo].[LOG_BAU]
GO
DROP TABLE [dbo].[LOG_CADASTROS]
GO
DROP TABLE [dbo].[LOG_COMPRA_CREDITOS]
GO
DROP TABLE [dbo].[LOG_CREDITOS]
GO
DROP TABLE [dbo].[LOG_CUSTOM_ARENA]
GO
DROP TABLE [dbo].[LOG_DENUNCIAS]
GO
DROP TABLE [dbo].[LOG_DESBAN]
GO
DROP TABLE [dbo].[LOG_DUELO]
GO
DROP TABLE [dbo].[LOG_DUPE_EVENTO]
GO
DROP TABLE [dbo].[LOG_DV]
GO
DROP TABLE [dbo].[LOG_EVENTOS]
GO
DROP TABLE [dbo].[LOG_EVENTOS_ITENS]
GO
DROP TABLE [dbo].[LOG_GOLDS]
GO
DROP TABLE [dbo].[LOG_GUILDMEMBER]
GO
DROP TABLE [dbo].[LOG_MAIL]
GO
DROP TABLE [dbo].[LOG_NOME]
GO
DROP TABLE [dbo].[LOG_OBS]
GO
DROP TABLE [dbo].[LOG_ORDEM]
GO
DROP TABLE [dbo].[LOG_PAINEL]
GO
DROP TABLE [dbo].[LOG_RANK]
GO
DROP TABLE [dbo].[LOG_REI_MK]
GO
DROP TABLE [dbo].[LOG_SENHA_M]
GO
DROP TABLE [dbo].[LOG_SENHA_R]
GO
DROP TABLE [dbo].[LOG_STONES]
GO
DROP TABLE [dbo].[LOG_TRANSFERENCIA]
GO
DROP TABLE [dbo].[LOG_TRANSFERENCIA_CREDITOS]
GO
DROP TABLE [dbo].[LOG_USERONLINE]
GO
DROP TABLE [dbo].[LOG_VENDA_CONTA]
GO
DROP TABLE [dbo].[LOG_VIP]
GO
DROP TABLE [dbo].[LOG_VOTOS]
GO
DROP TABLE [dbo].[LOG_VOTOS2]
GO
DROP TABLE [dbo].[LOG_WAR]
GO
DROP TABLE [dbo].[LOG_XP_WAR]
GO
DROP TABLE [dbo].[MK_Character_GM]
GO
DROP TABLE [dbo].[MK_Chat]
GO
DROP TABLE [dbo].[MK_Chat_amigos]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Chat_amigos](
	[id_chat] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[login_amigo] [nvarchar](10) NOT NULL,
	[qtd_msgs] [int] NOT NULL CONSTRAINT [DF_Chat_amigos_qtd_msgs]  DEFAULT ((0)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_Chat_amigos_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_Chat_amigos] PRIMARY KEY CLUSTERED 
(
	[id_chat] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Chat](
	[id_chat] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[name] [nvarchar](10) NOT NULL,
	[msg] [nvarchar](140) NOT NULL,
	[data] [datetime] NOT NULL CONSTRAINT [DF_Chat_data]  DEFAULT (getdate()),
	[img] [nvarchar](15) NULL,
 CONSTRAINT [PK_Chat] PRIMARY KEY CLUSTERED 
(
	[id_chat] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Character_GM](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[acc_gm] [nvarchar](10) NOT NULL,
	[acc_player] [nvarchar](10) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_Character_GM_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_XP_WAR](
	[id_xp] [int] IDENTITY(1,1) NOT NULL,
	[guild] [nvarchar](10) NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_XP_WAR_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_WAR](
	[id_war] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[win] [nvarchar](10) NOT NULL,
	[lose] [nvarchar](10) NOT NULL,
	[ip] [char](15) NULL,
	[data] [smalldatetime] NULL CONSTRAINT [DF_LOG_WAR_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_WAR] PRIMARY KEY CLUSTERED 
(
	[id_war] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_VOTOS2](
	[id_voto] [int] IDENTITY(1,1) NOT NULL,
	[login_fez] [nvarchar](10) NOT NULL,
	[login_recebeu] [nvarchar](10) NOT NULL,
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_VOTOS2_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_VOTOS](
	[id_voto] [int] IDENTITY(1,1) NOT NULL,
	[login_fez] [nvarchar](10) NOT NULL,
	[login_recebeu] [nvarchar](10) NOT NULL,
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_VOTOS_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_VOTOS] PRIMARY KEY CLUSTERED 
(
	[id_voto] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_VIP](
	[id_vip] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[dias] [int] NOT NULL,
	[tipo] [smallint] NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_VIP_data]  DEFAULT (getdate()),
	[login_lan] [nvarchar](10) NULL,
 CONSTRAINT [PK_LOG_VIP] PRIMARY KEY CLUSTERED 
(
	[id_vip] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_VENDA_CONTA](
	[id_venda] [int] IDENTITY(1,1) NOT NULL,
	[conta] [nvarchar](10) NULL,
	[conta_comprou] [nvarchar](10) NULL,
	[conta_creditos] [nvarchar](10) NULL,
	[valor] [int] NULL,
	[mail_antigo] [nvarchar](50) NULL,
	[mail_novo] [nvarchar](50) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_VENDA_CONTA_data]  DEFAULT (getdate()),
	[ip] [char](15) NULL,
 CONSTRAINT [PK_LOG_VENDA_CONTA] PRIMARY KEY CLUSTERED 
(
	[id_venda] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_USERONLINE](
	[timestamp] [int] NOT NULL CONSTRAINT [DF_LOG_USERONLINE_timestamp]  DEFAULT ((0)),
	[ip] [nvarchar](15) NOT NULL,
	[file] [nvarchar](50) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_TRANSFERENCIA_CREDITOS](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[login_destino] [nvarchar](10) NOT NULL,
	[valor] [int] NOT NULL CONSTRAINT [DF_LOG_TRANSFERENCIA_CREDITOS_valor]  DEFAULT ((0)),
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_TRANSFERENCIA_CREDITOS_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_TRANSFERENCIA_CREDITOS] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_TRANSFERENCIA](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[char] [nvarchar](10) NULL,
	[gameid] [nvarchar](10) NULL,
	[login_destino] [nvarchar](10) NOT NULL,
	[gameid_dest] [nvarchar](10) NULL,
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_TRANSFERENCIA_data]  DEFAULT (getdate()),
	[adm] [tinyint] NOT NULL CONSTRAINT [DF_LOG_TRANSFERENCIA_adm]  DEFAULT ((0)),
 CONSTRAINT [PK_LOG_TRANSFERENCIA] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_STONES](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[serial] [binary](4) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_STONES_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_STONES] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_SENHA_R](
	[id_senha] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[mail] [nvarchar](50) NULL,
	[ip] [char](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_SENHA_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_SENHA] PRIMARY KEY CLUSTERED 
(
	[id_senha] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_SENHA_M](
	[id_mudar] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[antiga] [nvarchar](10) NULL,
	[ip] [char](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_SENHA_M_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_SENHA_M] PRIMARY KEY CLUSTERED 
(
	[id_mudar] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_REI_MK](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[name] [nvarchar](10) NOT NULL,
	[guild] [nvarchar](10) NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_REI_MK_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_Log_rei_mk] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_RANK](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](10) NOT NULL,
	[tipo] [smallint] NOT NULL,
	[posicao] [int] NOT NULL,
 CONSTRAINT [PK_LOG_RANK] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_PAINEL](
	[id_painel] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[ip] [char](15) NULL,
	[host] [nvarchar](50) NULL,
	[data] [smalldatetime] NULL CONSTRAINT [DF_LOG_PAINEL_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_PAINEL] PRIMARY KEY CLUSTERED 
(
	[id_painel] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_ORDEM](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[posicao1] [nvarchar](10) NULL,
	[posicao2] [nvarchar](10) NULL,
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_ORDEM_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_ORDEM] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_OBS](
	[id_obs] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[obs] [nvarchar](150) NOT NULL,
	[mostrar] [tinyint] NOT NULL CONSTRAINT [DF_LOG_OBG_mostrar]  DEFAULT ((0)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_OBG_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_OBG] PRIMARY KEY CLUSTERED 
(
	[id_obs] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_NOME](
	[login] [nvarchar](10) NOT NULL,
	[novo] [nvarchar](10) NOT NULL,
	[antigo] [nvarchar](10) NOT NULL,
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NULL CONSTRAINT [DF_LOG_NOME_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_MAIL](
	[id_mail] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[antigo] [nvarchar](50) NULL,
	[novo] [nvarchar](50) NULL,
	[ip] [char](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_MAIL_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_MAIL] PRIMARY KEY CLUSTERED 
(
	[id_mail] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_GUILDMEMBER](
	[id_historico] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](10) NOT NULL,
	[id_guild] [int] NOT NULL CONSTRAINT [DF_LOG_GUILD_MEMBER_id_guild]  DEFAULT ((0)),
	[vitorias] [int] NOT NULL CONSTRAINT [DF_LOG_GUILD_vitorias]  DEFAULT ((0)),
	[derrotas] [int] NOT NULL CONSTRAINT [DF_LOG_GUILD_derrotas]  DEFAULT ((0)),
	[valor_compra] [int] NOT NULL CONSTRAINT [DF_LOG_GUILD_valor_compra]  DEFAULT ((0)),
	[data_compra] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_GUILDMEMBER_data_compra]  DEFAULT (getdate()),
	[saiu] [smallint] NOT NULL CONSTRAINT [DF_LOG_GUILDMEMBER_saiu]  DEFAULT ((0))
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_GOLDS](
	[login] [nvarchar](10) NOT NULL,
	[name] [nvarchar](10) NOT NULL,
	[name_destino] [nvarchar](10) NOT NULL,
	[valor] [int] NOT NULL CONSTRAINT [DF_LOG_GOLDS_valor]  DEFAULT ((0)),
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_GOLDS_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_EVENTOS_ITENS](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[tipo] [smallint] NOT NULL,
	[qtd] [int] NOT NULL CONSTRAINT [DF_LOG_EVENTOS_ITENS_qtd]  DEFAULT ((0)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_EVENTOS_ITENS_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_EVENTOS_ITENS] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_EVENTOS](
	[id_gold] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[login_char] [nvarchar](10) NOT NULL,
	[personagem] [nvarchar](10) NOT NULL,
	[tipo] [int] NOT NULL,
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_EVENTOS_data]  DEFAULT (getdate()),
	[valor] [int] NOT NULL CONSTRAINT [DF_LOG_EVENTOS_valor]  DEFAULT ((0)),
 CONSTRAINT [PK_LOG_EVENTOS] PRIMARY KEY CLUSTERED 
(
	[id_gold] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_DV](
	[id_dv] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[login_dv] [nvarchar](10) NOT NULL,
	[mail] [nvarchar](50) NOT NULL,
	[ativo] [smallint] NOT NULL CONSTRAINT [DF_LOG_DV_ativo]  DEFAULT ((0)),
	[invalido] [smallint] NOT NULL CONSTRAINT [DF_LOG_DV_invalido]  DEFAULT ((0)),
	[ip] [char](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_DV_data]  DEFAULT (getdate()),
	[criou] [smallint] NOT NULL CONSTRAINT [DF_LOG_DV_criou]  DEFAULT ((0)),
	[resetou] [smallint] NOT NULL CONSTRAINT [DF_LOG_DV_resetou]  DEFAULT ((0)),
	[depositou] [smallint] NOT NULL CONSTRAINT [DF_LOG_DV_depositou]  DEFAULT ((0)),
 CONSTRAINT [PK_LOG_DV] PRIMARY KEY CLUSTERED 
(
	[id_dv] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_DUPE_EVENTO](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[serial] [binary](4) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_DUPE_EVENTO_data]  DEFAULT (getdate()),
	[evento] [nchar](20) NULL,
 CONSTRAINT [PK_LOG_DUPE_EVENTO] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_DUELO](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[vencedor] [nvarchar](10) NULL,
	[perdedor] [nvarchar](10) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_DUELO_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_DUELO] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_DESBAN](
	[id_desban] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[desbanido] [nvarchar](10) NOT NULL,
	[ip] [nvarchar](15) NULL,
	[data] [smalldatetime] NULL CONSTRAINT [DF_LOG_DESBAN_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_DENUNCIAS](
	[id_acc] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[mostrar] [smallint] NOT NULL CONSTRAINT [DF_LOG_DENUNCIAS_mostrar]  DEFAULT ((0)),
	[qtd] [int] NOT NULL CONSTRAINT [DF_LOG_DENUNCIAS_qtd]  DEFAULT ((0)),
 CONSTRAINT [PK_LOG_DENUNCIAS] PRIMARY KEY CLUSTERED 
(
	[id_acc] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_CUSTOM_ARENA](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](10) NOT NULL,
	[Valor] [int] NOT NULL CONSTRAINT [DF_LOG_CUSTOM_ARENA_Valor]  DEFAULT ((0)),
	[arena] [smallint] NOT NULL CONSTRAINT [DF_LOG_CUSTOM_ARENA_arena]  DEFAULT ((0)),
	[rank] [smallint] NOT NULL CONSTRAINT [DF_LOG_CUSTOM_ARENA_rank]  DEFAULT ((1)),
	[Data] [smalldatetime] NOT NULL CONSTRAINT [DF_Table_1_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_CREDITOS](
	[id_creditos] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[valor] [int] NOT NULL CONSTRAINT [DF_LOG_CREDITOS_valor]  DEFAULT ((0)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_CREDITOS_data]  DEFAULT (getdate()),
	[ip] [char](15) NULL,
	[tipo] [smallint] NOT NULL CONSTRAINT [DF_LOG_CREDITOS_tipo]  DEFAULT ((0)),
 CONSTRAINT [PK_LOG_CREDITOS] PRIMARY KEY CLUSTERED 
(
	[id_creditos] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_COMPRA_CREDITOS](
	[id_c] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[nome] [nvarchar](10) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_COMPRA_CREDITOS_data]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_CADASTROS](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[ip] [char](15) NULL,
	[host] [nvarchar](50) NULL,
	[navegador] [nvarchar](110) NULL,
	[cookie1] [nvarchar](20) NULL,
	[cookie2] [nvarchar](20) NULL,
	[data] [smalldatetime] NULL CONSTRAINT [DF_LOG_CADASTROS_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_CADASTROS] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_BAU](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_BAU_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_BAU] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_BAN](
	[id_ban] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[name] [nvarchar](10) NULL,
	[reason] [nvarchar](200) NULL,
	[gm] [nvarchar](10) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_BAN_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_BAN] PRIMARY KEY CLUSTERED 
(
	[id_ban] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LOG_AGRADECIMENTOS](
	[id_agr] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[login_r] [nvarchar](10) NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_LOG_AGRADECIMENTOS_data]  DEFAULT (getdate()),
	[ip] [nvarchar](15) NULL,
 CONSTRAINT [PK_LOG_AGRADECIMENTOS] PRIMARY KEY CLUSTERED 
(
	[id_agr] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_ADM](
	[id_adm] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[ip] [char](15) NULL,
	[valor] [nvarchar](50) NULL,
	[valor2] [nvarchar](50) NULL,
	[tipo] [smallint] NULL,
	[data] [smalldatetime] NULL CONSTRAINT [DF_LOG_ADM_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_ADM] PRIMARY KEY CLUSTERED 
(
	[id_adm] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MK_Despesas](
	[id_desp] [int] IDENTITY(1,1) NOT NULL,
	[despesa] [nvarchar](30) NOT NULL,
	[valor_despesa] [int] NOT NULL,
	[data_pg] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_Despesas] PRIMARY KEY CLUSTERED 
(
	[id_desp] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[MK_Despesas] ADD  DEFAULT ((0)) FOR [valor_despesa]
GO

ALTER TABLE [dbo].[MK_Despesas] ADD  DEFAULT (getdate()) FOR [data_pg]
GO

CREATE TABLE [dbo].[LOG_ACESSO_N](
	[id_acesso] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NULL,
	[senha] [nvarchar](10) NULL,
	[tipo] [smallint] NOT NULL CONSTRAINT [DF_LOG_ACESSO_N_tipo]  DEFAULT ((1)),
	[ip] [char](15) NULL,
	[data] [smalldatetime] NULL CONSTRAINT [DF_LOG_ACESSO_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_LOG_ACESSO] PRIMARY KEY CLUSTERED 
(
	[id_acesso] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MK_Pagamentos](
	[id_pg] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[data] [char](10) NOT NULL,
	[hora] [char](10) NOT NULL,
	[terminal] [char](20) NOT NULL,
	[conta] [char](30) NOT NULL,
	[valor] [char](10) NOT NULL,
	[dados] [text] NOT NULL,
	[valor_depositado] [int] NOT NULL CONSTRAINT [DF_Pagamentos_valor_depositado]  DEFAULT ((0)),
	[valor_confirmado] [int] NOT NULL CONSTRAINT [DF_Pagamentos_valor_confirmado]  DEFAULT ((0)),
	[ip] [char](15) NULL,
	[data_pg] [smalldatetime] NOT NULL CONSTRAINT [DF_Pagamentos_data_pg]  DEFAULT (getdate()),
	[confirmado] [smallint] NOT NULL CONSTRAINT [DF_Pagamentos_confirmado]  DEFAULT ((0)),
	[respondido] [smallint] NOT NULL CONSTRAINT [DF_Pagamentos_respondido]  DEFAULT ((0)),
 CONSTRAINT [PK_Pagamentos] PRIMARY KEY CLUSTERED 
(
	[id_pg] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Online_today](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[quant] [int] NOT NULL CONSTRAINT [DF_Online_today_quant]  DEFAULT ((0)),
	[quant2] [int] NOT NULL CONSTRAINT [DF_Online_today_quant2]  DEFAULT ((0)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_Online_today_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_Online_today] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Murkut_News](
	[id_news] [int] IDENTITY(1,1) NOT NULL,
	[nome] [nvarchar](10) NULL,
	[valor] [nvarchar](20) NULL,
	[valor2] [nvarchar](25) NULL,
	[tipo] [int] NOT NULL,
	[data] [datetime] NOT NULL CONSTRAINT [DF_Murkut_News_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_Murkut_News] PRIMARY KEY CLUSTERED 
(
	[id_news] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MK_Mudar_Mail](
	[login] [nvarchar](10) NOT NULL,
	[antigo] [nvarchar](50) NOT NULL,
	[novo] [nvarchar](50) NOT NULL,
	[dias] [int] NOT NULL CONSTRAINT [DF_Mudar_Mail_dias]  DEFAULT ((0)),
	[ip] [char](15) NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_Mudar_Mail_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_Mudar_Mail] PRIMARY KEY CLUSTERED 
(
	[login] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MK_Mensagens](
	[id_msg] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[login_r] [nvarchar](10) NOT NULL,
	[msg] [text] NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_Mensagens_data]  DEFAULT (getdate()),
	[respondido] [smallint] NOT NULL CONSTRAINT [DF_Mensagens_respondido]  DEFAULT ((0)),
	[suporte] [tinyint] NOT NULL CONSTRAINT [DF_MK_Mensagens_suporte]  DEFAULT ((0)),
	[viu] [smallint] NOT NULL CONSTRAINT [DF_Mensagens_viu]  DEFAULT ((0)),
	[removeu1] [varchar](10) NULL,
	[removeu2] [varchar](10) NULL,
 CONSTRAINT [PK_Mensagens] PRIMARY KEY CLUSTERED 
(
	[id_msg] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TOP_Semanal](
	[id_top] [int] IDENTITY(1,1) NOT NULL,
	[nome] [varchar](10) NOT NULL,
	[dado] [int] NOT NULL,
	[tipo] [smallint] NOT NULL,
	[rank] [smallint] NOT NULL CONSTRAINT [DF_TOP_Semanal_rank]  DEFAULT ((1)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_TOP_Semanal_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_TOP_Semanal] PRIMARY KEY CLUSTERED 
(
	[id_top] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TOP_Mensal](
	[id_top] [int] IDENTITY(1,1) NOT NULL,
	[nome] [varchar](10) NOT NULL,
	[dado] [int] NOT NULL,
	[tipo] [smallint] NOT NULL,
	[rank] [smallint] NOT NULL CONSTRAINT [DF_TOP_Mensal_rank]  DEFAULT ((1)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_TOP_Mensal_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_TOP_Mensal] PRIMARY KEY CLUSTERED 
(
	[id_top] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TOP_Diario](
	[id_topd] [int] IDENTITY(1,1) NOT NULL,
	[nome] [nvarchar](10) NOT NULL,
	[dado] [int] NOT NULL,
	[tipo] [smallint] NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_TOP_Diario_data]  DEFAULT (getdate()),
 CONSTRAINT [PK_TOP_Diario] PRIMARY KEY CLUSTERED 
(
	[id_topd] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Server](
	[rei_do_mk] [smallint] NOT NULL CONSTRAINT [DF_Server_rei_do_mk]  DEFAULT ((0)),
	[recorde_on] [int] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MK_Reputacao](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[login_r] [nvarchar](10) NOT NULL,
	[reputacao] [char](1) NOT NULL CONSTRAINT [DF_Reputacao_reputacao]  DEFAULT ('P'),
	[comentario] [nvarchar](200) NULL,
 CONSTRAINT [PK_Reputacao] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MK_DV](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [varchar](10) NOT NULL,
	[link] [nvarchar](250) NOT NULL,
	[valor] [tinyint] NOT NULL CONSTRAINT [DF_MK_DV_valor]  DEFAULT ((0)),
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_MK_DV_data]  DEFAULT (getdate()),
	[invalida] [tinyint] NOT NULL CONSTRAINT [DF_MK_DV_invalida]  DEFAULT ((0)),
 CONSTRAINT [PK_MK_DV] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Chat_staff](
	[id_chat] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](20) NOT NULL,
	[name] [nvarchar](20) NOT NULL,
	[msg] [nvarchar](70) NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_Chat_staff_data]  DEFAULT (getdate()),
	[server] [smallint] NOT NULL CONSTRAINT [DF_Chat_staff_server]  DEFAULT ((0)),
 CONSTRAINT [PK_Chat_staff] PRIMARY KEY CLUSTERED 
(
	[id_chat] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[WZ_GetAccountLevel] 
@Account varchar(10)
AS
BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON


DECLARE @CurrentAccountLevel int
DECLARE @CurrentAccountExpireDate smalldatetime

SELECT @CurrentAccountLevel = AccountLevel, @CurrentAccountExpireDate = AccountExpireDate FROM MEMB_INFO WHERE memb___id = @account

IF (@CurrentAccountLevel <> 0 AND GETDATE() > @CurrentAccountExpireDate)
BEGIN
	SET @CurrentAccountLevel = 0
	UPDATE MEMB_INFO SET AccountLevel = @CurrentAccountLevel WHERE memb___id = @account
END

SELECT @CurrentAccountLevel as AccountLevel, @CurrentAccountExpireDate as AccountExpireDate


SET NOCOUNT OFF
SET XACT_ABORT OFF

END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--
-- Definition for stored procedure WZ_CS_ModifyTaxRate : 
--

--//************************************************************************
--// << ? ??? - ?? ???? >>
--// 
--// ??	: ?? ? (????) ? ??? ????.
--// ??	: ???? 1? 
--// ???	: 2004.11.09
--// ???	: ???
--// 
--//************************************************************************

CREATE PROCEDURE	[dbo].[WZ_CS_ModifyTaxRate]
	@iMapSvrGroup		SMALLINT,	-- ??? ??
	@iTaxKind		INT,		-- ??? ?? (1:????? / 2:??)
	@iTaxRate		INT		-- ??? ??
As
Begin
	BEGIN TRANSACTION
	
	SET NOCOUNT ON

	IF (@iTaxKind = 1)			-- ??? ?? ????
	BEGIN
		IF EXISTS ( SELECT MAP_SVR_GROUP FROM MuCastle_DATA  WITH (READUNCOMMITTED) 
					WHERE MAP_SVR_GROUP = @iMapSvrGroup)
		BEGIN
			UPDATE MuCastle_DATA 
			SET TAX_RATE_CHAOS = 0
			WHERE MAP_SVR_GROUP = @iMapSvrGroup
	
			SELECT @iTaxKind As TaxKind, 1 As QueryResult, TAX_RATE_CHAOS As TaxRate	-- ????? ??? ???? ????? ????.
			FROM MuCastle_DATA
			WHERE MAP_SVR_GROUP = @iMapSvrGroup
		END
		ELSE
		BEGIN
			SELECT @iTaxKind As TaxKind, 0 As QueryResult, 0 As TaxRate				-- ????? ??? ???? ???? ????? ????.
		END
	END
	ELSE IF (@iTaxKind = 2)			-- ?? ?? ??
	BEGIN
		IF EXISTS ( SELECT MAP_SVR_GROUP FROM MuCastle_DATA  WITH (READUNCOMMITTED) 
					WHERE MAP_SVR_GROUP = @iMapSvrGroup)
		BEGIN
			UPDATE MuCastle_DATA 
			SET TAX_RATE_STORE = 0 -- @iTaxRate
			WHERE MAP_SVR_GROUP = @iMapSvrGroup
	
			SELECT @iTaxKind As TaxKind, 1 As QueryResult, TAX_RATE_STORE As TaxRate	-- ????? ??? ???? ????? ????.
			FROM MuCastle_DATA
			WHERE MAP_SVR_GROUP = @iMapSvrGroup
		END
		ELSE
		BEGIN
			SELECT @iTaxKind As TaxKind, 0 As QueryResult, 0 As TaxRate				-- ????? ??? ???? ???? ????? ????.
		END
	END
	ELSE IF (@iTaxKind = 3)			-- ??? ??? ?? ??
	BEGIN
		IF EXISTS ( SELECT MAP_SVR_GROUP FROM MuCastle_DATA  WITH (READUNCOMMITTED) 
					WHERE MAP_SVR_GROUP = @iMapSvrGroup)
		BEGIN
			UPDATE MuCastle_DATA 
			SET TAX_HUNT_ZONE = 0 --@iTaxRate
			WHERE MAP_SVR_GROUP = @iMapSvrGroup
	
			SELECT @iTaxKind As TaxKind, 1 As QueryResult, TAX_HUNT_ZONE As TaxRate	-- ????? ??? ???? ????? ????.
			FROM MuCastle_DATA
			WHERE MAP_SVR_GROUP = @iMapSvrGroup
		END
		ELSE
		BEGIN
			SELECT @iTaxKind As TaxKind, 0 As QueryResult, 0 As TaxRate				-- ????? ??? ???? ???? ????? ????.
		END
	END
	ELSE
	BEGIN
		SELECT @iTaxKind As TaxKind, 0 As QueryResult, 0 As TaxRate					-- ????? ???? ???.
	END


	IF(@@Error <> 0 )
		ROLLBACK TRANSACTION
	ELSE	
		COMMIT TRANSACTION

	SET NOCOUNT OFF	
End
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[EVENTO_ITENS]
@uid varchar(20),
@tip int
AS

Begin 

SET NoCOUNT ON
DECLARE
@wh_acid varchar(10),
@wh_data binary(1920),
@wh_type binary(2),
@wh_full binary(1),
@wh_serial binary(4),
@wj_serial binary(4),
@wh_13 binary(1),
@k int,
@j int,
@qtd int,
@find int,
@conn int

SELECT @conn = (SELECT top 1 connectstat FROM memb_stat where memb___id=@uid)

SET @k=0
SET @qtd=0

if @conn = 0 
BEGIN
--Verifica Baú
SELECT @wh_data=items FROM warehouse where accountid = @uid


WHILE @k<120 AND @wh_data IS NOT NULL
BEGIN
SET @wh_type=SUBSTRING(@wh_data,@k*16+1,2)
SET @wh_serial=SUBSTRING(@wh_data,@k*16+4,4)
SET @wh_13=SUBSTRING(@wh_data,@k*16+8,1)
SET @k=@k+1

IF 
@wh_type = 0xCB60
BEGIN
SET @find=0
SET @j=0

	WHILE @j < (@k-1)
		BEGIN
			SET @wj_serial=SUBSTRING(@wh_data,@j*16+4,4)
			SET @j=@j+1

				IF @wj_serial = @wh_serial
					BEGIN
						SET @find=1
						INSERT INTO LOG_DUPE_EVENTO (login,serial,evento) VALUES (@uid, @wj_serial,'K5')
					END
		END

IF @wh_serial = 0x00000000
BEGIN
set @wh_data = substring(@wh_data ,1,16*@j)+0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF+substring(@wh_data,16*@j+11,len(@wh_data))
update [warehouse] set [items]=@wh_data where [AccountId]=@uid
END

IF @find=0 and @wh_serial<>0x00000000
	BEGIN
		SET @qtd = @qtd+1
	END

END
END
END

select @qtd as qtd

END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Chat_online](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[data] [smalldatetime] NOT NULL CONSTRAINT [DF_Chat_online_data]  DEFAULT (getdate()),
	[img] [nvarchar](25) NULL,
 CONSTRAINT [PK_Chat_online] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_MEDALHAS](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[login] [nvarchar](10) NOT NULL,
	[Name] [nvarchar](10) NOT NULL,
	[medal_evento] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_evento]  DEFAULT ((0)),
	[medal_resets] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_resets]  DEFAULT ((0)),
	[medal_mresets] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_mresets]  DEFAULT ((0)),
	[medal_tempo] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_tempo]  DEFAULT ((0)),
	[medal_sresets] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_sresets]  DEFAULT ((0)),
	[medal_smresets] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_smresets]  DEFAULT ((0)),
	[medal_pk] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_pk]  DEFAULT ((0)),
	[medal_exp] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_exp]  DEFAULT ((0)),
	[medal_gm] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_gm]  DEFAULT ((0)),
	[medal_reputacao] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_reputacao]  DEFAULT ((0)),
	[medal_evento_m] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_evento_m]  DEFAULT ((0)),
	[medal_resets_m] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_resets_m]  DEFAULT ((0)),
	[medal_mresets_m] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_mresets_m]  DEFAULT ((0)),
	[medal_tempo_m] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_tempo_m]  DEFAULT ((0)),
	[medal_pk_m] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_pk_m]  DEFAULT ((0)),
	[medal_ds] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_ds]  DEFAULT ((0)),
	[medal_ds_s] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_ds_s]  DEFAULT ((0)),
	[medal_rei] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_rei]  DEFAULT ((0)),
	[medal_duel_semanal] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_duel1_5]  DEFAULT ((0)),
	[medal_duel] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_duel]  DEFAULT ((0)),
	[medal_missao] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_duel1]  DEFAULT ((0)),
	[medal_bc] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_duel1_1]  DEFAULT ((0)),
	[medal_vip] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_duel1_2]  DEFAULT ((0)),
	[medal_contribuinte] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_duel1_3]  DEFAULT ((0)),
	[medal_rei_conquistas] [tinyint] NOT NULL CONSTRAINT [DF_Character_medal_duel1_4]  DEFAULT ((0)),
	[medal_bc_s] [tinyint] NOT NULL CONSTRAINT [DF_MK_MEDALHAS_medal_bc_s]  DEFAULT ((0)),
	[medal_hr] [tinyint] NOT NULL CONSTRAINT [DF_MK_MEDALHAS_medal_hr]  DEFAULT ((0)),
	[medal_hr_m] [tinyint] NOT NULL CONSTRAINT [DF_MK_MEDALHAS_medal_hr_m]  DEFAULT ((0)),
	[medal_cc_s] [tinyint] NOT NULL CONSTRAINT [DF_MK_MEDALHAS_medal_cc_s]  DEFAULT ((0)),
	[medal_joias] [tinyint] NOT NULL CONSTRAINT [DF_MK_MEDALHAS_medal_joias]  DEFAULT ((0)),
 CONSTRAINT [PK_LOginName] PRIMARY KEY CLUSTERED 
(
	[login] ASC,
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MK_Quest](
	[Name] [nvarchar](10) NOT NULL,
	[quest1] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest1]  DEFAULT ((0)),
	[quest2] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest2]  DEFAULT ((0)),
	[quest3] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest3]  DEFAULT ((0)),
	[quest4] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest4]  DEFAULT ((0)),
	[quest5] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest5]  DEFAULT ((0)),
	[quest6] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest6]  DEFAULT ((0)),
	[quest7] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest7]  DEFAULT ((0)),
	[quest8] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest8]  DEFAULT ((0)),
	[quest9] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest9]  DEFAULT ((0)),
	[quest10] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest10]  DEFAULT ((0)),
	[quest11] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest11]  DEFAULT ((0)),
	[quest12] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest12]  DEFAULT ((0)),
	[quest13] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest13]  DEFAULT ((0)),
	[quest14] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest14]  DEFAULT ((0)),
	[quest15] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest15]  DEFAULT ((0)),
	[quest16] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest16]  DEFAULT ((0)),
	[quest17] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest17]  DEFAULT ((0)),
	[quest18] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest18]  DEFAULT ((0)),
	[quest19] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest19]  DEFAULT ((0)),
	[quest20] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest20]  DEFAULT ((0)),
	[nivel] [smallint] NOT NULL CONSTRAINT [DF_Quest_nivel]  DEFAULT ((0)),
	[quest21] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest21]  DEFAULT ((0)),
	[quest22] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest22]  DEFAULT ((0)),
	[quest23] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest23]  DEFAULT ((0)),
	[quest24] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest24]  DEFAULT ((0)),
	[quest25] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest25]  DEFAULT ((0)),
	[quest26] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest26]  DEFAULT ((0)),
	[quest27] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest27]  DEFAULT ((0)),
	[quest28] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest28]  DEFAULT ((0)),
	[quest29] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest29]  DEFAULT ((0)),
	[quest30] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest30]  DEFAULT ((0)),
	[quest31] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest31]  DEFAULT ((0)),
	[quest32] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest32]  DEFAULT ((0)),
	[quest33] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest33]  DEFAULT ((0)),
	[quest34] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest34]  DEFAULT ((0)),
	[quest35] [smallint] NOT NULL CONSTRAINT [DF_Quest_quest35]  DEFAULT ((0)),
 CONSTRAINT [PK_Quest] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[WZ_SetResetInfo] 
@Account varchar(10),
@Name varchar(10),
@Reset int,
@ResetDay int,
@ResetWek int,
@ResetMon int
AS
BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON

SET @Reset = 1

UPDATE Character SET ResetCount=ResetCount+@Reset, reset_diario = reset_diario +@Reset, reset_semanal = reset_semanal +@Reset, reset_mensal = reset_mensal+@Reset
 WHERE AccountID=@Account AND Name=@Name

SET NOCOUNT OFF
SET XACT_ABORT OFF

END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[WZ_SetMasterResetInfo] 
@Account varchar(10),
@Name varchar(10),
@Reset int,
@MasterReset int,
@MasterResetDay int,
@MasterResetWek int,
@MasterResetMon int
AS
BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON

set @Reset = 1

UPDATE Character SET MasterResetCount=MasterResetCount+@Reset,mresets_diario=mresets_diario+@Reset, mresets_semanal = mresets_semanal +@Reset, mreset_mensal = mreset_mensal+@Reset, exp_war = exp_war +30
 WHERE AccountID=@Account AND Name=@Name

UPDATE CashShopData SET WCoinP = WCoinP + 10, GoblinPoint = GoblinPoint+30 WHERE AccountID=@Account

SET NOCOUNT OFF
SET XACT_ABORT OFF

END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[WZ_GetResetInfo]
@Account varchar(10),
@Name varchar(10)
AS
BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON

DECLARE @Reset int
DECLARE @ResetDay int
DECLARE @ResetWek int
DECLARE @ResetMon int

SELECT @Reset=ResetCount,@ResetDay=0,@ResetWek=0,@ResetMon=0 FROM Character WHERE AccountID=@Account AND Name=@Name

SELECT @Reset AS Reset,@ResetDay AS ResetDay,@ResetWek AS ResetWek,@ResetMon AS ResetMon

SET NOCOUNT OFF
SET XACT_ABORT OFF

END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[WZ_GetMasterResetInfo]
@Account varchar(10),
@Name varchar(10)
AS
BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON

DECLARE @MasterReset int
DECLARE @MasterResetDay int
DECLARE @MasterResetWek int
DECLARE @MasterResetMon int

SELECT @MasterReset=MasterResetCount,@MasterResetDay=0,@MasterResetWek=0,@MasterResetMon=0 FROM Character WHERE AccountID=@Account AND Name=@Name

SELECT @MasterReset AS MasterReset,@MasterResetDay AS MasterResetDay,@MasterResetWek AS MasterResetWek,@MasterResetMon AS MasterResetMon

SET NOCOUNT OFF
SET XACT_ABORT OFF

END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[chat_atualizar]
@acc varchar(10)
as
begin

IF not exists (Select login from MK_chat_online where login = @acc)
	INSERT INTO MK_Chat_online (login) VALUES (@acc)
ELSE
	UPDATE MK_Chat_online set data = (getdate()) where login = @acc
	
end
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[VERIFICAR_ITENS]
@uid varchar(20),
@type binary(2)
AS

Begin 

SET NoCOUNT ON
DECLARE
@wh_acid varchar(10),
@wh_data binary(3840),
@wh_type binary(2),
@wh_full binary(1),
@wh_serial binary(4),
@wj_serial binary(4),
@wh_13 binary(1),
@k int,
@j int,
@qtd int,
@find int,
@conn int

SELECT @conn = (SELECT top 1 connectstat FROM memb_stat where memb___id=@uid)

SET @k=0
SET @qtd=0
SET @find=0

if @conn = 0 
BEGIN
--Verifica Baú
SELECT @wh_data=items FROM warehouse where accountid = @uid

WHILE @k<120 AND @wh_data IS NOT NULL
BEGIN
SET @wh_type=SUBSTRING(@wh_data,@k*16+1,2)
SET @k=@k+1

	IF 
	@wh_type <> @type
	and @wh_type <> 0xFFFF
	BEGIN
		SET @find = 1
	END
END

SET @k=0

--Verifica Baú
IF @find = 0 
BEGIN

WHILE @k<120 AND @wh_data IS NOT NULL
BEGIN
SET @wh_type=SUBSTRING(@wh_data,@k*16+1,2)
SET @wh_serial=SUBSTRING(@wh_data,@k*16+4,4)
SET @wh_13=SUBSTRING(@wh_data,@k*16+8,1)
SET @k=@k+1

IF 
@wh_type = @type
BEGIN
SET @find=0
SET @j=0

	WHILE @j < (@k-1)
		BEGIN
			SET @wj_serial=SUBSTRING(@wh_data,@j*16+4,4)
			SET @j=@j+1

				IF @wj_serial = @wh_serial
					BEGIN
						SET @find=1
						INSERT INTO LOG_DUPE_EVENTO (login,serial,evento) VALUES (@uid, @wj_serial,'K5')
					END
		END

set @wh_data = substring(@wh_data ,1,16*@j)+0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF+substring(@wh_data,16*@j+17,len(@wh_data))

IF @find=0 and @wh_serial<>0x00000000
	BEGIN
		SET @qtd = @qtd+1
	END

END
END
END
	IF @qtd >= 120 
		BEGIN
			update [warehouse] set [items]=@wh_data where [AccountId]=@uid
			
			if @type = 0x0E00
			begin
				declare @nome varchar(10)
				select @nome = dbo.fn_char_forte(@uid)
				if exists (select login from mk_medalhas where login = @uid and name = @nome)
					UPDATE MK_MEDALHAS SET medal_joias=1 where name = @nome
				ELSE
					INSERT INTO MK_MEDALHAS (login,name,medal_joias) VALUES (@uid,@nome,1)
			end
		END
END

select @qtd as qtd, @find as find

END
GO
ALTER TABLE [dbo].[MK_MEDALHAS]  WITH CHECK ADD  CONSTRAINT [FK_MK_MEDALHAS_Character] FOREIGN KEY([Name])
REFERENCES [dbo].[Character] ([Name])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[MK_MEDALHAS] CHECK CONSTRAINT [FK_MK_MEDALHAS_Character]
GO
ALTER TABLE [dbo].[MK_Quest]  WITH CHECK ADD  CONSTRAINT [fk_name_char] FOREIGN KEY([Name])
REFERENCES [dbo].[Character] ([Name])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[MK_Quest] CHECK CONSTRAINT [fk_name_char]
GO


CREATE Procedure [dbo].[PREMIAR_TOPS] 
@Account varchar(10),
@Name varchar(10),
@WC int,
@WP int,
@GP int,
@XP int,
@VIP1 int,
@VIP2 int,
@VIP3 int,
@EVENTOS int
AS
BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON

IF @WC > 0 or @WP > 0 or @GP > 0
BEGIN
UPDATE CashShopData 
	SET WCoinC = WCoinC + @WC, WCoinP = WCoinP + @WP, GoblinPoint = GoblinPoint + @GP where AccountID = @Account
END 

IF @WC > 0
BEGIN
	insert into log_creditos ( login, valor, ip, tipo ) values (@Account,@WC,'1','6')
END

IF @EVENTOS > 0 or @XP > 0
BEGIN 
UPDATE Character 
	SET exp_war = exp_war + @XP, eventos = eventos + @EVENTOS where Name = @Name and AccountID = @Account
END

IF @VIP1 > 0
BEGIN
	-- ADD VIP NA CONTA VIP_AL1
	update memb_info set AccountExpireDate = AccountExpireDate+@VIP1 where memb___id = @Account and accountlevel = 1
	-- ADD VIP NA CONTA VIP_AL0
	update memb_info set accountlevel = 1, AccountExpireDate = (getdate())+@VIP1 where memb___id = @Account and accountlevel = 0
	
	if (select COUNT(*) from MEMB_INFO where memb___id = @Account and AccountLevel = 1) > 0
	Insert into log_vip (login,dias,tipo) values (@Account,@VIP1,'6' )
END

if @VIP2 > 0
BEGIN
	-- ADD VIP NA CONTA VIP_AL2
	update memb_info set AccountExpireDate = AccountExpireDate+@VIP2 where memb___id = @Account and accountlevel = 2
	
	if (select COUNT(*) from MEMB_INFO where memb___id = @Account and AccountLevel = 2) > 0
	Insert into log_vip (login,dias,tipo) values (@Account,@VIP2,'7' )
END

if @VIP3 > 0
BEGIN
	-- ADD VIP NA CONTA VIP_AL3
	update memb_info set AccountExpireDate = AccountExpireDate+@VIP3 where memb___id = @Account and accountlevel = 3

	if (select COUNT(*) from MEMB_INFO where memb___id = @Account and AccountLevel = 3) > 0
	Insert into log_vip (login,dias,tipo) values (@Account,@VIP3,'8' )
END


CREATE Procedure [dbo].[PREMIAR_TOPS_MEDALHAS] 
@Account	varchar(10),
@Name		varchar(10),
@MEDALHA	int
AS
BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON

IF @MEDALHA = 1 
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_sresets=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_sresets) VALUES (@Account,@name,1)
END

IF @MEDALHA = 2 
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_smresets=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_smresets) VALUES (@Account,@name,1)
END

IF @MEDALHA = 3 
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_tempo=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_tempo) VALUES (@Account,@name,1)
END

IF @MEDALHA = 4 
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_evento=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_evento) VALUES (@Account,@name,1)
END

IF @MEDALHA = 5 
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_pk=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_pk) VALUES (@Account,@name,1)
END

IF @MEDALHA = 6 
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_hr=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_hr) VALUES (@Account,@name,1)
END

IF @MEDALHA = 7
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_ds_s=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_ds_s) VALUES (@Account,@name,1)
END

IF @MEDALHA = 8
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_bc_s=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_bc_s) VALUES (@Account,@name,1)
END

IF @MEDALHA = 9
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_cc_s=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_cc_s) VALUES (@Account,@name,1)
END

IF @MEDALHA = 10
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_duel_semanal=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_duel_semanal) VALUES (@Account,@name,1)
END

IF @MEDALHA = 11
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_resets_m=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_resets_m) VALUES (@Account,@name,1)
END

IF @MEDALHA = 12
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_mresets_m=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_mresets_m) VALUES (@Account,@name,1)
END


IF @MEDALHA = 13
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_tempo_m=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_tempo_m) VALUES (@Account,@name,1)
END

IF @MEDALHA = 14
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_evento_m=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_evento_m) VALUES (@Account,@name,1)
END

IF @MEDALHA = 15
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_pk_m=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_pk_m) VALUES (@Account,@name,1)
END

IF @MEDALHA = 16
BEGIN
	if exists (select login from mk_medalhas where login = @Account and name = @name)
		UPDATE MK_MEDALHAS SET medal_hr_m=1 where name = @name
	ELSE
		INSERT INTO MK_MEDALHAS (login,name,medal_hr_m) VALUES (@Account,@name,1)
END




INSERT INTO MK_SERVER (REI_DO_MK,recorde_on) VALUES (0,0)
GO
