Query that unequipment on specific Character
Dear Ragezoners,
As always, I will keep sharing good stuffs for RageZone.. :driver:
Lets have fun ...
//Create dbo._emptyEquipmentsToInvenotry
besure of changing the database name "SRO_VT_SHARD"
Code:
USE [SRO_VT_SHARD]
GO
/****** Object: StoredProcedure [dbo].[_emptyEquipmentsToInvenotry] Script Date: 23/09/2012 07:37:38 م ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Megaman
-- Create date: No specific date
-- Description: Uneqiupment all Weapons, Armors and Accessories from Character
-- =============================================
CREATE PROCEDURE [dbo].[_emptyEquipmentsToInvenotry]
-- Add the parameters for the stored procedure here
@charname16 varchar (16)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @intFlag1 INT -- For Slots
Declare @intFlag2 INT -- For Equipments Slots
Declare @Flag2Permission INT -- Permissions for Equipments slots
Declare @ITEMID INT -- For Gathering ItemID as Temporary
Declare @CharID INT -- For Gathering Character ID
SET @intFlag1 = 13
SET @intFlag2 = 0
SET @Flag2Permission = 0
-- Checking before starting Actions
IF not exists (select CharID from _Char where CharName16 = @charname16)
BEGIN
Return -4 -- The character is not exists
END
SET @CharID = (select CharID from _Char where CharName16 = @charname16)
-- WARNING !! WARNING !! Starting Actions !! WARNING !! WARNING
WHILE (@intFlag1 <=109)
Begin
IF (select i.ItemID from _Inventory i where i.CharID = @CharID and i.Slot = @intFlag1) = 0
BEGIN
SET @Flag2Permission = 1
WHILE (@intFlag2 <= 12) and (@Flag2Permission = 1)
BEGIN
IF (select ItemID from _Inventory where Slot = @intFlag2 and CharID = @CharID) != 0
BEGIN
-- Checking If ITEMID is not Dummy object
IF (select ItemID from _Inventory where Slot = @intFlag2 and CharID = @CharID) = 0
BEGIN
Return -3 -- ITEM is selected wrongly
END
SET @ITEMID = (select ItemID from _Inventory where Slot = @intFlag2 and CharID = @CharID)
UPDATE _Inventory set ItemID = @ITEMID where CharID = @CharID and Slot = @intFlag1
Update _Inventory Set ItemID = 0 where CharID = @CharID and Slot = @intFlag2
END
SET @intFlag2 = @intFlag2 + 1
SET @Flag2Permission = 0
END
END
SET @intFlag1 = @intFlag1 + 1
END
END
GO
//Executing dbo._emptyEquipmentsToInvenotry
Code:
exec dbo._emptyEquipmentsToInvenotry [Write the Character Name]
//Expected dbo._emptyEquipmentsToInvenotry returns errors
Returns:
- Return 0 or 1
The prouceder has been executed successfully - Return -4
The character is not exists - Return -3
Wrong on checking Item (Never happen before)
Wished to all good lucks
Cheers,,
Re: Query that unequipment on specific Character
Re: Query that unequipment on specific Character