Bu vereceğim kodları sql nize ekleyerek panelinizden item kitleme yapabilirsiniz.
Bu sql kodları sayesinde item kitlemeyi sorunsuz yapabilirsiniz.
Sql Kod item kitleme Aşağıda bulabilirsiniz
Bu kodları sırayla SQL nize girin item kitleme sorunsuz çalışmaktadır.
KOD 1 :
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ItemSealOnPos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ItemSealOnPos]
GO
CREATE PROCEDURE [dbo].[ItemSealOnPos] (@strUserID varchar(30), @ItemNum int,@ItemPos int )
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNumCheck int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0 and @ItemNum > 0
BEGIN
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @i = (((@ItemPos + 1) * 8) - 7)
SET @ItemNumCheck = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
if @ItemNum = @ItemNumCheck
BEGIN
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
if @ItemSerial <> 0
BEGIN
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if @IsAlreadyLocked = 0
BEGIN
INSERT INTO User_LockedItems (strUserID,ItemSerial,ItemNum) values (@strUserID,@ItemSerial,@ItemNum)
print 'Kilit basarili'
return
END
END
END
END
END
print 'Kilit basarisiz'
return
END
[/HIDE-THANKS]
KOD 2 :
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ItemUnSealOnPos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ItemUnSealOnPos]
GO
CREATE PROCEDURE [dbo].[ItemUnSealOnPos] (@strUserID varchar(30), @ItemNum int,@ItemPos int )
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNumCheck int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0 and @ItemNum > 0
BEGIN
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @i = (((@ItemPos + 1) * 8) - 7)
SET @ItemNumCheck = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
if @ItemNum = @ItemNumCheck
BEGIN
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
if @ItemSerial <> 0
BEGIN
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if @IsAlreadyLocked > 0
BEGIN
delete from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
print 'UnKilit basarili'
return
END
END
END
END
END
print 'UnKilit basarisiz'
return
END
GO
KOD 3 :
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FetchUserItems]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[FetchUserItems]
GO
CREATE PROCEDURE [dbo].[FetchUserItems] (@strUserID varchar(30))
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNum int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int,@ItemPos as int,@ItemStack as int,@ItemDuration as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0
BEGIN
delete from ListUserItems where strUserID=@strUserID
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @ItemPos = 0
SET @i = (((@ItemPos + 1) * 8) - 7)
while 401 > @i
BEGIN
SET @ItemNum = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
SET @ItemDuration = cast(cast(cast( substring(@InventoryItems, @i+5, 1) as varbinary(1))+cast(substring(@InventoryItems, @i+4, 1) as varbinary(1)) as varbinary(2)) as smallint)
SET @ItemStack = cast(cast(cast( substring(@InventoryItems, @i+7, 1) as varbinary(1))+cast(substring(@InventoryItems, @i+6, 1) as varbinary(1)) as varbinary(2)) as smallint)
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
INSERT INTO ListUserItems (strUserID,ItemPos,ItemNum,ItemSerial,ItemStack,It emDuration,ItemSealed) values (@strUserID,@ItemPos,@ItemNum,@ItemSerial,@ItemSta ck,@ItemDuration,@IsAlreadyLocked)
SET @ItemPos = @ItemPos + 1
SET @i = (((@ItemPos + 1) * 8) - 7)
END
END
select * from ListUserItems where strUserID=@strUserID order by ItemPos
return
END
print 'Item listing fail'
return
END
GO
KOD 4:
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ItemSealInventory]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ItemSealInventory]
GO
CREATE PROCEDURE [dbo].[ItemSealInventory] (@strUserID varchar(30))
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNum int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int,@ItemPos as int,@ItemStack as int,@ItemDuration as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0
BEGIN
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @ItemPos = 0
SET @i = (((@ItemPos + 1) * 8) - 7)
while 401 > @i
BEGIN
SET @ItemNum = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if (@IsAlreadyLocked = 0) and (@ItemNum > 0) and (@ItemSerial > 0)
BEGIN
INSERT INTO User_LockedItems (strUserID,ItemSerial,ItemNum) values (@strUserID,@ItemSerial,@ItemNum)
END
SET @ItemPos = @ItemPos + 1
SET @i = (((@ItemPos + 1) * 8) - 7)
END
END
print 'Inventory lock success'
return
END
print 'Inventory lock failed'
return
END
GO
KOD 5 :
CREATE PROCEDURE [dbo].[ItemKilitlePanel] (@strUserID varchar(30), @ItemPos int )AS
BEGIN
SET NOCOUNT ON;
SET @strUserID = ltrim(rtrim(@strUserID))
print 'Islem basladi'
DECLARE @ItemNum int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
print 'Kullanici kontrol ediliyor'
if (@IsRealUser > 0)
BEGIN
print 'Kulanici bulundu'
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @i = (((@ItemPos + 1) * 8) - 7)
SET @ItemNum = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
if @ItemNum > 0
BEGIN
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
if @ItemSerial <> 0
BEGIN
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if @IsAlreadyLocked = 0
BEGIN
INSERT INTO User_LockedItems (strUserID,ItemSerial,ItemNum) values (@strUserID,@ItemSerial,@ItemNum)
print 'Kilit basarili'
return
END
if @IsAlreadyLocked > 0
BEGIN
delete from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
print 'UnKilit basarili'
return
END
END
END
END
END
return
END
GO
Şimdi iste Tablolarımıza geçelim
TABLO 1 :
Bu sql kodları sayesinde item kitlemeyi sorunsuz yapabilirsiniz.
Sql Kod item kitleme Aşağıda bulabilirsiniz
Bu kodları sırayla SQL nize girin item kitleme sorunsuz çalışmaktadır.
KOD 1 :
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ItemSealOnPos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ItemSealOnPos]
GO
CREATE PROCEDURE [dbo].[ItemSealOnPos] (@strUserID varchar(30), @ItemNum int,@ItemPos int )
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNumCheck int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0 and @ItemNum > 0
BEGIN
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @i = (((@ItemPos + 1) * 8) - 7)
SET @ItemNumCheck = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
if @ItemNum = @ItemNumCheck
BEGIN
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
if @ItemSerial <> 0
BEGIN
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if @IsAlreadyLocked = 0
BEGIN
INSERT INTO User_LockedItems (strUserID,ItemSerial,ItemNum) values (@strUserID,@ItemSerial,@ItemNum)
print 'Kilit basarili'
return
END
END
END
END
END
print 'Kilit basarisiz'
return
END
[/HIDE-THANKS]
KOD 2 :
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ItemUnSealOnPos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ItemUnSealOnPos]
GO
CREATE PROCEDURE [dbo].[ItemUnSealOnPos] (@strUserID varchar(30), @ItemNum int,@ItemPos int )
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNumCheck int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0 and @ItemNum > 0
BEGIN
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @i = (((@ItemPos + 1) * 8) - 7)
SET @ItemNumCheck = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
if @ItemNum = @ItemNumCheck
BEGIN
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
if @ItemSerial <> 0
BEGIN
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if @IsAlreadyLocked > 0
BEGIN
delete from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
print 'UnKilit basarili'
return
END
END
END
END
END
print 'UnKilit basarisiz'
return
END
GO
KOD 3 :
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FetchUserItems]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[FetchUserItems]
GO
CREATE PROCEDURE [dbo].[FetchUserItems] (@strUserID varchar(30))
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNum int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int,@ItemPos as int,@ItemStack as int,@ItemDuration as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0
BEGIN
delete from ListUserItems where strUserID=@strUserID
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @ItemPos = 0
SET @i = (((@ItemPos + 1) * 8) - 7)
while 401 > @i
BEGIN
SET @ItemNum = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
SET @ItemDuration = cast(cast(cast( substring(@InventoryItems, @i+5, 1) as varbinary(1))+cast(substring(@InventoryItems, @i+4, 1) as varbinary(1)) as varbinary(2)) as smallint)
SET @ItemStack = cast(cast(cast( substring(@InventoryItems, @i+7, 1) as varbinary(1))+cast(substring(@InventoryItems, @i+6, 1) as varbinary(1)) as varbinary(2)) as smallint)
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
INSERT INTO ListUserItems (strUserID,ItemPos,ItemNum,ItemSerial,ItemStack,It emDuration,ItemSealed) values (@strUserID,@ItemPos,@ItemNum,@ItemSerial,@ItemSta ck,@ItemDuration,@IsAlreadyLocked)
SET @ItemPos = @ItemPos + 1
SET @i = (((@ItemPos + 1) * 8) - 7)
END
END
select * from ListUserItems where strUserID=@strUserID order by ItemPos
return
END
print 'Item listing fail'
return
END
GO
KOD 4:
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ItemSealInventory]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ItemSealInventory]
GO
CREATE PROCEDURE [dbo].[ItemSealInventory] (@strUserID varchar(30))
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ItemNum int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int,@ItemPos as int,@ItemStack as int,@ItemDuration as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
if @IsRealUser > 0
BEGIN
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @ItemPos = 0
SET @i = (((@ItemPos + 1) * 8) - 7)
while 401 > @i
BEGIN
SET @ItemNum = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if (@IsAlreadyLocked = 0) and (@ItemNum > 0) and (@ItemSerial > 0)
BEGIN
INSERT INTO User_LockedItems (strUserID,ItemSerial,ItemNum) values (@strUserID,@ItemSerial,@ItemNum)
END
SET @ItemPos = @ItemPos + 1
SET @i = (((@ItemPos + 1) * 8) - 7)
END
END
print 'Inventory lock success'
return
END
print 'Inventory lock failed'
return
END
GO
KOD 5 :
CREATE PROCEDURE [dbo].[ItemKilitlePanel] (@strUserID varchar(30), @ItemPos int )AS
BEGIN
SET NOCOUNT ON;
SET @strUserID = ltrim(rtrim(@strUserID))
print 'Islem basladi'
DECLARE @ItemNum int,@ItemSerial bigint,@IsRealUser smallint,@InventoryItems varchar(400),@InventorySerials varchar(400),@i as int,@IsAlreadyLocked as int
select top 1 @IsRealUser=COUNT(strUserID) from USERDATA where strUserId=@strUserID
print 'Kullanici kontrol ediliyor'
if (@IsRealUser > 0)
BEGIN
print 'Kulanici bulundu'
select @InventoryItems=strItem,@InventorySerials=strSeria l from USERDATA where strUserId=@strUserID
if (@InventoryItems is not null) and (@InventorySerials is not null)
BEGIN
SET @i = (((@ItemPos + 1) * 8) - 7)
SET @ItemNum = cast(cast(substring(cast(substring(@InventoryItems , @i,4) as varbinary(4)), 4, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 3, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 2, 1)+substring(cast(substring(@InventoryItems, @i,4) as varbinary(4)), 1, 1) as varbinary(4)) as int)
if @ItemNum > 0
BEGIN
SET @ItemSerial = cast(cast(substring(cast(substring(@InventorySeria ls, @i,8) as varbinary(8)), 8, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 7, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 6, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 5, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 4, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 3, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 2, 1)+substring(cast(substring(@InventorySerials, @i,8) as varbinary(8)), 1, 1) as varbinary(8)) as bigint)
if @ItemSerial <> 0
BEGIN
select top 1 @IsAlreadyLocked = COUNT(strUserID) from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
if @IsAlreadyLocked = 0
BEGIN
INSERT INTO User_LockedItems (strUserID,ItemSerial,ItemNum) values (@strUserID,@ItemSerial,@ItemNum)
print 'Kilit basarili'
return
END
if @IsAlreadyLocked > 0
BEGIN
delete from User_LockedItems where strUserID = @strUserID and ItemSerial = @ItemSerial and ItemNum = @ItemNum
print 'UnKilit basarili'
return
END
END
END
END
END
return
END
GO
Şimdi iste Tablolarımıza geçelim
TABLO 1 :
View hidden content is available for registered users!