[How]Send items to warehouse and ivnetnory?

04/26/2014 14:29 QQers19#1
Hello!
I need query how tu send items to wh/inventory to empty bag and slot ;(
04/26/2014 16:37 nubness#2
You need to go learn your shit and stop begging on elitepvpers. You're asking us to write you some basic SQL queries, and you don't even bother to correct the typo in the thread name.

First, execute these 2:
Code:
USE PS_GameData
GO
CREATE VIEW NewID
AS
SELECT NewID() AS NewID
Code:
USE [PS_GameData]
GO

/****** Object:  UserDefinedFunction [dbo].[ItemUID]    Script Date: 31.07.2013 00:03:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Euphoria Dev Team
-- =============================================
CREATE FUNCTION [dbo].[ItemUID]
()
RETURNS BIGINT
AS
BEGIN
	
	DECLARE @ItemUID BIGINT

	NEWUID:
	SET @ItemUID = ABS(CAST(HASHBYTES('SHA1',CAST((SELECT NewID FROM PS_GameData.dbo.NewID) AS NVARCHAR(MAX))) AS BIGINT))

	IF EXISTS(SELECT * FROM PS_GameData.dbo.CharItems WHERE ItemUID = @ItemUID) OR
	EXISTS(SELECT * FROM PS_GameData.dbo.GuildStoredItems WHERE ItemUID = @ItemUID) OR
	EXISTS(SELECT * FROM PS_GameData.dbo.MarketItems WHERE ItemUID = @ItemUID) OR
	EXISTS(SELECT * FROM PS_GameData.dbo.UserStoredItems WHERE ItemUID = @ItemUID)
	GOTO NEWUID

	RETURN @ItemUID

END
GO
And here's the code to insert an item in a character's inventory:
Code:
USE PS_GameData

DECLARE @CharID INT = 1,
		@ItemID INT = 1001,
		@ItemCount TINYINT = 1,
		@MinBag TINYINT = 1,
		@MinSlot TINYINT = 0

IF (SELECT COUNT(*) FROM CharItems WHERE CharID = @CharID AND Bag != 0) >= 120
BEGIN
	
	PRINT 'The character''s inventory is full.'
	RETURN
	
END

WHILE @MinBag <= 5
BEGIN
	
	WHILE @MinSlot <= 23
	BEGIN
		
		IF NOT EXISTS (SELECT * FROM CharItems WHERE CharID = @CharID AND Bag = @MinBag AND Slot = @MinSlot)
		BEGIN
			
			INSERT INTO CharItems (CharID, ItemID, ItemUID, Type, TypeID, Bag, Slot, Quality, Gem1, Gem2, Gem3, Gem4, Gem5, Gem6, Craftname, Count, Maketime, Maketype, Del)
			VALUES (@CharID, @ItemID, dbo.ItemUID(), @ItemID / 1000, @ItemID % 1000, @MinBag, @MinSlot, (SELECT Quality FROM PS_GameDefs.dbo.Items WHERE ItemID = @ItemID), 0, 0, 0, 0, 0, 0, '00000000000000000000', @ItemCount, GETDATE(), 'S', 0)
			
			IF @@ERROR = 0 AND @@ROWCOUNT = 1
				PRINT 'Item inserted successfully in Bag ' + CAST(@MinBag AS VARCHAR(1)) + ', Slot ' + CAST(@MinSlot AS VARCHAR(2)) + '.'
			ELSE PRINT 'An error occured while attempting to insert the item.'
			
			RETURN
			
		END
		
		SET @MinSlot += 1
		
	END
	
	SET @MinSlot = 0
	SET @MinBag += 1
	
END
For the warehouse part, try to figure it out on your own without begging.
04/26/2014 18:48 QQers19#3
Thanks.
For wh if someone needs
Code:
USE PS_GameData

DECLARE @ServerID TINYINT = 1,
            @UserUID INT = 1,  
	    @ItemID INT = 17215, 
       	    @ItemCount TINYINT = 1,
             @MinSlot TINYINT = 1

		


IF (SELECT COUNT(*) FROM UserStoredItems WHERE UserUID = @UserUID AND Slot != 0) >= 239
BEGIN
	
	PRINT 'The character''s warehouse is full.'
	RETURN
	
END

WHILE @MinSlot <= 239
	BEGIN
		
		IF NOT EXISTS (SELECT * FROM UserStoredItems WHERE UserUID = @UserUID AND Slot = @MinSlot)
		BEGIN
			
			INSERT INTO UserStoredItems (ServerID, UserUID, ItemID, ItemUID, Type, TypeID, Slot, Quality, Gem1, Gem2, Gem3, Gem4, Gem5, Gem6, Craftname, Count, Maketime, Maketype, Del)
			VALUES (@ServerID, @UserUID, @ItemID, dbo.ItemUID(), @ItemID / 1000, @ItemID % 1000, @MinSlot, (SELECT Quality FROM PS_GameDefs.dbo.Items WHERE ItemID = @ItemID), 0, 0, 0, 0, 0, 0, '00000000000000000000', @ItemCount, GETDATE(), 'S', 0)
			
			IF @@ERROR = 0 AND @@ROWCOUNT = 1
				PRINT 'Item inserted successfully in Slot ' + CAST(@MinSlot AS VARCHAR(3)) + '.'
			ELSE PRINT 'An error occured while attempting to insert the item.'
			
			RETURN
			
		END
		
		SET @MinSlot += 1
		
	END
	
	SET @MinSlot = 0
04/27/2014 00:19 nubness#4
For the warehouse inserting PRINT comment, you should cast the @MinSlot variable as a VARCHAR(3) not VARCHAR(2), because it can have 3-digit values.
04/27/2014 10:29 accuface35#5
where istyping the item id to execute the quiry?
04/27/2014 11:11 nubness#6
I think people like you should get banned, seriously. Have you even read the query ? It's in the first lines, in the declaration part.
04/27/2014 16:52 QQers19#7
I try Nubness change you script to insert items in wh. And in Database that is. You' Admin Panel see ItemUID But in game Warehouse is empty.
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]

I try put items on a specific Slot but still wh is empty.
Code:
USE PS_GameData

DECLARE  @ServerID TINYINT = 1,
         @UserUID INT = 1,  
	     @ItemID INT = 17215, 
       	 @ItemCount TINYINT = 1,
         @Slot TINYINT = 1

		


INSERT INTO UserStoredItems (ServerID, UserUID, ItemID, ItemUID, Type, TypeID, Slot, Quality, Gem1, Gem2, Gem3, Gem4, Gem5, Gem6, Craftname, Count, Maketime, Maketype, Del)
VALUES (@ServerID, @UserUID, @ItemID, dbo.ItemUID(), @ItemID / 1000, @ItemID % 1000, @Slot, (SELECT Quality FROM PS_GameDefs.dbo.Items WHERE ItemID = @ItemID), 0, 0, 0, 0, 0, 0, '00000000000000000000', @ItemCount, GETDATE(), 'S', 0)
04/27/2014 16:56 nubness#8
It's best to insert items into inventories and warehouses when the character is offline.

Make sure you're writing in the correct UserUID.
04/27/2014 17:00 QQers19#9
I konw and i did insert offline
UserUID 1 is ok
[Only registered and activated users can see links. Click Here To Register...]
04/27/2014 17:03 nubness#10
Place an item in the warehouse from in game, log off and see how the row looks like. Then make sure your query inserts the same.
04/27/2014 17:11 QQers19#11
Still empty.
[Only registered and activated users can see links. Click Here To Register...]
For you that is work?
04/27/2014 17:12 nubness#12
Did you actually go in game and place an item into your warehouse ?
04/27/2014 17:17 QQers19#13
Yes i did
04/27/2014 17:21 nubness#14
I don't have time to mess with this at the moment, but you should keep trying. Try a basic insert query for the UserStoredItems. Maybe you find where the problem is.
04/27/2014 17:24 QQers19#15
Ok.
Thanks for trying