Register for your free account! | Forgot your password?

You last visited: Today at 22:56

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[RELEASE] ItemSwitch System

Discussion on [RELEASE] ItemSwitch System within the SRO PServer Guides & Releases forum part of the SRO Private Server category.

Reply
 
Old   #1
 
Syloxx's Avatar
 
elite*gold: 56
Join Date: Oct 2013
Posts: 1,165
Received Thanks: 762
[RELEASE] ItemSwitch System

Hey Elitepvpers,

someone asked me to create a Devil Spirit gender switch and i decided to create a generally ItemSwitch query out of it

maybe its usefull for some of you guys.

TABLE:
Code:
CREATE TABLE dbo._RefItemSwitch
(
      [Service] INT NOT NULL
    , RefItemID1 INT NOT NULL
    , RefItemID2 INT NOT NULL
    , RefScroll VARCHAR(129) NOT NULL
);
PROCEDURE:
Code:
/**
version : 1
author : syloxx
created date : 2015-06-07
description : change gender / switch items
return :
0 = There is no error.
-1 = The transaction is in an uncommittable state. Rolling back transaction.
-2 = Slot 13 is emptry.
-3 = Item in slot 13 is not allowed to switch.
-4 = Unknown error.
**/

CREATE PROCEDURE dbo._ItemSwitcher
      @CharID int
    , @Scroll varchar(129)
AS
SET NOCOUNT ON;
SET XACT_ABORT ON;

DECLARE @ReturnValue int
    , @ItemID bigint
    , @OldRefItemID int
    , @NewRefItemID1 int
    , @NewRefItemID2 int
    , @NewRefItemID int

IF XACT_STATE() = -1
BEGIN
    SET @ReturnValue = -1;
    GOTO ErrorHandler;
END
BEGIN TRY
    /**_# Get ItemID of item in slot 13.*/
    SELECT @ItemID = INV.ItemID
        , @OldRefItemID = I.RefItemID
    FROM dbo._Inventory INV WITH (NOLOCK)
        JOIN _Items I WITH (NOLOCK) ON INV.ItemID = I.ID64
    WHERE INV.CharID = @CharID
    AND INV.Slot = 13;
    
    /**_# Check if slot 13 is empty.*/
    IF @OldRefItemID IS NULL OR @OldRefItemID = 0
    BEGIN
        SET @ReturnValue = -2;
        GOTO ErrorHandler;
    END
    
    /**_# Get all possible ItemIDs.*/
    SELECT TOP 1 @NewRefItemID1 = RefItemID1
        , @NewRefItemID2 = RefItemID2
    FROM _RefItemSwitch WITH (NOLOCK)
    WHERE Service = 1
    AND (RefItemID1 = @OldRefItemID OR RefItemID2 = @OldRefItemID)
    AND RefScroll = RefScroll
    
    /**_# Check if item is allowed to switch.*/
    IF @NewRefItemID1 IS NULL OR @NewRefItemID2 IS NULL OR @NewRefItemID1 = 0 OR @NewRefItemID2 = 0
    BEGIN
        SET @ReturnValue = -3;
        GOTO ErrorHandler;
    END
    
    /**_# Set the new ItemID.*/
    SET @NewRefItemID = CASE
                            WHEN @NewRefItemID1 = @OldRefItemID THEN @NewRefItemID2
                            WHEN @NewRefItemID2 = @OldRefItemID THEN @NewRefItemID1
                            ELSE @OldRefItemID
                        END
    
    /**_# Debug for an unknown error.*/
    IF @NewRefItemID = @OldRefItemID
    BEGIN
        SET @ReturnValue = -4;
        GOTO ErrorHandler;
    END
    
    BEGIN TRANSACTION;
    
    /**_# Finally switch the Item.*/
    UPDATE _Items
    SET RefItemID = @NewRefItemID
    WHERE ID64 = @ItemID
    
    COMMIT TRANSACTION;
END TRY
BEGIN CATCH
        GOTO ErrorHandler;
END CATCH;

RETURN 0;

ErrorHandler:
IF XACT_STATE() <> 0
    ROLLBACK TRANSACTION;

DECLARE @CharName varchar(17);

SELECT @CharName = CharName16
FROM _Char WITH (NOLOCK)
WHERE CharID = @CharID;

EXEC _ADD_ITEM_EXTERN @CharName, @Scroll, 1, 0;

RETURN @ReturnValue;
TUTORIAL:
Code:
1) fill table _RefItemSwitch with Service (0 = disabled, 1 = enabled), RefItemID1 (male for example), RefItemID2 (female for example), RefScroll (codename of the scroll).
2) create a new scroll i wont explain how to do it
3) paste the function to trigger this procedure in _AddLogChar
Syloxx is offline  
Thanks
8 Users
Old 07/06/2015, 17:50   #2
 
Justin1337*'s Avatar
 
elite*gold: 480
Join Date: Jan 2012
Posts: 655
Received Thanks: 579
Cool, thanks Syloxx. =)
Justin1337* is offline  
Old 07/26/2017, 15:18   #3

 
R3D*'s Avatar
 
elite*gold: 1400
Join Date: May 2011
Posts: 1,200
Received Thanks: 740
It is good to see something useful that may help the beginners in this community! Good Job!
R3D* is offline  
Old 07/26/2017, 19:01   #4
 
Emperix's Avatar
 
elite*gold: 0
Join Date: Jul 2017
Posts: 34
Received Thanks: 7
Thanks alot
Emperix is offline  
Old 07/26/2017, 22:09   #5
 
Justin1337*'s Avatar
 
elite*gold: 480
Join Date: Jan 2012
Posts: 655
Received Thanks: 579
Quote:
Originally Posted by Acs' View Post
It is good to see something useful that may help the beginners in this community! Good Job!
Quote:
Originally Posted by Emperix View Post
Thanks alot
07/06/2015, 08:00 glad to see i am not the only one going blind. XD
Justin1337* is offline  
Old 07/27/2017, 02:41   #6
 
Worshiper's Avatar
 
elite*gold: 0
Join Date: May 2017
Posts: 882
Received Thanks: 159
Thanks For it its good idea
Worshiper is offline  
Old 07/27/2017, 07:17   #7

 
R3D*'s Avatar
 
elite*gold: 1400
Join Date: May 2011
Posts: 1,200
Received Thanks: 740
Quote:
Originally Posted by Justin1337* View Post
07/06/2015, 08:00 glad to see i am not the only one going blind. XD
I already realized that when this guy @Emperix has done a replay. xD
R3D* is offline  
Old 07/27/2017, 13:20   #8
 
Emperix's Avatar
 
elite*gold: 0
Join Date: Jul 2017
Posts: 34
Received Thanks: 7
Quote:
Originally Posted by Justin1337* View Post
07/06/2015, 08:00 glad to see i am not the only one going blind. XD
lol it had no comments so i thought its new lol
Emperix is offline  
Reply


Similar Threads Similar Threads
[Release] Taiwan Server files [New Global Chat,new party system,new guild system]
10/24/2012 - SRO PServer Guides & Releases - 80 Replies
those files used by creddy online :) USE IN YOUR OWN RISK server files --removed--- DB http://www.mediafire.com/?3ocz3a0adsazsf6



All times are GMT +2. The time now is 22:56.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.