USE [World00_Character]
GO
/****** Object: StoredProcedure [dbo].[p_Char_Login] Script Date: 07/12/2015 17:46:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** 개체: 저장 프로시저 dbo.p_Char_Login 스크립트 날짜: 2007-03-13 오후 6:25:10 ******/


ALTER PROCEDURE [dbo].[p_Char_Login]
/*
Character login
2004.6 By CJC
Updated: 2012.5 By Korv4kx
Updated: 2015.7 By Regie
Input:
nCharNo = To be login
DB Output: Fills LoggedInChars with more info.
Output:
0 = error
1 = work ok
*/
@nCharNo int,
@nRet int OUTPUT
AS
SET NOCOUNT ON
UPDATE tCharacter
SET nLoginCount = nLoginCount + 1,
dLastLoginDate = GETDATE()
WHERE nCharNo = @nCharNo
SET @nRet = @@ROWCOUNT
INSERT INTO dbo.LoggedInChars (nCharNo) VALUES (@nCharNo)
UPDATE dbo.LoggedInChars
SET nUserNo = dbo.tCharacter.nUserNo,
nAdminLevel = dbo.tCharacter.nAdminLevel,
sID = dbo.tCharacter.sID,
sLoginZone = dbo.tCharacter.sLoginZone,
nLoginCount = dbo.tCharacter.nLoginCount,
nPlayMin = dbo.tCharacter.nPlayMin,
nLevel = dbo.tCharacter.nLevel,
nExp = dbo.tCharacter.nExp,
nFame = dbo.tCharacter.nFame,
nMoney = dbo.tCharacter.nMoney
FROM dbo.tCharacter
WHERE dbo.LoggedInChars.nCharNo = dbo.tCharacter.nCharNo
UPDATE dbo.LoggedInChars
SET nClass = dbo.tCharacterShape.nClass
FROM dbo.tCharacterShape
WHERE dbo.LoggedInChars.nCharNo = dbo.tCharacterShape.nCharNo
UPDATE dbo.LoggedInChars
SET nCoin = dbo.tGambleCoin.nCoin
FROM dbo.tGambleCoin
WHERE dbo.LoggedInChars.nCharNo = dbo.tGambleCoin.nCharNo
RETURN
-- end