![]() |
|
|
#1 |
|
Архивный участник
Join Date: Feb 2006
Posts: 39
|
*Sorry for pure English - it's not my native
*1. As I see, all statistics sites for L2 servers uses comparision login > logout time to deside is char online or offline. But when server crashes, some chars stays "online" even if they are not. I think I've resolved that problem. All you need is to update procedure in DB. Code:
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO /******************************************** lin_DeleteNotOwnedItem INPUT OUTPUT return made by carrot date 2003-10-12 ********************************************/ ALTER PROCEDURE [DBO].[lin_DeleteNotOwnedItem] AS SET NOCOUNT ON -- Charis start update lin2world.dbo.user_data set logout = getdate() where login > logout -- Charis end DELETE user_item WHERE char_id = 0 OR item_type = 0 DECLARE @ToDeleteCharacter CURSOR DECLARE @char_id INT SET @ToDeleteCharacter = CURSOR FAST_FORWARD FOR SELECT char_id FROM user_data WHERE account_id > 0 AND temp_delete_date IS NOT NULL AND DATEDIFF ( dd , temp_delete_date , GETDATE()) >= 7 OPEN @ToDeleteCharacter FETCH FROM @ToDeleteCharacter INTO @char_id WHILE @@FETCH_STATUS = 0 BEGIN EXEC lin_deleteChar @char_id FETCH NEXT FROM @ToDeleteCharacter INTO @char_id END CLOSE @ToDeleteCharacter DEALLOCATE @ToDeleteCharacter exec dbo.lin_CleanUpGhostData GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO I think it may be usefull for users to see when and from what IP they have logged in on account. It is nided to do such changes in DB. Add Table for logs of logins in lin2db database: Code:
CREATE TABLE [login_list] ( [uid] [int] NOT NULL , [last_login] [datetime] NOT NULL , [last_logout] [datetime] NULL , [last_ip] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , CONSTRAINT [PK_login_list] PRIMARY KEY CLUSTERED ( [uid], [last_login] ) WITH FILLFACTOR = 90 ON [PRIMARY] ) ON [PRIMARY] GO Code:
SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO ALTER PROCEDURE [dbo].[ap_SLog] @uid int, @lastlogin datetime, @lastlogout datetime, @LastGame int, @LastWorld tinyint, @LastIP varchar(15) AS --Charis start declare @last_list int declare @old_last_login datetime declare @old_last_logout datetime declare @old_last_ip nvarchar(50) declare @msg nvarchar(214) SET @last_list = 0 if @lastlogin is null or isdate(@lastlogin)!=1 return select @old_last_login = last_login, @old_last_logout = last_logout, @old_last_ip = last_ip from user_account where uid = @uid if @old_last_login is not null and isdate(@old_last_login)=1 begin SELECT @last_list = 1 FROM login_list WHERE uid = @uid and last_login = @old_last_login if @last_list = 0 insert into login_list ([uid], [last_login], [last_logout], [last_ip]) VALUES (@uid, @old_last_login, @old_last_logout, @old_last_ip) SET @last_list = 0 end SELECT @last_list = 1 FROM login_list WHERE uid = @uid and last_login = @lastlogin if (@last_list <> 1) insert into login_list ([uid], [last_login], [last_logout], [last_ip]) VALUES (@uid, @lastlogin, @lastlogout, @lastip) else update login_list set last_logout = @lastlogout, last_ip = @lastip where uid = @uid and last_login = @lastlogin --Charis end UPDATE user_account SET last_login = @lastlogin, last_logout=@lastlogout, last_world=@lastWorld, last_game=@lastGame, last_ip=@lastIP WHERE uid=@uid GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
|
|
|
|
|