• Vsro Sql Code ( Model Switcher ) Simple




    - AddLogItem



    Code:
    if (@ItemRefID = 43054)
    BEGIN
    EXEC SRO_VT_SHARDLOG.dbo._NOVA_SWITCHER @CharID
    END

    - Query


    Code:
    USE [SRO_VT_SHARDLOG]
    GO
    /****** Object: StoredProcedure [dbo].[_NOVA_SWITCHER] Script Date: 6/6/2015 2:42:04 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    /****** Object: StoredProcedure [dbo].[_NOVA_SWITCHER] Script Date: 6/6/2015 8:10:36 AM ******/
    CREATE PROCEDURE [dbo].[_NOVA_SWITCHER]
    -- =============================================
    /*
    Eslam Galull
    */
    -- =============================================
    @CharID INT
    AS
    BEGIN
    --//---------------------------------------------------------------
    DECLARE @INVSIZE TINYINT,
    @Top1Wep int,
    @OldItm int
    Set @InvSize = (select InventorySize from sro_vt_shard.._char where charid = @charid)
    set @Top1Wep = (select top 1 inv.itemid from sro_vt_shard.._inventory inv inner join sro_vt_shard.._items itm on inv.itemid = itm.id64
    where itm.refitemid in (select ItemID from _ModelSwitcher) and itm.serial64 > 0 and inv.itemid <> 0 and inv.slot between 13 and @InvSize and inv.charid = @charid )
    Set @OldItm = (select top 1 refitemid from sro_vt_shard.._items where id64 <> 0 and id64 = @Top1Wep and serial64 > 0)
    if @Top1Wep > 0
    Begin
    Declare @NewItm int = case
    When @olditm in (select ItemID from _ModelSwitcher)
    then (select top 1 Newitemid from _ModelSwitcher where ItemID = @olditm )
    end /* will destroy any item that he tries to switch if he dont have required items */
    update sro_vt_shard.._items set RefItemID = @NewItm where RefItemID = @OldItm and ID64 = @Top1Wep and Serial64 > 0
    End
    END
    GO



    - table ( so here u should put the olditem id .. and the new one id ) thats all

    like that



    Code:
    USE [SRO_VT_SHARDLOG]
    GO
    /****** Object: Table [dbo].[_ModelSwitcher] Script Date: 6/6/2015 2:43:23 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO SET ANSI_PADDING ON GO
    CREATE TABLE [dbo].[_ModelSwitcher](
    [ItemID] [int] NOT NULL,
    [ItemCode] [varchar](max) NOT NULL,
    [NewitemID] [int] NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO


    - All Copyrights Reserved to Eslam Galull @galullians.com 2015
  • Twitter

    Like us

    Author Info