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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Posts

    • L2 Insignia High Five 20x MID SERVER FOCUSED ON OLYMPIAD | PVP | AUTOFARM       OPEN BETA TEST SERVER 3 MAY 2024   GRAND OPENING 10 MAY 2024    Rates: 📜 XP/SP 20x | Spoil 15x | Drop 10x | Adena 10x 📜     Server Features: 🔥 No Olf-T Shirt, No big over-enchant, No over-power Donate 🔥 🔥 VIP Gold Color Chat, Unique Olympiad Extra Points Engine, GvG Event 🔥 🔥 Auto-Farm, LoA and DV scheduled PvP Zone, Calendar Daily Reward 🔥 🔥 Castle Instance, Solo Instance, PvP Solo Rift, Dress me system, Adena Boxes 🔥        Website: https://www.l2insignia.com  Discord: https://discord.com/invite/yEgsrHn2hQ      
    • I am selling the essence project which includes versions 388 and 439 that have been running for over 2 years or (447 as custom PVP like Pride). I have a test server for you to test them out. If you are really interested in it then contact my seller at discord: kiwi7106. Price: 4000 Euro P/s: This is a project that I have spent a lot of money and time developing, so if you are not interested in it, please get out of this topic, thank you. P/s 2: If you find the price too expensive, it's best to skip this article and find another project and don't comment negatively on my topic, thank you.
    • Someone ask me for this, it should work on any client that has Kamael race, preview:     Installation - there are two ways to install depending on how you want to use it:   Method 1: If you want to completely replace the original, do:   Copy all lines from your armorgrp to Notepad++, press Ctrl+H, check the "match whole word" option and replace:   kamael.Mkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_MKamael_m001_w_ad00   Then replace:   MKamael.Mkamael_m000_t00_w   by:   AvengersKamaelWings.MKamael_m001_t00_w   Now repeat the same process with the female, replace:   kamael.Fkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_FKamael_m001_w_ad00   Then replace:   FKamael.Fkamael_m000_t00_w   by:   AvengersKamaelWings.FKamael_m001_t00_w   You're done, paste everything back into File Edit and save!   Method 2: If you only want to replace in specific sets, execute the above process only on the armorgrp of those sets.   Repack by: AvengersTeamBr Password: LadrãoDeFrango      
  • Topics

×
×
  • Create New...