USE [SRO_VT_LOG]GO
/****** Object: StoredProcedure [dbo].[_JobS] Script Date: 25.8.2017 18:14:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[_JobS]
@Operation AS TINYINT, @charID AS INT, @slot_From AS TINYINT, @slot_To AS TINYINT
AS
DECLARE @ItemID int, @serial bigint, @skillID int;
SELECT TOP 1 @ItemID = I.RefItemID
FROM SRO_VT_SHARD.._Items I
INNER JOIN SRO_VT_SHARD.._Inventory INV
ON I.ID64 = INV.ItemID
WHERE INV.CharID = @charID and INV.Slot = @slot_From
SELECT @serial = (SELECT TOP 1 Serial64 + 1 FROM SRO_VT_SHARD.._TimedJob ORDER BY Serial64 desc)
SELECT @skillID = CASE
WHEN @ItemID IN ('41896','41911') THEN '39049'
WHEN @ItemID IN ('41897','41912') THEN '39050'
WHEN @ItemID IN ('41898','41913') THEN '39051'
WHEN @ItemID IN ('41899','41914') THEN '39052'
WHEN @ItemID IN ('41900','41915') THEN '39053'
WHEN @ItemID IN ('41906','41921') THEN '39054'
WHEN @ItemID IN ('41907','41922') THEN '39055'
WHEN @ItemID IN ('41908','41923') THEN '39056'
WHEN @ItemID IN ('41909','41924') THEN '39057'
WHEN @ItemID IN ('41910','41925') THEN '39058'
WHEN @ItemID IN ('41901','41916') THEN '39059'
WHEN @ItemID IN ('41902','41917') THEN '39060'
WHEN @ItemID IN ('41903','41918') THEN '39061'
WHEN @ItemID IN ('41904','41919') THEN '39062'
WHEN @ItemID IN ('41905','41920') THEN '39063'
ELSE 0
END
----------- ## Granting Job suit - Player wears job suit ## -----------
IF @Operation = '0' and @slot_To = '8'
BEGIN
IF NOT EXISTS (SELECT CharID FROM SRO_VT_SHARD.._TimedJob WHERE CharID = @charID and JobID = @skillID)
BEGIN
INSERT SRO_VT_SHARD.._TimedJob WITH (ROWLOCK)
SELECT @charID,0 @skillID,1209600000,0,0,0,0,0,0,0,0 @serial,0
END
END
----------- ## Granted! ## -----------
----------- ## Removing Job suit - Player taking job suit off ## -----------
IF @Operation = '0' AND @slot_From = '8'
BEGIN
IF EXISTS (SELECT * FROM SRO_VT_SHARD.._TimedJob WHERE CharID = @charID and JobID Between '39049' AND '39063')
BEGIN
DELETE FROM SRO_VT_SHARD.._TimedJob WHERE CharID = @charID AND JobID Between '39049' AND '39063'
END
END
----------- ## Removed! ## -----------
GO