Jump to content

L2OFF Online Statistics and Online Announcement


Recommended Posts

hello guys i decided to share a cool code for online statistics and Announcements!

Its something simple.

 

online statistics

 

Adding to DB:

 

 

CREATE PROCEDURE [dbo].[playersnumber]
--@pl_number int output
AS
--SELECT @pl_number=count(*) FROM user_data WHERE login>logout AND logout>0 AND login>0
SELECT count(*) FROM user_data with (nolock) WHERE login>logout
GO

 

 

And here is the Script...(Php)

PHP Code:

<?php

$flogin = fsockopen ("000.000.000.000",2106, $errno, $errstr, 1);//Instead 000.000.000.000 Ip Server
        if ( $flogin )
                $login_s = "Online";
        else
                $login_s = "Offline";

$fgame = fsockopen ("000.000.000.000",7777, $errno, $errstr, 1);
        if ( $flogin )
                $game_s = "Online";
        else
                $game_s = "Offline";


$mssql_server="000.000.000.000"; //Instead 000.000.000.000 Ip Server
$mssql_db="lin2world";
$CONN = mssql_connect($mssql_server, 'user', 'pass');
if ($CONN) {
mssql_select_db($mssql_db);
$result = mssql_query("exec playersnumber", $CONN);
$online=mssql_fetch_row($result);
$online=$online[0];
}
else $on_line = 0;

//image size $im = imagecreate(X, Y);
$im = imagecreate(100, 45);
$str = "Online: ";
// $bg - the background color, $textcolor - text color
$bg = imagecolorallocate($im, 213, 248, 225);
$textcolor = imagecolorallocate($im, 0, 0, 0);

// Output lines in the picture
//imagestring($im, The font size for the X coordinate, coordinate, Y, "Login: ", $textcolor);
imagestring($im, 3, 0, 0, "Login: ", $textcolor);
imagestring($im, 3, 53, 0, $login_s, $textcolor);
imagestring($im, 3, 0, 15, "Game: ", $textcolor);
imagestring($im, 3, 53, 15, $game_s, $textcolor);
imagestring($im, 3, 0, 30, $str, $textcolor);
imagestring($im, 3, 53, 30, $online, $textcolor);
// output the image
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?> 

 

 

Online Announcement

 

PHP Code:

 

 <?php 
DEFINE("SELECT_ONLINE","select count(*) from user_data where  account_id>0 and online=1"); 

function connectdb($db, $dbaddress, $dbuser, $dbpass){ 
$dbconnect = mssql_connect ($dbaddress, $dbuser, $dbpass); 
  mssql_select_db ($db, $dbconnect); 
  } 
   
connectdb('lin2world', '172.16.192.34', 'sawa', 'dfsdfFdvh'); 
$result = mssql_query(sprintf(SELECT_ONLINE)); 
$accounts = mssql_fetch_array($result); 
$accounts = trim($accounts[0]); 


send_announce("Now online: ".$accounts." users"); 

exit; 


function send_announce($announce){ 
$buf=pack("c",70).tounicode($announce); 
$cachedsocket=@fsockopen("172.16.192.3","2012",$errno,$errstr,1) or die($notconnected); 
fwrite($cachedsocket,pack("s",(strlen($buf)+2)).$buf); 
$len=unpack("v",fread($cachedsocket,2)); 
$rid=unpack("c",fread($cachedsocket,1)); 
  for($i=0;$i<(($len[1]-4)/4);$i++){ 
    $read=unpack("i",fread($cachedsocket,4)); 
      $rs.=$read[1]; 
       } 
       fclose($cachedsocket); 
} 


function tounicode($string){ 
  $rs=""; 
  for($i=0;$i<strlen($string);$i++) 
  $rs.=$string[$i].chr(0); 
  return($rs.chr(0).chr(0)); 
} 
?> 

 

Thats all!If i made mistakes let me know!

 

More shares soon

Link to comment
Share on other sites

I don't think it's a good way to define an "online" player:

SELECT count(*) FROM user_data with (nolock) WHERE login>logout

Same here:

DEFINE("SELECT_ONLINE","select count(*) from user_data where  account_id>0 and online=1"); 

I mean... It works in 99% of the cases, but the results can be random, count crashed players etc.

 

Regards,

Tomoya of L2Sublimity

 

Link to comment
Share on other sites

The hAuthD script works with any hAuthD version, and for what i know any server works with hAuthD.

 

hAuthd doesn't support Auto Registration - like GF AuthDaemon \  AuthGate does.

 

So there's that niche possibilty.

Link to comment
Share on other sites

hAuthd doesn't support Auto Registration - like GF AuthDaemon \  AuthGate does.

 

So there's that niche possibilty.

GF doesn't support it as well, it was some crap added by some of the previous owners of the files, not NcSoft, its just a stored procedure that has to me modified in order to disable that function. But we are talking about online status and players, what has to do that with ?

Link to comment
Share on other sites

GF doesn't support it as well, it was some crap added by some of the previous owners of the files, not NcSoft, its just a stored procedure that has to me modified in order to disable that function. But we are talking about online status and players, what has to do that with ?

 

hAuthd script only works with hAuthd.

And you try use the modified GPwdWithFlag with hAuthd tell me what happens.

 

Thus a similar script like this is needed - in those niches.

Link to comment
Share on other sites

I know but we were talking about online and offline scripts, not about auto-registration :D I was talking about the hAuthD script for online and offline status, beacause its the Auth that most people use.

The only thing that needs to be removed in that SP for deactivating the Auto-Registration feature is exec ap_AutoReg @account thats all, anyway  extending other Auth like C4 there is a posibility of adding such feature.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock