USE [kn_online]GO
/****** Object: StoredProcedure [dbo].[CREATE_NEW_CHAR] Script Date: 04.03.2017 19:58:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[CREATE_NEW_CHAR]
@strAccountID varchar(21),
@index tinyint,
@strCharID varchar(21),
@bRace tinyint,
@sClass smallint,
@nHair int,
@bFace tinyint,
@bStr tinyint,
@bSta tinyint,
@bDex tinyint,
@bIntel tinyint,
@bCha tinyint
AS
DECLARE @bNation tinyint
DECLARE @bCharCount tinyint
DECLARE @bCount tinyint
SELECT @bNation = bNation, @bCharCount = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @strAccountID
--IF (@bNation = 1 AND @bRace > 10)
--RETURN 2
--ELSE IF (@bNation = 2 AND @bRace < 10)
--RETURN 2
--ELSE IF (@bNation <> 1 AND @bNation <> 2)
--RETURN 2
SELECT @bCount = COUNT(strUserID) FROM USERDATA WHERE strUserID = @strCharID
IF (@bCount > 0)
RETURN 3
BEGIN TRAN
IF (@index = 0)
UPDATE ACCOUNT_CHAR SET strCharID1 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID
ELSE IF (@index = 1)
UPDATE ACCOUNT_CHAR SET strCharID2 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID
ELSE IF (@index = 2)
UPDATE ACCOUNT_CHAR SET strCharID3 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID
ELSE IF (@index = 3)
UPDATE ACCOUNT_CHAR SET strCharID4 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID
IF (@@ERROR <> 0 OR @@ROWCOUNT = 0)
BEGIN
ROLLBACK TRAN
RETURN 4
END
INSERT INTO USERDATA (strUserID, Nation, Race, Class, HairRGB, Face, Strong, Sta, Dex, Intel, Cha)
VALUES (@strCharID, @bNation, @bRace, @sClass, @nHair, @bFace, @bStr, @bSta, @bDex, @bIntel, @bCha)
update USERDATA SET zone=21 where zone = 21
--HUMAN WARRİOR--
update userdata set Class = 206 ,strong = '255' , sta = '177' ,Dex='60',Cha='50',Intel='50', [level] = '83' where struserid = @strCharID and @sClass = 201
--HUMAN WARRİOR--
--HUMAN ROGUE--
update userdata set Class = 208 ,strong = '60' , dex = '255' , sta = '177',Intel='50',Cha='50' , [level] = '83' where struserid = @strCharID and @sClass = 202
--HUMAN ROGUE--
--HUMAN MAGİCİAN--
update userdata set Class = 210 ,strong = '51' , sta = '135' ,Dex='60', cha = '186' , intel = '160', [level] = '83' where struserid = @strCharID and @sClass = 203
--HUMAN MAGİCİAN--
--HUMAN PRİEST--
update userdata set Class = 212 ,strong = '194' , sta = '84' , intel = '194',Dex='70',Cha='50' ,[level] = '83' where struserid = @strCharID and @sClass = 204
--HUMAN PRİEST--
-----------------------------------------------
--KARUS WARRİOR--
update userdata set Class = 106 ,strong = '255' , sta = '177' ,Dex='60',Cha='50',Intel='50', [level] = '83' where struserid = @strCharID and @sClass = 101
--KARUS WARRİOR--
--KARUS ROGUE--
update userdata set Class = 108 ,strong = '60' , dex = '255' , sta = '177',Intel='50',Cha='50' , [level] = '83' where struserid = @strCharID and @sClass = 102
--KARUS ROGUE--
--KARUS MAGİCİAN--
update userdata set Class = 110 ,strong = '51' , sta = '135' ,Dex='60', cha = '186' , intel = '160', [level] = '83' where struserid = @strCharID and @sClass = 103
--KARUS MAGİCİAN--
--KARUS PRİEST--
update userdata set Class = 112 ,strong = '194' , sta = '84' , intel = '194',Dex='70',Cha='50' ,[level] = '83' where struserid = @strCharID and @sClass = 104
--KARUS PRİEST--
update userdata set Class = 106 where struserid = @strCharID and @sClass = 101
update userdata set Class = 108 where struserid = @strCharID and @sClass = 102
update userdata set Class = 110 where struserid = @strCharID and @sClass = 103
update userdata set Class = 112 where struserid = @strCharID and @sClass = 104
update userdata set Class = 206 where struserid = @strCharID and @sClass = 201
update userdata set Class = 208 where struserid = @strCharID and @sClass = 202
update userdata set Class = 210 where struserid = @strCharID and @sClass = 203
update userdata set Class = 212 where struserid = @strCharID and @sClass = 204
DECLARE @bFree tinyint
SET @bFree = 0
IF (@@ERROR <> 0)
BEGIN
ROLLBACK TRAN
RETURN 4
END
COMMIT TRAN
RETURN 0