top

Anti-Dupe Script

 
Creaza un subiect nou   Raspunde la subiect    Pagina de start a forumului Online Games Tutorials Forum , Linkmedia -> Cum faci server de Mu Online
Autor Mesaj
Khubala
Administrator
Administrator


Data inscrierii: 01/Mai/2008
Mesaje: 111

MesajTrimis: 05/05/2008 10:40    Titlul subiectului: Anti-Dupe Script Raspunde cu citat (quote)

:arrow: Acest script , iti sterge itemele cu acelasi serial , sterge dupele.

:arrow: Ruleaza acest script in QA ( Query Analyzer ) selectand data base MuOnline.

Cod:
USE MUONLINE
   if exists(select * from dbo.sysobjects where type='p' and name='WZ_GetItemSerial')
   drop procedure WZ_GetItemSerial
GO

CREATE procedure WZ_GetItemSerial
AS
BEGIN
   DECLARE @ItemSerial int
   SET NOCOUNT ON
   BEGIN TRANSACTION
   UPDATE GameServerInfo set @ItemSerial = ItemCount = (case when ItemCount < 0x7effffff then ItemCount+1
   ELSE 1
   END)
   
   IF(@@error <> 0)
   BEGIN
      rollback transaction
      select-1
   END
   ELSE
   BEGIN
      commit transaction
      select @ItemSerial
   END
END
GO

   if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[trg_CheckSameID]') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
   drop trigger [dbo].[trg_CheckSameID]
GO

   if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AllItemsLog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
   drop table [dbo].[AllItemsLog]
GO

   if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CopyLog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
   drop table [dbo].[CopyLog]
GO

CREATE TABLE [dbo].[AllItemsLog] (
   [items_id] [int] IDENTITY (1, 1) NOT NULL ,
   [items_type] [binary] (1) NOT NULL ,
   [items_serial] [binary] (4) NOT NULL ,
   [items_acid] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[CopyLog] (
   [copy_id] [int] IDENTITY (1, 1) NOT NULL ,
   [copy_acid] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
   [copy_name] [varchar] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
   [copy_type] [binary] (1) ,
   [copy_serial] [binary] (4) ,
   [copy_item] [binary] (16) ,
   [copy_date] [datetime] NOT NULL
) ON [PRIMARY]
GO
 
   ALTER TABLE [dbo].[AllItemsLog] ADD
   CONSTRAINT [DF_CT_ITEM_item] DEFAULT (0) FOR [items_type],
   CONSTRAINT [DF_CT_ITEM_itemid] DEFAULT (0) FOR [items_serial],
   CONSTRAINT [DF_CT_ITEM_itemrole] DEFAULT ('\') FOR [items_acid]
GO
 
   CREATE INDEX [IX_CT_ITEM] ON [dbo].[AllItemsLog]([items_type], [items_serial]) ON [PRIMARY]
GO
 
   ALTER TABLE [dbo].[CopyLog] ADD
   CONSTRAINT [DF_CopyLog_copy_date] DEFAULT (getdate()) FOR [copy_date]
GO
 
   SET QUOTED_IDENTIFIER ON
GO

   SET ANSI_NULLS ON
GO
   CONFECÈ›IONATE TRIGGER [dbo].[trg_CheckSameID] ON [dbo].[character]
   FOR UPDATE
   AS
   BEGIN
      IF UPDATE(inventory)
      BEGIN
         SET NOCOUNT ON
         DECLARE
         @wh_acid varchar(10),
         @wh_data binary(1920),
         @wh_type binary(1),
         @wh_serial binary(4),
         @wh_item binary(16),
         @cr_user varchar(10),
         @cr_acid varchar(10),
         @cr_char varchar(15),
         @cr_data binary(760),
         @cr_type binary(1),
         @cr_serial binary(4),
         @cr_item binary(16),
         @al_acid varchar(10),
         @j int,
         @ok int,
         @warehouse_length int,
         @find bit

         -- Selecting information about inserted object
         SELECT @cr_acid=i.accountid, @cr_data=i.inventory ,@cr_char=i.name FROM inserted i

         -- Length of the warehouse in binary
         SET @warehouse_length=1920
         
         SET @j=0
         SET @find=0
         WHILE @j<76 AND @cr_data IS NOT NULL
         BEGIN
            SET @cr_type=SUBSTRING(@cr_data,@j*16+1,1)
            SET @cr_serial=SUBSTRING(@cr_data,@j*16+4,4)
            SET @cr_item=SUBSTRING(@cr_data,@j*16+1,16)
            IF @cr_type<>0xFF AND @cr_serial<>0x00000000
            BEGIN
               SELECT @al_acid=items_acid FROM allitemslog WHERE items_type=@cr_type AND items_serial=@cr_serial
               IF @al_acid IS NULL
                  INSERT INTO allitemslog (items_type,items_serial,items_acid) VALUES (@cr_type,@cr_serial,@cr_acid)
               ELSE
               BEGIN
                  UPDATE allitemslog SET items_acid=@cr_acid WHERE items_type=@cr_type AND items_serial=@cr_serial

                  SELECT @wh_data=items FROM warehouse WHERE accountid=@al_acid
                  SET @ok=0
                  WHILE @ok<120 AND @wh_data IS NOT NULL
                  BEGIN
                     SET @wh_type=SUBSTRING(@wh_data,@ok*16+1,1)
                     SET @wh_serial=SUBSTRING(@wh_data,@ok*16+4,4)
                     SET @wh_item=SUBSTRING(@wh_data,@ok*16+1,16)
                     IF @wh_type=@cr_type AND @wh_serial=@cr_serial
                     BEGIN
                        SET @find=1
                        -- Insert dupe record in to the log (item with serial)
                        INSERT INTO copylog (copy_type,copy_serial,copy_item,copy_acid,copy_name,copy_date) VALUES (@cr_type,@cr_serial,@cr_item,@al_acid,@cr_char,getdate())
                        SET @wh_data=SUBSTRING(@wh_data,1,@ok*16)+0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF+SUBSTRING(@wh_data,((@ok+1)*16+1),@warehouse_length-(((@ok+1)*16)))
                       
                        -- Update warehouse, delete dupe
                        UPDATE warehouse SET items=@wh_data where accountid=@al_acid
                     END
                     SET @ok=@ok+1
                  END
               END
            END
            SET @j=@j+1
         END
         
         IF @find=1
         BEGIN
            -- This is where u can add more punishment like ban or lock characters

            -- Block character that has dupes on him [if you feel like it]
            --UPDATE Character SET CtlCode=1 WHERE name=@cr_char
            -- Do not block the character
            UPDATE Character SET CtlCode=0 WHERE name=@cr_char
         END
         SET NOCOUNT OFF
      END
   END
GO

   SET QUOTED_IDENTIFIER OFF
GO
 
   SET ANSI_NULLS ON
GO


Succes !
Sus
Vezi profilul utilizatorului Trimite mesaj privat
Afiseaza mesajele pentru a le previzualiza:    Subiectul anterior : Subiectul urmator  
Creaza un subiect nou   Raspunde la subiect    Pagina de start a forumului Online Games Tutorials Forum , Linkmedia -> Cum faci server de Mu Online Ora este GMT + 2 ore
Pagina 1 din 1

 
Mergi direct la:  
Nu puteti crea un subiect nou in acest forum
Nu puteti raspunde in subiectele acestui forum
Nu puteti modifica mesajele proprii din acest forum
Nu puteti sterge mesajele proprii din acest forum
Nu puteti vota in chestionarele din acest forum

Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro