Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Stored Procedure] Add Item

Experienced Elementalist
Joined
Apr 16, 2007
Messages
266
Reaction score
61
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
 
Joined
Sep 10, 2006
Messages
1,243
Reaction score
179
.
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.
 
Back
Top