/****** 개체: StoredProcedure [dbo].[lin_CreateChar] 스크립트 날짜: 11/03/2010 15:03:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/**
name: lin_CreateChar
desc: create user_data, quest, user_slot
history: 2007-03-30 modified by btwinuni
*/
CREATE procedure [lin_CreateChar]
(
@char_name nvarchar(24),
@account_name nvarchar(24),
@account_id int,
@pledge_id int,
builder tinyint,
gender tinyint,
@race tinyint,
@class tinyint,
@world smallint,
@xloc int,
@yloc int,
@zloc int,
@HP float,
@MP float,
@SP int,
Exp bigint,
Lev tinyint,
@align smallint,
@PK int,
@Duel int,
@PKPardon int,
@FaceIndex int = 0,
@HairShapeIndex int = 0,
@HairColorIndex int = 0
)
as
set nocount on
declare @char_id int
set @char_id = 0
set @char_name = rtrim(@char_name)
-- for test server by btwinuni 2007-07-31
--set
Lev = 82
--set
Exp = 9198000000
--set @SP = 1000000000
-- for test server
-- debug code delete in commercial
--if (@@servername = 'DL380G3NEW' or @@servername = 'L2DEV-AMD64-2')
--begin
-- set
builder = 1
--end
--else
--begin
-- if not exists(select * from account_ch2 (nolock) where account = @account_name)
-- begin
-- raiserror ('Creating character is prohibited : No account name on account_ch2 = [%s]', 16, 1, @account_name)
-- return -1
-- end
--end
if @char_name like N' '
begin
raiserror ('Character name has space : name = [%s]', 16, 1, @char_name)
return -1
end
-- check user_prohibit
if exists(select char_name from user_prohibit (nolock) where char_name = @char_name)
begin
raiserror ('Character name is prohibited: name = [%s]', 16, 1, @char_name)
return -1
end
declare @user_prohibit_word nvarchar(20)
select top 1 @user_prohibit_word = words from user_prohibit_word (nolock) where @char_name like '%' + words + '%'
if @user_prohibit_word is not null
begin
raiserror ('Character name has prohibited word: name = [%s], word[%s]', 16, 1, @char_name, @user_prohibit_word)
return -1
end
-- check reserved name
declare @reserved_name nvarchar(50)
declare @reserved_account_id int
select top 1 @reserved_name = char_name, @reserved_account_id = account_id from user_name_reserved (nolock) where used = 0 and char_name = @char_name
if not @reserved_name is null
begin
if not @reserved_account_id = @account_id
begin
raiserror ('Character name is reserved by other player: name = [%s]', 16, 1, @char_name)
return -1
end
end
-- insert user_data
insert into user_data (
char_name, account_name, account_id, pledge_id, builder, gender, race, class, subjob0_class,
world, xloc, yloc, zloc, HP, MP, max_hp, max_mp, SP, Exp, Lev, align, PK, PKpardon, duel,
create_date, face_index, hair_shape_index, hair_color_index
)
values (
@char_name, @account_name, @account_id, @pledge_id,
builder,
gender, @race, @class, @class,
@world, @xloc, @yloc, @zloc, @HP, @MP, @HP, @MP, @SP,
Exp,
Lev, @align, @PK, @Duel, @PKPardon,
GETDATE(), @FaceIndex, @HairShapeIndex, @HairColorIndex
)
if (@@error = 0)
begin
set @char_id = @@identity
insert into quest (char_id) values (@char_id)
insert into user_slot (char_id) values (@char_id)
-- for test server by neo 2008-04-10
-- insert into user_pccafe_point (char_id, point) values (@char_id, 20000)
-- for test server
end