حفظ بياناتي ؟

1/01/2023

22/05/2024_hema

22/05/2024_hema

END_shaher_01/12/2024

Ahmed_k_nayel_01_12_2024

END_02/12/2024

END 30/12/2024

END 06/12/2024

END 28/12/2024

END 30/12/2024_waiting

END 30/02/2025_Belal

END 06/01/2025

END 12/01/2025

END _14/01/2025_Karuoke

END _14/01/2025_Karuoke

25/01/2022

QueenSro_01_10_2024

Ahmed_k_nayel_01_12_2024

ibrahim_END 07/1212024

END 30/12/2024

END 12/01/2025

END _14/01/2025_Karuoke

 الـجـروب الـرسـمى لـلـمـنـتـدى FaceBook | Official Group 



قسم الاسئلة و الاستفسارات لعمل السيرفرات الخاصة [ قسم خاص لأسئلة واستفسارات عمل السيرفرات الخاصة ] [ يرجى الالتزام بقوانين قسم الأسئلة والاستفسارات ]

موضوع مغلق
 
أدوات الموضوع انواع عرض الموضوع
قديم 14-04-2017, 11:45 AM   #1

MORJANA
عضو مميز



الصورة الرمزية MORJANA


• الانـتـسـاب » Mar 2011
• رقـم العـضـويـة » 84781
• المشـــاركـات » 743
• الـدولـة » EGYPT
• الـهـوايـة » Helping People
• اسـم الـسـيـرفـر » Private Server
• الـجـنـس » Male
• نقـاط التقييم » 48
MORJANA صـاعـد

MORJANA غير متواجد حالياً


إرسال رسالة عبر Yahoo إلى MORJANA

افتراضي دمج



جرب كده


كود:
	-- RemoverPREMIUM Scroll 
		if(@JobID = '44800') -- Remove prem Edited By MORJANA
		begin
         DELETE FROM SRO_VT_SHARD.dbo._TimedJob
WHERE  CharID = @CharID
AND   JobID in (5412,24487,36754,9278,41906,31104,59696,60441,60236,59666,35567,59861)
		end
جرب كده

كود:
	

	-- RemoverPREMIUM Scroll 
		if(@JobID = '59861') -- Remove prem coded by Yui
		begin
         DELETE FROM SRO_VT_SHARD.dbo._TimedJob
WHERE  CharID = @CharID
AND   JobID in (5412,24487,36754,9278,41906,31104,59696,60441,60236,59666,35567,59861)
		end
من الـ SHARD هتمسح اللي موجود في البروسيدر ده __AUTO_EQUIP_GEAR
و تحط ده مكانه

