[Stored Procedure] Add Item

Results 1 to 3 of 3
  1. #1
    LordJustice crosenblum is offline
    True MemberRank
    Apr 2007 Join Date
    Burnsville, MNLocation
    401Posts

    [Stored Procedure] Add Item


    RaGEZONE Recommends

    RaGEZONE Recommends

    I know this is pretty simple or already used, but for new owners, this may be useful.

    What this does is lets you easily in other stored procedures or in engine, add items to a user, just using the minimal colums in the Item table.

    USE [kal_db]
    GO
    /****** Object: StoredProcedure [dbo].[AddItem] ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[AddItem]
    --Declare parameters
    @Player_id int,
    @Index_id int,
    @Quantity int
    AS
    BEGIN

    --Declare variables
    Declare @item_id int

    --step 1. Get Item IID Max for this current user
    select @item_id = max(IID)
    from [dbo].[Player]
    where PID = @Player_id

    --step 2. add item for this user
    INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num])
    VALUES ( @Player_id, @item_id, @Index_id, 0, 0, @Quantity)


    END


  2. #2
    boo General is offline
    Alpha MaleRank
    Sep 2006 Join Date
    at homeLocation
    2,320Posts

    Re: [Stored Procedure] Add Item

    .
    Quote Originally Posted by crosenblum View Post
    I know this is pretty simple or already used, but for new owners, this may be useful.

    What this does is lets you easily in other stored procedures or in engine, add items to a user, just using the minimal colums in the Item table.

    USE [kal_db]
    GO
    /****** Object: StoredProcedure [dbo].[AddItem] ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[AddItem]
    --Declare parameters
    @Player_id int,
    @Index_id int,
    @Quantity int
    AS
    BEGIN

    --Declare variables
    Declare @item_id int

    --step 1. Get Item IID Max for this current user
    select @item_id = max(IID)
    from [dbo].[Player]
    where PID = @Player_id

    --step 2. add item for this user
    INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num])
    VALUES ( @Player_id, @item_id, @Index_id, 0, 0, @Quantity)


    END
    Never ever run this while your server is running. It will cause double IIDs as DbSvr fetches the MaxIID only on startup and not every time it adds a new item.
    It's better to add 1 item with a high IID number and to have all ingame items above that Iid, while all Sp/php generated items stay under that IID.
    Known from SolleKal, SwordOnline, New World Kal and Trinity Kal.

  3. #3
    LordJustice crosenblum is offline
    True MemberRank
    Apr 2007 Join Date
    Burnsville, MNLocation
    401Posts

    Re: [Stored Procedure] Add Item

    The main purpose of this is for when the game server is NOT running.




Advertisement