USE [lin2world]
GO
/****** Object: StoredProcedure [dbo].[lin_GetUserDataByCharId] Script Date: 24.01.2023 18:17:05 ******/
DROP PROCEDURE [dbo].[lin_GetUserDataByCharId]
GO
/****** Object: StoredProcedure [dbo].[lin_GetUserDataByCharId] Script Date: 24.01.2023 18:17:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[lin_GetUserDataByCharId]
(
@char_id int
)
as
set nocount on
declare @subjob_id_s int
declare @lev_s int
declare @exp_s bigint
if @char_id > 0
begin
select top 1 @subjob_id_s = [subjob_id], @lev_s = [level], @exp_s = [exp]
from user_subjob(nolock) where char_id = @char_id order by [exp] desc
if @subjob_id_s is null
begin
set @subjob_id_s = -1
set @lev_s = 0
set @exp_s = 0
end
select
RTRIM(ud.char_name), ud.char_id, RTRIM(ud.account_name), ud.account_id, ud.pledge_id, ud.builder,
ud.gender, ud.race, ud.class, ud.world, ud.xloc, ud.yloc, ud.zloc, ud.IsInVehicle,
ud.HP, ud.MP, ud.Max_HP, ud.Max_MP, ud.CP, ud.Max_CP, ud.SP, ud.Exp, ud.Lev,
case when ud.subjob_id = @subjob_id_s then ud.Exp when ud.Exp >= @exp_s then ud.Exp else @exp_s end,
case when ud.subjob_id = @subjob_id_s then ud.Lev when ud.Exp >= @Exp_s then ud.Lev else @lev_s end,
ud.align, ud.PK, ud.duel, ud.pkpardon,
ISNULL(usl.ST_underwear, 0), ISNULL(usl.ST_right_ear, 0), ISNULL(usl.ST_left_ear, 0),
ISNULL(usl.ST_neck, 0), ISNULL(usl.ST_right_finger, 0), ISNULL(usl.ST_left_finger, 0),
ISNULL(usl.ST_head, 0), ISNULL(usl.ST_right_hand, 0), ISNULL(usl.ST_left_hand, 0),
ISNULL(usl.ST_gloves, 0), ISNULL(usl.ST_chest, 0), ISNULL(usl.ST_legs, 0), ISNULL(usl.ST_feet, 0),
ISNULL(usl.ST_back, 0), ISNULL(usl.ST_both_hand, 0), ISNULL(usl.ST_hair, 0), ISNULL(usl.ST_hair2, 0),
ISNULL(usl.ST_right_bracelet, 0), ISNULL(usl.ST_left_bracelet, 0),
ISNULL(usl.ST_agathion_main, 0), ISNULL(usl.ST_agathion_sub1, 0), ISNULL(usl.ST_agathion_sub2, 0), ISNULL(usl.ST_agathion_sub3, 0), ISNULL(usl.ST_agathion_sub4, 0),
ISNULL(usl.ST_deco1, 0), ISNULL(usl.ST_deco2, 0), ISNULL(usl.ST_deco3, 0),
ISNULL(usl.ST_deco4, 0), ISNULL(usl.ST_deco5, 0), ISNULL(usl.ST_deco6, 0),
ISNULL(usl.ST_waist, 0), ISNULL(usl.ST_brooch, 0), ISNULL(usl.ST_jewel1, 0),ISNULL(usl.ST_jewel2, 0),ISNULL(usl.ST_jewel3, 0),ISNULL(usl.ST_jewel4, 0),ISNULL(usl.ST_jewel5, 0),ISNULL(usl.ST_jewel6, 0),
ISNULL(YEAR(temp_delete_date),0), ISNULL(MONTH(temp_delete_date),0), ISNULL(DAY(temp_delete_date),0),
ISNULL(DATEPART(HOUR, temp_delete_date),0), ISNULL(DATEPART(mi, temp_delete_date),0), ISNULL(DATEPART(s, temp_delete_date),0),
ud.quest_flag, ud.face_index, ud.hair_shape_index, ud.hair_color_index,
ud.nickname, ud.power_flag, ud.pledge_dismiss_time, ud.pledge_ousted_time, ud.pledge_withdraw_time,
ud.surrender_war_id, ud.use_time, ud.drop_exp,
ISNULL(ub.status, 0), ISNULL(ub.ban_end , 0), ISNULL(ud.subjob_id , 0),
ud.subjob0_class, ud.subjob1_class, ud.subjob2_class, ud.subjob3_class,
ISNULL(ud.dual_class_id , 0), ISNULL(ssq_dawn_round, 0),
ISNULL(unc.color_rgb, 0xFFFFFF), isnull(unc.nickname_color_rgb, 0xECF9A2),
ud.pledge_type , ud.grade_id, ISNULL(ud.academy_pledge_id, 0), ISNULL(us.service_flag, 0),
ISNULL(ud.tutorial_flag, 0), ISNULL(ud.associated_inzone, 0), ISNULL(ud.bookmark_slot, 0), ISNULL(ud.associated_inzone_uid, 0),
ISNULL(uj.job_group, -1), ISNULL(ud.PP, 0)
from
(select * from user_data (nolock) where char_id = @char_id and account_id > 0) as ud
left outer join
(select * from user_ban (nolock) where char_id = @char_id) as ub on ud.char_id = ub.char_id
left outer join
(select * from user_name_color (nolock) where char_id = @char_id) as unc on ud.char_id = unc.char_id
left outer join
(select * from user_service (nolock) where char_id = @char_id) as us on ud.char_id = us.char_id
left outer join
(select * from user_slot (nolock) where char_id = @char_id) as usl on ud.char_id = usl.char_id
left outer join
(select * from user_job_group (nolock) where char_id = @char_id) as uj on ud.char_id = uj.char_id
end
GO