Add items to characters

Results 1 to 8 of 8
  1. #1
    Proficient Member Hikaru_K is offline
    MemberRank
    Mar 2006 Join Date
    VenezuelaLocation
    186Posts

    Add items to characters

    Season 4.9 files

    Hi, I'm testing the GM commands to add some items to the character

    I'm doing it this way:

    /giveitem admin 134481937 1
    (this is some Hanna wig)

    the confirmation appears and I confirm it typing /y

    the item has been granted it says... but where does this item goes?? to my room? because I cannot see it anywhre inside my room.

    Sounds likes a dumb question, but, does this command really work?

    thanks


  2. #2
    Deny everything. Tsukasa is offline
    MemberRank
    Jun 2005 Join Date
    Net SlumLocation
    558Posts

    Re: Add items to characters

    Yes, the command really works.

    It does, however, rely on the mailing system, which is broken in the database you can get from here. Therefore mailing items, and in effect gifting items through GM commands, does not work.

  3. #3
    Proficient Member Hikaru_K is offline
    MemberRank
    Mar 2006 Join Date
    VenezuelaLocation
    186Posts

    Re: Add items to characters

    Thanks Tsukasa

    Now then, there has to be a stored procedure to add the items right?

    or do I have to add them manually in Pangya_Item_WareHouse?

  4. #4
    Deny everything. Tsukasa is offline
    MemberRank
    Jun 2005 Join Date
    Net SlumLocation
    558Posts

    Re: Add items to characters

    Well, basically you have to add them manually. If you like you can make it a little easier by using this procedure:

    Spoiler:
    For consumables & equipment:
    Code:
    USE [Pangya_S4_TH]
    GO
    
    SET ANSI_NULLS ON
    GO
    
    SET QUOTED_IDENTIFIER ON
    GO
    
    
    CREATE PROC [dbo].[TSU_AddItemToUser] (
    	@user_id	varchar(32),
    	@item_id int
    )
    AS
    
    BEGIN
    	DECLARE @user_idx int
    	
    	SELECT @user_idx = [UID] FROM [Pangya_Member_Info]
    	WHERE [userid] = @user_id
    	
    	IF @@ROWCOUNT = 1
    	BEGIN
    		SELECT [TYPEID] AS [Item ID], [NAME] AS [Item Name] FROM [PANGYA_ITEM_TYPELIST]
    		WHERE TYPEID = @item_id
    		
    		IF @@ROWCOUNT = 1
    		BEGIN
    			INSERT INTO Pangya_Item_WareHouse ( [UID], [typeid], [valid], [regdate] )
    			VALUES ( @user_idx, @item_id, 1, GETDATE())
    			
    			RETURN @@ERROR
    		END
    		ELSE
    		BEGIN
    			PRINT N'Item does not exist!'
    			RETURN 1
    		END
    	END
    	ELSE
    	BEGIN
    		PRINT N'User does not exist!'
    		RETURN 1
    	END
    END
    GO
    For cards:
    Code:
    USE [Pangya_S4_TH]
    GO
    
    SET ANSI_NULLS ON
    GO
    
    SET QUOTED_IDENTIFIER ON
    GO
    
    
    /**************************************************
     * TSU_AddCardToUser                              *
     * Last Update: 2010-12-19                        *
     *                                                *
     * Adds a card from the published cardsets to a   *
     * user's inventory.                              *
     **************************************************/
    
    CREATE PROC [dbo].[TSU_AddCardToUser] (
    	@user_id varchar(32),
    	@card_id int
    )
    AS
    BEGIN
    	DECLARE @user_idx int
    	DECLARE @card_type int
    	
    	SELECT @user_idx = [UID] FROM [Pangya_Member_Info]
    	WHERE [userid] = @user_id
    	
    	IF @@ROWCOUNT = 1
    	BEGIN
    		SELECT TOP 1 @card_type = [card_type] FROM [TA_CARDPACK_ITEM]
    		WHERE CARD_TYPEID = @card_id
    		
    		IF @@ROWCOUNT = 1
    		BEGIN
    			INSERT INTO TD_CARD_USRS ( [UID], [CARD_TYPEID], [CARD_TYPE], [QTY], [USE_YN] )
    			VALUES ( @user_idx, @card_id, @card_type, 1, N'Y')
    			
    			RETURN @@ERROR
    		END
    		ELSE
    		BEGIN
    			PRINT N'Card does not exist!'
    			RETURN 1
    		END
    	END
    	ELSE
    	BEGIN
    		PRINT N'User does not exist!'
    		RETURN 1
    	END
    END
    GO


    Please note that the user has to logout/login for the items to appear and that they have to be registered in the database.
    Last edited by Tsukasa; 08-01-11 at 04:21 PM. Reason: If we're already at it, let's add cards too...

  5. #5
    Account Upgraded | Title Enabled! mrNickname is offline
    MemberRank
    May 2005 Join Date
    Isolated TowerLocation
    270Posts

    Re: Add items to characters

    Very nice Tsusaka, so you're a SQL programmer. Btw is it possible to inject more then one item at once? It looks like will need a different script...

    Well because I like to create a list of valid itemIDs and inject to userID. One execution and access to all items without all that hassle find ID and inject or buy it in shop one by one etc.

  6. #6
    Deny everything. Tsukasa is offline
    MemberRank
    Jun 2005 Join Date
    Net SlumLocation
    558Posts

    Re: Add items to characters

    Quote Originally Posted by mrNickname View Post
    Well because I like to create a list of valid itemIDs and inject to userID. One execution and access to all items without all that hassle find ID and inject or buy it in shop one by one etc.
    Someone asked me that very question once and I wrote this short snippet to add all available items from the database (excluding cards) to a user's warehouse:

    Spoiler:
    Code:
    USE [Pangya_S4_TH]
    GO
    
    DECLARE @cnt int
    DECLARE @cntMax int
    
    SELECT @cnt = 1
    SELECT @cntMax = count(TYPEID) FROM PANGYA_ITEM_TYPELIST
    
    DECLARE @typeid int
    DECLARE @uid int
    
    -- CHANGE THIS VALUE TO THE CORRESPONING UID --
    SET @uid = 1
    
    WHILE @cnt <= @cntMax
    
    BEGIN
    	WITH InsertLoop AS (
    	SELECT row_number() OVER (ORDER BY TYPEID) AS Row,*
    		FROM  PANGYA_ITEM_TYPELIST
    		)
    		
    	SELECT @typeid = typeid FROM InsertLoop WHERE Row=@cnt
    
    	INSERT INTO Pangya_Item_WareHouse ([UID], [typeid], [valid], [regdate]) VALUES (@uid, @typeid, 1, CURRENT_TIMESTAMP)
    	--PRINT N'Add item' + str(@typeid) + ' to user' + str(@uid)
    
    	SELECT @cnt = @cnt+1
    END


    I can only advise people not to do this but in the end it's your decision. Please note that this query is pretty inefficient since I'm not using transactions, so the execution will probably take a while.

  7. #7
    Account Upgraded | Title Enabled! mrNickname is offline
    MemberRank
    May 2005 Join Date
    Isolated TowerLocation
    270Posts

    Re: Add items to characters

    That one little simple script that is so powerful! O.O

    Full access to inventory, in exchange of more RAM and CPU usage and possibly triple or quadruple the bandwidth to load the necessary. Stability seems stable thought. Biiig thx Tsusaka xD

  8. #8
    Proficient Member Hikaru_K is offline
    MemberRank
    Mar 2006 Join Date
    VenezuelaLocation
    186Posts

    Re: Add items to characters

    Since I executed this script I cannot buy certain items like the clubs. I deleted some items but still cannot buy any.



Advertisement