![]() |
|
|
#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
|
|
|
|
|
#2 |
|
Архивный участник
Join Date: Jan 2006
Posts: 607
|
I'll check it for sure! Thanks, will edit this post once I try it!
Works like a charm, really useful to keep track of all people who connected and their ips |
|
|
|
|
#3 |
|
Архивный участник
Join Date: Aug 2005
Posts: 394
|
It's cool i especially like the log system.. can be very useful
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: Jul 2006
Posts: 67
|
Been looking for something like this, thanks!
|
|
|
|
|
#5 |
|
Архивный участник
Join Date: May 2005
Posts: 979
|
too complicated ;-) better is this new C4 function
Code:
SELECT TOP 1 world_user as l2players FROM user_count WHERE server_id < 2 ORDER BY record_time DESC http://gameparkl2.no-ip.org/stats/online.php Grab this php code ;-) (make .ini file - in that file will be stored numbers temporary.. to be defended before dos attacks..) Code:
<?php
header("Expires: ". gmdate("D, d M Y H:i:s")." GMT");
$online["cache"] = @file("./temp/online.ini");
@list($online["last"]["check"], $online["last"]["online"]) = explode(";", $online["cache"][0]);
if($online["last"]["check"] == "" || $online["last"]["check"] < (time() - 60)) {
include("config.php");
mssql_select_db("lin2db");
$mssql["entry"] = mssql_fetch_array(mssql_query("SELECT TOP 1 world_user as pocet FROM user_count WHERE server_id < 2 ORDER BY record_time DESC;"));
$online["online"] = $mssql["entry"]["pocet"];
echo "<body bgcolor=\"#272727\">";
echo "<font face=\"verdana\" size=\"2\" color=\"#dd6900\"><center><b>Online: ".$online["online"]."<br><font size=-2>(record: 800+)</b></center></font></body>";
chdir("c:/www/stats/");
$f = fopen("./temp/online.ini", "w");
fputs($f, time().";".$online["online"]);
fclose($f);
} else {
echo "<body background=\"http://lineage2.ratafak.net/images/bg-mini.gif\">";
echo "<body bgcolor=\"#272727\">";
echo "<font face=\"verdana\" size=\"2\" color=\"#dd6900\"><center><b>Online: ".$online["last"]["online"]."<br><font size=-2>(record: 800+)</b></center></font></body>";
}
?>
|
|
|
|
|
#6 |
|
Архивный участник
Join Date: May 2005
Posts: 979
|
config.php
Code:
<?php
header("Expires: ". gmdate("D, d M Y H:i:s")." GMT");
$mssql["server"] = "hostname_here";
$mssql["user"] = "";
$mssql["password"] = "";
$mssql["database"] = "lin2db";
$mssql["die"] = "Error when connecting to db...";
mssql_connect($mssql["server"], $mssql["user"], $mssql["password"]); // or die($mssql["die"])
mssql_select_db($mssql["database"]);
?>
|
|
|
|
|
#7 |
|
Архивный участник
Join Date: Feb 2006
Posts: 39
|
May be I don't understand what do you meen,
But I guess that we are talking about different things. BTW there is not only fix for online status issue
|
|
|
|
|
#8 |
|
Архивный участник
Join Date: Jan 2006
Posts: 607
|
I correct your query Fidow (has some writing error
)Code:
SELECT TOP 1 world_user FROM user_count WHERE record_time = (SELECT MAX(record_time) FROM user_count) AND server_id = 1; |
|
|
|
|
#9 | |
|
Архивный участник
Join Date: Apr 2006
Posts: 120
|
Quote:
Code:
SELECT TOP 1 world_user FROM user_count WHERE server_id = 1 ORDER BY record_time DESC |
|
|
|
|
|
#10 |
|
Архивный участник
Join Date: Mar 2006
Posts: 104
|
Small fix to your SQL.
Hardly noticable, but it may have been a character's first login, in that event logout would be null. Code:
-- Charis start update lin2world.dbo.user_data set logout = getdate() where login > logout -- Charis end Code:
update lin2world.dbo.user_data set logout = getdate() where login > isnull(logout, 0) |
|
|
|
|