USE [MuOnline]
GO
DROP PROCEDURE [dbo].[WZ_DISCONNECT_MEMB]
GO
CREATE PROCEDURE [dbo].[WZ_DISCONNECT_MEMB]
@memb___id varchar(10)
AS
Begin
set nocount on
Declare @find_id varchar(10)
Declare @ConnectStat tinyint
Declare @OnlineHours real
Set @ConnectStat = 0
Set @find_id = 'NOT'
select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id
where I.memb___id = @memb___id
if( @find_id <> 'NOT' )
begin
Update MEMB_STAT SET ConnectStat = @ConnectStat, DisConnectTM = getdate(), OnlineHours = OnlineHours + datediff(hour, ConnectTM, getdate()) where memb___id = @memb___id
SELECT @OnlineHours = OnlineHours FROM MEMB_STAT WHERE memb___id = @memb___id
Update MEMB_INFO SET gold = gold+(@OnlineHours * 2) WHERE memb___id = @memb___id and @OnlineHours >= '1'
Update MEMB_STAT SET OnlineHours = 0 WHERE memb___id = @memb___id
end
end
GO