كود:
USE [SRO_VT_SHARD]
GO
/****** Object:  StoredProcedure [dbo].[__AUTO_EQUIP_GEAR]    Script Date: 14/4/2017 10:56:18 AM ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE [dbo].[__AUTO_EQUIP_GEAR]
	@CharName AS VARCHAR(64),
	@EQPlus AS TINYINT
AS	
	-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	-- @@@ BEGIN: SETTINGS
	
	-- CHANGE THIS! -- CHANGE THIS! -- CHANGE THIS! (if needed)

	-- (Represent ITEM_EU_TSTAFF_09_C_RARE), change as you need it
	DECLARE @GearSuffix VARCHAR(16) = 'C_RARE'

	-- @@@ END: SETTINGS
	-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

	SET XACT_ABORT ON
	SET NOCOUNT ON

	-- Check if character exist
	DECLARE	@isCharExist TINYINT = 0

	PRINT 'Validating Character...'
	-- EXEC @isCharExist = [_IsExistingCharName] @CharNameToCheck = @CharName
	SELECT @isCharExist = COUNT(CharID) FROM [_Char] WITH (NOLOCK) WHERE CharName16 = @CharName
	IF (@isCharExist = 0)
	BEGIN
		RAISERROR('Character: %s does not exist. Sequence canceled!', 1, 16, @CharName)
		RETURN -1
	END

	-- Check character and account related information (In relation with SRO_VT_ACCOUNT)
	DECLARE @CharID INT = 0
	DECLARE @RefCharID INT = 0
	DECLARE @UserJID INT = 0
	DECLARE @AccountName VARCHAR(32) = ''

	-- Check if character assigned to Account ID
	PRINT 'Validating Account ID...'
	SELECT @CharID = CharID, @RefCharID = RefObjID FROM [_Char] WITH (NOLOCK) WHERE CharName16 = @CharName
	SELECT @UserJID = UserJID FROM [_User] WITH (NOLOCK) WHERE CharID = @CharID
	IF (@UserJID IS NULL OR @UserJID = 0)
	BEGIN
		RAISERROR('Account ID does not exist, or character: %s is not assigned to any user accounts. Sequence canceled!', 1, 16, @CharName)
		RETURN -2
	END

	-- Check character gender and race
	DECLARE @CharGender VARCHAR(1) = ''
	DECLARE @CharRace VARCHAR(2) = ''

	PRINT 'Validating race and gender...'
	SET @CharRace = CASE
		WHEN (@RefCharID BETWEEN 1907 AND 1919) OR (@RefCharID BETWEEN 1920 AND 1932) THEN 'CH'	-- Chinese (vSRO/BR110)
		WHEN (@RefCharID BETWEEN 14875 AND 14887) OR (@RefCharID BETWEEN 14888 AND 14900) THEN 'EU'	-- Euro (vSRO)
		WHEN (@RefCharID BETWEEN 14717 AND 14729) OR (@RefCharID BETWEEN 14730 AND 14742) THEN 'EU'	-- Euro (BR110)
		ELSE NULL END
	SET @CharGender = CASE
		WHEN (@RefCharID BETWEEN 1907 AND 1919) OR (@RefCharID BETWEEN 14875 AND 14887) OR (@RefCharID BETWEEN 14717 AND 14729) THEN 'M'
		WHEN (@RefCharID BETWEEN 1920 AND 1932) OR (@RefCharID BETWEEN 14888 AND 14900) OR (@RefCharID BETWEEN 14730 AND 14742) THEN 'W'
		ELSE NULL END
	PRINT 'Race code is: ' + @CharRace + ', gender code is: ' + @CharGender + '.'
	IF (@CharRace IS NULL OR @CharGender IS NULL)
	BEGIN
		RAISERROR('Invalid character race and gender info. Sequence canceled!', 1, 16, @CharName)
		RETURN -3
	END

	-- Check character level for item degree
	DECLARE @EQDegree VARCHAR(2) = ''
	DECLARE @CurLevel TINYINT = 0

	SET @CurLevel = CASE
		WHEN @CharRace = 'CH' THEN (SELECT CurLevel FROM [_Char] WITH (NOLOCK) WHERE CharID = @CharID) + 1
		WHEN @CharRace = 'EU' THEN (SELECT TOP (1) [Level] FROM [_CharSkillMastery] WITH (NOLOCK) WHERE CharID = @CharID ORDER BY [Level] DESC) + 1
		ELSE 0 END
	SET @EQDegree = CASE
		WHEN @CurLevel < 13 THEN '01'
		WHEN @CurLevel < 21 THEN '02'
		WHEN @CurLevel < 29 THEN '03'
		WHEN @CurLevel < 37 THEN '04'
		WHEN @CurLevel < 47 THEN '05'
		WHEN @CurLevel < 57 THEN '06'
		WHEN @CurLevel < 69 THEN '07'
		WHEN @CurLevel < 81 THEN '08'
		WHEN @CurLevel < 92 THEN '09'
		WHEN @CurLevel < 101 THEN '10'
		ELSE '11' END

	PRINT 'Character/Mastery Level: ' + CAST(@CurLevel AS VARCHAR(3)) + ', degree: ' + @EQDegree + '. (Level are current +1)'

	-- Setting up equipment
	-- Gears
	DECLARE @CodeNameHelm		VARCHAR(64) = ''
	DECLARE @CodeNameMail		VARCHAR(64) = ''
	DECLARE @CodeNameShoulder	VARCHAR(64) = ''
	DECLARE @CodeNameGauntlet	VARCHAR(64) = ''
	DECLARE @CodeNamePants		VARCHAR(64) = ''
	DECLARE @CodeNameBoots		VARCHAR(64) = ''
	DECLARE @RefHelmID		INT = 0
	DECLARE @RefMailID		INT = 0
	DECLARE @RefShoulderID		INT = 0
	DECLARE @RefGauntletID		INT = 0
	DECLARE @RefPantsID		INT = 0
	DECLARE @RefBootsID		INT = 0
	DECLARE @RefHelmLinkID		INT = 0
	DECLARE @RefMailLinkID		INT = 0
	DECLARE @RefShoulderLinkID	INT = 0
	DECLARE @RefGauntletLinkID	INT = 0
	DECLARE @RefPantsLinkID		INT = 0
	DECLARE @RefBootsLinkID		INT = 0

	-- Accessories
	DECLARE @CodeNameEarring	VARCHAR(64) = ''
	DECLARE @CodeNameNecklace	VARCHAR(64) = ''
	DECLARE @CodeNameRing		VARCHAR(64) = ''
	DECLARE @RefEarringID		INT = 0
	DECLARE @RefNecklaceID		INT = 0
	DECLARE @RefRingID		INT = 0
	DECLARE @RefEarringLinkID	INT = 0
	DECLARE @RefNecklaceLinkID	INT = 0
	DECLARE @RefRingLinkID		INT = 0

	-- Weapon and Shield
	DECLARE @CodeNameWeapon		VARCHAR(64) = ''
	DECLARE @CodeNameShield		VARCHAR(64) = ''
	DECLARE @RefWeaponID		INT = 0
	DECLARE @RefShieldID		INT = 0
	DECLARE @RefWeaponLinkID	INT = 0
	DECLARE @RefShieldLinkID	INT = 0

	-- Check for current equipped weapon/shield
	PRINT 'Validating equipped weapon...'
	DECLARE @OldWeaponID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot =6)
	IF (@OldWeaponID IS NULL OR @OldWeaponID = 0)
	BEGIN
		RAISERROR('Character: %s is not wearing any weapon. Sequence canceled!', 10, 1, @CharName)
		RETURN -4
	END
	DECLARE @RefOldWeaponID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldWeaponID)
	DECLARE @WPClass VARCHAR(16) = ''
	SELECT @WPClass = 
		CASE
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 2 THEN 'SWORD'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 3 THEN 'BLADE'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 4 THEN 'SPEAR'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 5 THEN 'TBLADE'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 6 THEN 'BOW'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 7 THEN 'SWORD'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 8 THEN 'TSWORD'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 9 THEN 'AXE'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 10 THEN 'DARKSTAFF'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 11 THEN 'TSTAFF'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 12 THEN 'CROSSBOW'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 13 THEN 'DAGGER'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 14 THEN 'HARP'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 15 THEN 'STAFF'
		END
	FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND ID = @RefOldWeaponID ORDER BY TypeID4 ASC
	PRINT 'Weapon is: ' + @WPClass + '.'

	-- Set no shield by default, if the weapon used is 1H, then add shield automatically.
	PRINT 'Checking if character is using shield...'
	DECLARE @useShield TINYINT = 0
	IF (@WPClass = 'SWORD' OR @WPClass = 'BLADE' OR @WPClass = 'STAFF' OR @WPClass = 'DARKSTAFF')
	BEGIN
		PRINT '- 1H weapon is used, new shield will be added.'
		SET @useShield = 1
	END

	-- Item codes (trailing codes are from itemSuffix settings above)
	PRINT 'Validating current gear...'
	DECLARE @OldGearID INT = (SELECT TOP (1) ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND ItemID > 0 AND Slot BETWEEN 0 AND 5)
	IF (@OldGearID IS NULL OR @OldGearID = 0)
	BEGIN
		RAISERROR('Character: %s is not wearing any armor. Sequence canceled!', 10, 1, @CharName)
		RETURN -5
	END
	DECLARE @RefOldGearID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldGearID)
	DECLARE @EQClass VARCHAR(10)
	SELECT @EQClass = 
		CASE
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND (TypeID3 = 1 OR TypeID3 = 9) THEN 'CLOTHES'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND (TypeID3 = 2 OR TypeID3 = 10) THEN 'LIGHT'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND (TypeID3 = 3 OR TypeID3 = 11) THEN 'HEAVY'
		END
	FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND ID = @RefOldGearID ORDER BY TypeID4 ASC
	PRINT 'Gear type is: ' + @EQClass + '.'

	PRINT 'Validating current equipment type...'
	DECLARE @OldHelmID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 0)
	DECLARE @RefOldHelmID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldHelmID)
	DECLARE @OldMailID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 1)
	DECLARE @RefOldMailID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldMailID)
	DECLARE @OldShoulderID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 2)
	DECLARE @RefOldShoulderID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldShoulderID)
	DECLARE @OldGauntletID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 3)
	DECLARE @RefOldGauntletID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldGauntletID)
	DECLARE @OldPantsID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 4 )
	DECLARE @RefOldPantsID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldPantsID)
	DECLARE @OldBootsID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 5)
	DECLARE @RefOldBootsID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldBootsID)
	DECLARE @OldShieldID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 7)
	DECLARE @RefOldShieldID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldShieldID)
	DECLARE @OldEarringID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 9)
	DECLARE @RefOldEarringID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldEarringID)
	DECLARE @OldNecklaceID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 10)
	DECLARE @RefOldNecklaceID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldNecklaceID)
	DECLARE @OldLRingID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 11)
	DECLARE @RefOldLRingID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldLRingID)
	DECLARE @OldRRingID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 12)
	DECLARE @RefOldRRingID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldRRingID)

	-- Check if old equipment are Egy or Roc set
	DECLARE @useHelm TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldHelmID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useMail TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldMailID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useShoulder TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldShoulderID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useGauntlet TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldGauntletID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @usePants TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldPantsID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useBoots TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldBootsID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useWeapon TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldWeaponID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	IF (@useShield = 1)
	BEGIN
		SET @useShield = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldShieldID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	END
	DECLARE @useEarring TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldEarringID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useNecklace TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldNecklaceID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useLRing TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldLRingID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useRRing TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldRRingID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END

	PRINT 'Setting up item codenames...'
	-- Gears
	SET @CodeNameHelm	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_HA_' + @GearSuffix
	SET @CodeNameMail	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_BA_' + @GearSuffix
	SET @CodeNameShoulder	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_SA_' + @GearSuffix
	SET @CodeNameGauntlet	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_AA_' + @GearSuffix
	SET @CodeNamePants	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_LA_' + @GearSuffix
	SET @CodeNameBoots	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_FA_' + @GearSuffix

	-- Accessories
	SET @CodeNameEarring	= 'ITEM_' + @CharRace + '_EARRING_' + @EQDegree + '_' + @GearSuffix
	SET @CodeNameNecklace	= 'ITEM_' + @CharRace + '_NECKLACE_' + @EQDegree + '_' + @GearSuffix
	SET @CodeNameRing	= 'ITEM_' + @CharRace + '_RING_' + @EQDegree + '_' + @GearSuffix

	-- Weapon and Shield
	SET @CodeNameWeapon	= 'ITEM_' + @CharRace + '_' + @WPClass + '_' + @EQDegree + '_' + @GearSuffix
	SET @CodeNameShield	= 'ITEM_' + @CharRace + '_SHIELD_' + @EQDegree + '_' + @GearSuffix

	-- Get Reference ID and Link ID
	PRINT 'Getting item reference ID and link...'
	-- Gears
	SELECT @RefHelmID = ID, @RefHelmLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameHelm
	SELECT @RefMailID = ID, @RefMailLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameMail
	SELECT @RefShoulderID = ID, @RefShoulderLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameShoulder
	SELECT @RefGauntletID = ID, @RefGauntletLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameGauntlet
	SELECT @RefPantsID = ID, @RefPantsLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNamePants
	SELECT @RefBootsID = ID, @RefBootsLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameBoots

	-- Accessories
	SELECT @RefEarringID = ID, @RefEarringLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameEarring
	SELECT @RefNecklaceID = ID, @RefNecklaceLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameNecklace
	SELECT @RefRingID = ID, @RefRingLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameRing

	-- Weapon and Shield
	SELECT @RefWeaponID = ID, @RefWeaponLinkID = Link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameWeapon
	SELECT @RefShieldID = ID, @RefShieldLinkID = Link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameShield

	IF (
		@RefHelmID IS NULL OR @RefHelmID = 0 OR 
		@RefMailID IS NULL OR @RefMailID = 0 OR 
		@RefShoulderID IS NULL OR @RefShoulderID = 0 OR 
		@RefGauntletID IS NULL OR @RefGauntletID = 0 OR 
		@RefPantsID IS NULL OR @RefPantsID = 0 OR 
		@RefBootsID IS NULL OR @RefBootsID = 0 OR 
		@RefEarringID IS NULL OR @RefEarringID = 0 OR 
		@RefNecklaceID IS NULL OR @RefNecklaceID = 0 OR 
		@RefRingID IS NULL OR @RefRingID = 0 OR
		@RefWeaponID IS NULL OR @RefWeaponID = 0 OR
		@RefShieldID IS NULL OR @RefShieldID = 0
	)
	BEGIN
		RAISERROR('Invalid item reference ID, check item codename (degree parameter or item suffix setting). Sequence canceled!', 1, 16)
		RETURN -6
	END
	IF (
		@RefHelmLinkID IS NULL OR @RefHelmLinkID = 0 OR 
		@RefMailLinkID IS NULL OR @RefMailLinkID = 0 OR 
		@RefShoulderLinkID IS NULL OR @RefShoulderLinkID = 0 OR 
		@RefGauntletLinkID IS NULL OR @RefGauntletLinkID = 0 OR 
		@RefPantsLinkID IS NULL OR @RefPantsLinkID = 0 OR 
		@RefBootsLinkID IS NULL OR @RefBootsLinkID = 0 OR 
		@RefEarringLinkID IS NULL OR @RefEarringLinkID = 0 OR 
		@RefNecklaceLinkID IS NULL OR @RefNecklaceLinkID = 0 OR 
		@RefRingLinkID IS NULL OR @RefRingLinkID = 0 OR 
		@RefWeaponLinkID IS NULL OR @RefWeaponLinkID = 0 OR 
		@RefShieldLinkID IS NULL OR @RefShieldLinkID = 0
	)
	BEGIN
		RAISERROR('Invalid link reference ID, check item codename (degree parameter or item suffix setting). Sequence canceled!', 1, 16)
		RETURN -7
	END

	-- Get durability for 'Data'
	PRINT 'Getting items durability information...'
	DECLARE @DuraHelm INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefHelmLinkID)
	DECLARE @DuraMail INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefMailLinkID)
	DECLARE @DuraShoulder INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefShoulderLinkID)
	DECLARE @DuraGauntlet INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefGauntletLinkID)
	DECLARE @DuraPants INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefPantsLinkID)
	DECLARE @DuraBoots INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefBootsLinkID)
	DECLARE @DuraWeapon INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefWeaponLinkID)
	DECLARE @DuraShield INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefShieldLinkID)

	-- Sequence begin
	BEGIN TRANSACTION

		-- Add new equipment to equipment slots
		PRINT 'Adding new items...'
		DECLARE @HelmItemID64 BIGINT = 0
		DECLARE @MailItemID64 BIGINT = 0
		DECLARE @ShoulderItemID64 BIGINT = 0
		DECLARE @GauntletItemID64 BIGINT = 0
		DECLARE @PantsItemID64 BIGINT = 0
		DECLARE @BootsItemID64 BIGINT = 0

		DECLARE @EarringItemID64 BIGINT = 0
		DECLARE @NecklaceItemID64 BIGINT = 0
		DECLARE @RingLItemID64 BIGINT = 0
		DECLARE @RingRItemID64 BIGINT = 0

		DECLARE @WeaponItemID64 BIGINT = 0
		DECLARE @ShieldItemID64 BIGINT = 0

		-- Helm
		IF (@useHelm = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 0
			EXEC @HelmItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 0, @RefHelmID, @DuraHelm
			IF (@HelmItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -8
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @HelmItemID64
			PRINT '- Helm equipped.'
		END

		-- Chest
		IF (@useMail = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 1
			EXEC @MailItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 1, @RefMailID, @DuraMail
			IF (@MailItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -9
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @MailItemID64
			UPDATE [_Items] SET MagParamNum = 5, MagParam5 = 901943132463 WHERE ID64 = @MailItemID64
			PRINT '- Chest equipped.'
		END

		-- Shoulder
		IF (@useShoulder = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 2
			EXEC @ShoulderItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 2, @RefShoulderID, @DuraShoulder
			IF (@ShoulderItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -10
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @ShoulderItemID64
			PRINT '- Shoulder equipped.'
		END

		-- Gauntlet
		IF (@useGauntlet = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 3
			EXEC @GauntletItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 3, @RefGauntletID, @DuraGauntlet
			IF (@GauntletItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -11
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @GauntletItemID64
			PRINT '- Gauntlet equipped.'
		END

		-- Pants
		IF (@usePants = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 4
			EXEC @PantsItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 4, @RefPantsID, @DuraPants
			IF (@PantsItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -12
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @PantsItemID64
			PRINT '- Pants equipped.'
		END

		-- Boots
		IF (@useBoots = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 5
			EXEC @BootsItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 5, @RefBootsID, @DuraBoots
			IF (@BootsItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -13
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @BootsItemID64
			PRINT '- Boots equipped.'
		END

		-- Earring
		IF (@useEarring = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 9
			EXEC @EarringItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 9, @RefEarringID, 0
			IF (@EarringItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -14
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @EarringItemID64
			UPDATE [_Items] SET MagParamNum = 9, MagParam8 = 214748365115, MagParam9 = 214748365139 WHERE ID64 = @EarringItemID64
			PRINT '- Earring equipped.'
		END

		-- Necklace
		IF (@useNecklace = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 10
			EXEC @NecklaceItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 10, @RefNecklaceID, 0
			IF (@NecklaceItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -15
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @NecklaceItemID64
			UPDATE [_Items] SET MagParamNum = 8, MagParam8 = 47244640547 WHERE ID64 = @NecklaceItemID64
			PRINT '- Necklace equipped.'
		END

		-- Left Ring
		IF (@useLRing = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 11
			EXEC @RingLItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 11, @RefRingID, 0
			IF (@RingLItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -16
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @RingLItemID64
			UPDATE [_Items] SET MagParamNum = 9, MagParam8 = 107374182751, MagParam9 = 107374182727  WHERE ID64 = @RingLItemID64
			PRINT '- Left Ring equipped.'
		END

		-- Right Ring
		IF (@useRRing = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 12
			EXEC @RingRItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 12, @RefRingID, 0
			IF (@RingRItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -17
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @RingRItemID64
			UPDATE [_Items] SET MagParamNum = 9, MagParam8 = 107374182751, MagParam9 = 107374182727  WHERE ID64 = @RingRItemID64
			PRINT '- Right Ring equipped.'
		END

		-- Weapon
		IF (@useWeapon = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 6
			EXEC @WeaponItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 6, @RefWeaponID, @DuraWeapon
			IF (@WeaponItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -18
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 6, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 429496729714, MagParam5 = 257698037862, MagParam6 = 12884902155, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @WeaponItemID64
			PRINT '- Weapon equipped.'
		END

		-- Shield
		IF (@useShield = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 7
			EXEC @ShieldItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 7, @RefShieldID, @DuraShield
			IF (@ShieldItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -19
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 429496729726, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @ShieldItemID64
			PRINT '- Shield equipped.'
		END

		-- Arrow/Bolt
		IF (@WPClass = 'BOW' OR @WPClass = 'CROSSBOW')
		BEGIN
			DECLARE @ArrowItemID64 BIGINT
			DECLARE @RefArrowID INT = CASE
				WHEN @WPClass = 'BOW' THEN (SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = 'ITEM_MALL_QUIVER')
				WHEN @WPClass = 'CROSSBOW' THEN (SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = 'ITEM_MALL_BOLT')
			END
		
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 7
			EXEC @ArrowItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 7, @RefArrowID, 10000
			IF (@ArrowItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP] (Arrow/Bolt), canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -19
			END
			PRINT '- Arrow/Bolt equipped.'
		END

	COMMIT TRANSACTION
	PRINT 'Sequence complete.'

RETURN -1
-- EOF
من الـ SHARD هتمسح اللي موجود في البروسيدر ده __AUTO_EQUIP_GEAR
و تحط ده مكانه

كود:
USE [SRO_VT_SHARD]
GO
/****** Object:  StoredProcedure [dbo].[__AUTO_EQUIP_GEAR]    Script Date: 14/4/2017 10:56:18 AM ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE [dbo].[__AUTO_EQUIP_GEAR]
	@CharName AS VARCHAR(64),
	@EQPlus AS TINYINT
AS	
	-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	-- @@@ BEGIN: SETTINGS
	
	-- CHANGE THIS! -- CHANGE THIS! -- CHANGE THIS! (if needed)

	-- (Represent ITEM_EU_TSTAFF_09_C_RARE), change as you need it
	DECLARE @GearSuffix VARCHAR(16) = 'C_RARE'

	-- @@@ END: SETTINGS
	-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

	SET XACT_ABORT ON
	SET NOCOUNT ON

	-- Check if character exist
	DECLARE	@isCharExist TINYINT = 0

	PRINT 'Validating Character...'
	-- EXEC @isCharExist = [_IsExistingCharName] @CharNameToCheck = @CharName
	SELECT @isCharExist = COUNT(CharID) FROM [_Char] WITH (NOLOCK) WHERE CharName16 = @CharName
	IF (@isCharExist = 0)
	BEGIN
		RAISERROR('Character: %s does not exist. Sequence canceled!', 1, 16, @CharName)
		RETURN -1
	END

	-- Check character and account related information (In relation with SRO_VT_ACCOUNT)
	DECLARE @CharID INT = 0
	DECLARE @RefCharID INT = 0
	DECLARE @UserJID INT = 0
	DECLARE @AccountName VARCHAR(32) = ''

	-- Check if character assigned to Account ID
	PRINT 'Validating Account ID...'
	SELECT @CharID = CharID, @RefCharID = RefObjID FROM [_Char] WITH (NOLOCK) WHERE CharName16 = @CharName
	SELECT @UserJID = UserJID FROM [_User] WITH (NOLOCK) WHERE CharID = @CharID
	IF (@UserJID IS NULL OR @UserJID = 0)
	BEGIN
		RAISERROR('Account ID does not exist, or character: %s is not assigned to any user accounts. Sequence canceled!', 1, 16, @CharName)
		RETURN -2
	END

	-- Check character gender and race
	DECLARE @CharGender VARCHAR(1) = ''
	DECLARE @CharRace VARCHAR(2) = ''

	PRINT 'Validating race and gender...'
	SET @CharRace = CASE
		WHEN (@RefCharID BETWEEN 1907 AND 1919) OR (@RefCharID BETWEEN 1920 AND 1932) THEN 'CH'	-- Chinese (vSRO/BR110)
		WHEN (@RefCharID BETWEEN 14875 AND 14887) OR (@RefCharID BETWEEN 14888 AND 14900) THEN 'EU'	-- Euro (vSRO)
		WHEN (@RefCharID BETWEEN 14717 AND 14729) OR (@RefCharID BETWEEN 14730 AND 14742) THEN 'EU'	-- Euro (BR110)
		ELSE NULL END
	SET @CharGender = CASE
		WHEN (@RefCharID BETWEEN 1907 AND 1919) OR (@RefCharID BETWEEN 14875 AND 14887) OR (@RefCharID BETWEEN 14717 AND 14729) THEN 'M'
		WHEN (@RefCharID BETWEEN 1920 AND 1932) OR (@RefCharID BETWEEN 14888 AND 14900) OR (@RefCharID BETWEEN 14730 AND 14742) THEN 'W'
		ELSE NULL END
	PRINT 'Race code is: ' + @CharRace + ', gender code is: ' + @CharGender + '.'
	IF (@CharRace IS NULL OR @CharGender IS NULL)
	BEGIN
		RAISERROR('Invalid character race and gender info. Sequence canceled!', 1, 16, @CharName)
		RETURN -3
	END

	-- Check character level for item degree
	DECLARE @EQDegree VARCHAR(2) = ''
	DECLARE @CurLevel TINYINT = 0

	SET @CurLevel = CASE
		WHEN @CharRace = 'CH' THEN (SELECT CurLevel FROM [_Char] WITH (NOLOCK) WHERE CharID = @CharID) + 1
		WHEN @CharRace = 'EU' THEN (SELECT TOP (1) [Level] FROM [_CharSkillMastery] WITH (NOLOCK) WHERE CharID = @CharID ORDER BY [Level] DESC) + 1
		ELSE 0 END
	SET @EQDegree = CASE
		WHEN @CurLevel < 13 THEN '01'
		WHEN @CurLevel < 21 THEN '02'
		WHEN @CurLevel < 29 THEN '03'
		WHEN @CurLevel < 37 THEN '04'
		WHEN @CurLevel < 47 THEN '05'
		WHEN @CurLevel < 57 THEN '06'
		WHEN @CurLevel < 69 THEN '07'
		WHEN @CurLevel < 81 THEN '08'
		WHEN @CurLevel < 92 THEN '09'
		WHEN @CurLevel < 101 THEN '10'
		ELSE '11' END

	PRINT 'Character/Mastery Level: ' + CAST(@CurLevel AS VARCHAR(3)) + ', degree: ' + @EQDegree + '. (Level are current +1)'

	-- Setting up equipment
	-- Gears
	DECLARE @CodeNameHelm		VARCHAR(64) = ''
	DECLARE @CodeNameMail		VARCHAR(64) = ''
	DECLARE @CodeNameShoulder	VARCHAR(64) = ''
	DECLARE @CodeNameGauntlet	VARCHAR(64) = ''
	DECLARE @CodeNamePants		VARCHAR(64) = ''
	DECLARE @CodeNameBoots		VARCHAR(64) = ''
	DECLARE @RefHelmID		INT = 0
	DECLARE @RefMailID		INT = 0
	DECLARE @RefShoulderID		INT = 0
	DECLARE @RefGauntletID		INT = 0
	DECLARE @RefPantsID		INT = 0
	DECLARE @RefBootsID		INT = 0
	DECLARE @RefHelmLinkID		INT = 0
	DECLARE @RefMailLinkID		INT = 0
	DECLARE @RefShoulderLinkID	INT = 0
	DECLARE @RefGauntletLinkID	INT = 0
	DECLARE @RefPantsLinkID		INT = 0
	DECLARE @RefBootsLinkID		INT = 0

	-- Accessories
	DECLARE @CodeNameEarring	VARCHAR(64) = ''
	DECLARE @CodeNameNecklace	VARCHAR(64) = ''
	DECLARE @CodeNameRing		VARCHAR(64) = ''
	DECLARE @RefEarringID		INT = 0
	DECLARE @RefNecklaceID		INT = 0
	DECLARE @RefRingID		INT = 0
	DECLARE @RefEarringLinkID	INT = 0
	DECLARE @RefNecklaceLinkID	INT = 0
	DECLARE @RefRingLinkID		INT = 0

	-- Weapon and Shield
	DECLARE @CodeNameWeapon		VARCHAR(64) = ''
	DECLARE @CodeNameShield		VARCHAR(64) = ''
	DECLARE @RefWeaponID		INT = 0
	DECLARE @RefShieldID		INT = 0
	DECLARE @RefWeaponLinkID	INT = 0
	DECLARE @RefShieldLinkID	INT = 0

	-- Check for current equipped weapon/shield
	PRINT 'Validating equipped weapon...'
	DECLARE @OldWeaponID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot =6)
	IF (@OldWeaponID IS NULL OR @OldWeaponID = 0)
	BEGIN
		RAISERROR('Character: %s is not wearing any weapon. Sequence canceled!', 10, 1, @CharName)
		RETURN -4
	END
	DECLARE @RefOldWeaponID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldWeaponID)
	DECLARE @WPClass VARCHAR(16) = ''
	SELECT @WPClass = 
		CASE
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 2 THEN 'SWORD'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 3 THEN 'BLADE'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 4 THEN 'SPEAR'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 5 THEN 'TBLADE'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 6 THEN 'BOW'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 7 THEN 'SWORD'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 8 THEN 'TSWORD'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 9 THEN 'AXE'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 10 THEN 'DARKSTAFF'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 11 THEN 'TSTAFF'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 12 THEN 'CROSSBOW'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 13 THEN 'DAGGER'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 14 THEN 'HARP'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND TypeID3 = 6 AND TypeID4 = 15 THEN 'STAFF'
		END
	FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND ID = @RefOldWeaponID ORDER BY TypeID4 ASC
	PRINT 'Weapon is: ' + @WPClass + '.'

	-- Set no shield by default, if the weapon used is 1H, then add shield automatically.
	PRINT 'Checking if character is using shield...'
	DECLARE @useShield TINYINT = 0
	IF (@WPClass = 'SWORD' OR @WPClass = 'BLADE' OR @WPClass = 'STAFF' OR @WPClass = 'DARKSTAFF')
	BEGIN
		PRINT '- 1H weapon is used, new shield will be added.'
		SET @useShield = 1
	END

	-- Item codes (trailing codes are from itemSuffix settings above)
	PRINT 'Validating current gear...'
	DECLARE @OldGearID INT = (SELECT TOP (1) ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND ItemID > 0 AND Slot BETWEEN 0 AND 5)
	IF (@OldGearID IS NULL OR @OldGearID = 0)
	BEGIN
		RAISERROR('Character: %s is not wearing any armor. Sequence canceled!', 10, 1, @CharName)
		RETURN -5
	END
	DECLARE @RefOldGearID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldGearID)
	DECLARE @EQClass VARCHAR(10)
	SELECT @EQClass = 
		CASE
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND (TypeID3 = 1 OR TypeID3 = 9) THEN 'CLOTHES'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND (TypeID3 = 2 OR TypeID3 = 10) THEN 'LIGHT'
			WHEN TypeID1 = 3 AND TypeID2 = 1 AND (TypeID3 = 3 OR TypeID3 = 11) THEN 'HEAVY'
		END
	FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND ID = @RefOldGearID ORDER BY TypeID4 ASC
	PRINT 'Gear type is: ' + @EQClass + '.'

	PRINT 'Validating current equipment type...'
	DECLARE @OldHelmID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 0)
	DECLARE @RefOldHelmID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldHelmID)
	DECLARE @OldMailID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 1)
	DECLARE @RefOldMailID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldMailID)
	DECLARE @OldShoulderID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 2)
	DECLARE @RefOldShoulderID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldShoulderID)
	DECLARE @OldGauntletID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 3)
	DECLARE @RefOldGauntletID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldGauntletID)
	DECLARE @OldPantsID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 4 )
	DECLARE @RefOldPantsID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldPantsID)
	DECLARE @OldBootsID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 5)
	DECLARE @RefOldBootsID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldBootsID)
	DECLARE @OldShieldID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 7)
	DECLARE @RefOldShieldID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldShieldID)
	DECLARE @OldEarringID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 9)
	DECLARE @RefOldEarringID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldEarringID)
	DECLARE @OldNecklaceID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 10)
	DECLARE @RefOldNecklaceID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldNecklaceID)
	DECLARE @OldLRingID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 11)
	DECLARE @RefOldLRingID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldLRingID)
	DECLARE @OldRRingID INT = (SELECT ItemID FROM [_Inventory] WITH (NOLOCK) WHERE CharID = @CharID AND Slot = 12)
	DECLARE @RefOldRRingID INT = (SELECT RefItemID FROM [_Items] WITH (NOLOCK) WHERE ID64 = @OldRRingID)

	-- Check if old equipment are Egy or Roc set
	DECLARE @useHelm TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldHelmID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useMail TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldMailID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useShoulder TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldShoulderID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useGauntlet TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldGauntletID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @usePants TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldPantsID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useBoots TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldBootsID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useWeapon TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldWeaponID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	IF (@useShield = 1)
	BEGIN
		SET @useShield = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldShieldID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	END
	DECLARE @useEarring TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldEarringID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useNecklace TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldNecklaceID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useLRing TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldLRingID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END
	DECLARE @useRRing TINYINT = CASE WHEN EXISTS(SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE ID = @RefOldRRingID AND (CodeName128 LIKE 'ITEM_ROC_%' OR CodeName128 LIKE '%_SET_A_RARE' OR CodeName128 LIKE '%_SET_B_RARE' OR CodeName128 LIKE '%_TOURNAMENT_SET' OR CodeName128 LIKE '%_SCHOLAR_SET' OR CodeName128 LIKE '%_GM_SET')) THEN 0 ELSE 1 END

	PRINT 'Setting up item codenames...'
	-- Gears
	SET @CodeNameHelm	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_HA_' + @GearSuffix
	SET @CodeNameMail	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_BA_' + @GearSuffix
	SET @CodeNameShoulder	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_SA_' + @GearSuffix
	SET @CodeNameGauntlet	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_AA_' + @GearSuffix
	SET @CodeNamePants	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_LA_' + @GearSuffix
	SET @CodeNameBoots	= 'ITEM_' + @CharRace + '_' + @CharGender + '_' + @EQClass + '_' + @EQDegree + '_FA_' + @GearSuffix

	-- Accessories
	SET @CodeNameEarring	= 'ITEM_' + @CharRace + '_EARRING_' + @EQDegree + '_' + @GearSuffix
	SET @CodeNameNecklace	= 'ITEM_' + @CharRace + '_NECKLACE_' + @EQDegree + '_' + @GearSuffix
	SET @CodeNameRing	= 'ITEM_' + @CharRace + '_RING_' + @EQDegree + '_' + @GearSuffix

	-- Weapon and Shield
	SET @CodeNameWeapon	= 'ITEM_' + @CharRace + '_' + @WPClass + '_' + @EQDegree + '_' + @GearSuffix
	SET @CodeNameShield	= 'ITEM_' + @CharRace + '_SHIELD_' + @EQDegree + '_' + @GearSuffix

	-- Get Reference ID and Link ID
	PRINT 'Getting item reference ID and link...'
	-- Gears
	SELECT @RefHelmID = ID, @RefHelmLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameHelm
	SELECT @RefMailID = ID, @RefMailLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameMail
	SELECT @RefShoulderID = ID, @RefShoulderLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameShoulder
	SELECT @RefGauntletID = ID, @RefGauntletLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameGauntlet
	SELECT @RefPantsID = ID, @RefPantsLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNamePants
	SELECT @RefBootsID = ID, @RefBootsLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameBoots

	-- Accessories
	SELECT @RefEarringID = ID, @RefEarringLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameEarring
	SELECT @RefNecklaceID = ID, @RefNecklaceLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameNecklace
	SELECT @RefRingID = ID, @RefRingLinkID = link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameRing

	-- Weapon and Shield
	SELECT @RefWeaponID = ID, @RefWeaponLinkID = Link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameWeapon
	SELECT @RefShieldID = ID, @RefShieldLinkID = Link FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = @CodeNameShield

	IF (
		@RefHelmID IS NULL OR @RefHelmID = 0 OR 
		@RefMailID IS NULL OR @RefMailID = 0 OR 
		@RefShoulderID IS NULL OR @RefShoulderID = 0 OR 
		@RefGauntletID IS NULL OR @RefGauntletID = 0 OR 
		@RefPantsID IS NULL OR @RefPantsID = 0 OR 
		@RefBootsID IS NULL OR @RefBootsID = 0 OR 
		@RefEarringID IS NULL OR @RefEarringID = 0 OR 
		@RefNecklaceID IS NULL OR @RefNecklaceID = 0 OR 
		@RefRingID IS NULL OR @RefRingID = 0 OR
		@RefWeaponID IS NULL OR @RefWeaponID = 0 OR
		@RefShieldID IS NULL OR @RefShieldID = 0
	)
	BEGIN
		RAISERROR('Invalid item reference ID, check item codename (degree parameter or item suffix setting). Sequence canceled!', 1, 16)
		RETURN -6
	END
	IF (
		@RefHelmLinkID IS NULL OR @RefHelmLinkID = 0 OR 
		@RefMailLinkID IS NULL OR @RefMailLinkID = 0 OR 
		@RefShoulderLinkID IS NULL OR @RefShoulderLinkID = 0 OR 
		@RefGauntletLinkID IS NULL OR @RefGauntletLinkID = 0 OR 
		@RefPantsLinkID IS NULL OR @RefPantsLinkID = 0 OR 
		@RefBootsLinkID IS NULL OR @RefBootsLinkID = 0 OR 
		@RefEarringLinkID IS NULL OR @RefEarringLinkID = 0 OR 
		@RefNecklaceLinkID IS NULL OR @RefNecklaceLinkID = 0 OR 
		@RefRingLinkID IS NULL OR @RefRingLinkID = 0 OR 
		@RefWeaponLinkID IS NULL OR @RefWeaponLinkID = 0 OR 
		@RefShieldLinkID IS NULL OR @RefShieldLinkID = 0
	)
	BEGIN
		RAISERROR('Invalid link reference ID, check item codename (degree parameter or item suffix setting). Sequence canceled!', 1, 16)
		RETURN -7
	END

	-- Get durability for 'Data'
	PRINT 'Getting items durability information...'
	DECLARE @DuraHelm INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefHelmLinkID)
	DECLARE @DuraMail INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefMailLinkID)
	DECLARE @DuraShoulder INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefShoulderLinkID)
	DECLARE @DuraGauntlet INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefGauntletLinkID)
	DECLARE @DuraPants INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefPantsLinkID)
	DECLARE @DuraBoots INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefBootsLinkID)
	DECLARE @DuraWeapon INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefWeaponLinkID)
	DECLARE @DuraShield INT = (SELECT Dur_L FROM _RefObjItem WITH (NOLOCK) WHERE ID = @RefShieldLinkID)

	-- Sequence begin
	BEGIN TRANSACTION

		-- Add new equipment to equipment slots
		PRINT 'Adding new items...'
		DECLARE @HelmItemID64 BIGINT = 0
		DECLARE @MailItemID64 BIGINT = 0
		DECLARE @ShoulderItemID64 BIGINT = 0
		DECLARE @GauntletItemID64 BIGINT = 0
		DECLARE @PantsItemID64 BIGINT = 0
		DECLARE @BootsItemID64 BIGINT = 0

		DECLARE @EarringItemID64 BIGINT = 0
		DECLARE @NecklaceItemID64 BIGINT = 0
		DECLARE @RingLItemID64 BIGINT = 0
		DECLARE @RingRItemID64 BIGINT = 0

		DECLARE @WeaponItemID64 BIGINT = 0
		DECLARE @ShieldItemID64 BIGINT = 0

		-- Helm
		IF (@useHelm = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 0
			EXEC @HelmItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 0, @RefHelmID, @DuraHelm
			IF (@HelmItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -8
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @HelmItemID64
			PRINT '- Helm equipped.'
		END

		-- Chest
		IF (@useMail = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 1
			EXEC @MailItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 1, @RefMailID, @DuraMail
			IF (@MailItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -9
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @MailItemID64
			UPDATE [_Items] SET MagParamNum = 5, MagParam5 = 901943132463 WHERE ID64 = @MailItemID64
			PRINT '- Chest equipped.'
		END

		-- Shoulder
		IF (@useShoulder = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 2
			EXEC @ShoulderItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 2, @RefShoulderID, @DuraShoulder
			IF (@ShoulderItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -10
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @ShoulderItemID64
			PRINT '- Shoulder equipped.'
		END

		-- Gauntlet
		IF (@useGauntlet = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 3
			EXEC @GauntletItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 3, @RefGauntletID, @DuraGauntlet
			IF (@GauntletItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -11
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @GauntletItemID64
			PRINT '- Gauntlet equipped.'
		END

		-- Pants
		IF (@usePants = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 4
			EXEC @PantsItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 4, @RefPantsID, @DuraPants
			IF (@PantsItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -12
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @PantsItemID64
			PRINT '- Pants equipped.'
		END

		-- Boots
		IF (@useBoots = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 5
			EXEC @BootsItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 5, @RefBootsID, @DuraBoots
			IF (@BootsItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -13
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 257698037898, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @BootsItemID64
			PRINT '- Boots equipped.'
		END

		-- Earring
		IF (@useEarring = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 9
			EXEC @EarringItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 9, @RefEarringID, 0
			IF (@EarringItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -14
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @EarringItemID64
			UPDATE [_Items] SET MagParamNum = 9, MagParam8 = 214748365115, MagParam9 = 214748365139 WHERE ID64 = @EarringItemID64
			PRINT '- Earring equipped.'
		END

		-- Necklace
		IF (@useNecklace = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 10
			EXEC @NecklaceItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 10, @RefNecklaceID, 0
			IF (@NecklaceItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -15
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @NecklaceItemID64
			UPDATE [_Items] SET MagParamNum = 8, MagParam8 = 47244640547 WHERE ID64 = @NecklaceItemID64
			PRINT '- Necklace equipped.'
		END

		-- Left Ring
		IF (@useLRing = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 11
			EXEC @RingLItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 11, @RefRingID, 0
			IF (@RingLItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -16
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @RingLItemID64
			UPDATE [_Items] SET MagParamNum = 9, MagParam8 = 107374182751, MagParam9 = 107374182727  WHERE ID64 = @RingLItemID64
			PRINT '- Left Ring equipped.'
		END

		-- Right Ring
		IF (@useRRing = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 12
			EXEC @RingRItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 12, @RefRingID, 0
			IF (@RingRItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -17
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 1073741823, MagParamNum = 7, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 85899346100, MagParam4 = 85899346094, MagParam5 = 85899346088, MagParam6 = 85899346106, MagParam7 = 85899346112, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @RingRItemID64
			UPDATE [_Items] SET MagParamNum = 9, MagParam8 = 107374182751, MagParam9 = 107374182727  WHERE ID64 = @RingRItemID64
			PRINT '- Right Ring equipped.'
		END

		-- Weapon
		IF (@useWeapon = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 6
			EXEC @WeaponItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 6, @RefWeaponID, @DuraWeapon
			IF (@WeaponItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -18
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 6, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 429496729714, MagParam5 = 257698037862, MagParam6 = 12884902155, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @WeaponItemID64
			PRINT '- Weapon equipped.'
		END

		-- Shield
		IF (@useShield = 1)
		BEGIN
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 7
			EXEC @ShieldItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 7, @RefShieldID, @DuraShield
			IF (@ShieldItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP], canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -19
			END
			UPDATE [_Items] SET OptLevel = @EQPlus, Variance = 34359738336, MagParamNum = 4, MagParam1 = 30064771144, MagParam2 = 30064771150, MagParam3 = 858993459290, MagParam4 = 429496729726, MagParam5 = NULL, MagParam6 = NULL, MagParam7 = NULL, MagParam8 = NULL, MagParam9 = NULL, MagParam10 = NULL, MagParam11 = NULL, MagParam12 = NULL WHERE ID64 = @ShieldItemID64
			PRINT '- Shield equipped.'
		END

		-- Arrow/Bolt
		IF (@WPClass = 'BOW' OR @WPClass = 'CROSSBOW')
		BEGIN
			DECLARE @ArrowItemID64 BIGINT
			DECLARE @RefArrowID INT = CASE
				WHEN @WPClass = 'BOW' THEN (SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = 'ITEM_MALL_QUIVER')
				WHEN @WPClass = 'CROSSBOW' THEN (SELECT ID FROM [_RefObjCommon] WITH (NOLOCK) WHERE [Service] = 1 AND CodeName128 = 'ITEM_MALL_BOLT')
			END
		
			EXEC [_STRG_DEL_ITEM_NoTX] 1, @CharID, 7
			EXEC @ArrowItemID64 = [_FN_ADD_INITIAL_EQUIP] @CharID, 7, @RefArrowID, 10000
			IF (@ArrowItemID64 <= 0)
			BEGIN
				PRINT 'Problem when executing [_FN_ADD_INITIAL_EQUIP] (Arrow/Bolt), canceling sequence and rolling back data...'
				ROLLBACK TRANSACTION
				RETURN -19
			END
			PRINT '- Arrow/Bolt equipped.'
		END

	COMMIT TRANSACTION
	PRINT 'Sequence complete.'

RETURN -1
-- EOF
عادي يا باشا هو كده عمل كونكت
دوس على كلمة Server Connection و دخل بيانات الكراكتر الجي ام
للي هتعملها بوت أيفينت و هو هيدخل عادي
بدون مشاكل
محلوظة/ أسف على تكرار الردود .. بتحصل لوحدها عشان النت عندي في مشكلة و بطيئ جدا


عادي يا باشا هو كده عمل كونكت
دوس على كلمة Server Connection و دخل بيانات الكراكتر الجي ام
للي هتعملها بوت أيفينت و هو هيدخل عادي
بدون مشاكل
محلوظة/ أسف على تكرار الردود .. بتحصل لوحدها عشان النت عندي في مشكلة و بطيئ جدا


توقيع MORJANA :


Help others, such as the circle i Need You Today . You Need Me Tomorrow

SQL.[DB].Editor---> Media.pk2 Editor Web Design & Graphic Designer

التعديل الأخير تم بواسطة .Gamer. ; 14-04-2017 الساعة 02:14 PM السبب: مكرر

إعلانات google

موضوع مغلق


يتصفح الموضوع حالياً : 1 (0 عضو و 1 زائر)
 

ضوابط المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع

المواضيع المتشابهه
الموضوع كاتب الموضوع المنتدى الردود آخر مشاركة
Premium remover loaymoataz123 قسم الاسئلة و الاستفسارات لعمل السيرفرات الخاصة 6 17-04-2017 11:24 PM
Premium Remover Scroll Sherio_3x قسم المواضيع المكررة و المخالفة 3 26-11-2013 09:37 PM
WTS acc Wizard/cllirc FF lvl 64 +2avtar +premium +premium skill+40silk محمد محمود55 Minerva 4 28-07-2010 11:20 AM
حرام والله crash crash crash عايز حل بليز Sneezy قسم المواضيع المكررة و المخالفة 13 02-06-2010 06:01 PM


الساعة الآن 01:51 AM.