Jump to content

Recommended Posts

Posted

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

Posted

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

 

Posted

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.

Posted

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 ?

Posted

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.

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • In your place l will join to Mobius community to get something decent or just go to Lucera 2 ( ofc no source) if you want interlude on Classic client, coz Acis not have have it yet.
    • The client and the system aren't working very well; the screen is black, and some things aren't loading.  😞 
    • LINEAGE2.SK Summer Season is Comming! GRAND OPENING - 14.08.2026 at 20:00 GMT+1  OBT - 07.08.2025 at 20:00 GMT+1   Website :https://lineage2.sk Discord : https://discord.gg/gj7AC5juGP       Server Features and Rates Xp – 20x Sp – 20x Adena – 10x Drop – 15x Spoil - 15x  Epic Raid Boss  - 1x Regular RB - 5x  Quest - 5x Fame - 2x Epaulette - 15x Manor - 15x     Special Features Somik Interface Limited AutoFarm Vote System Champions System Achievement System And more in information below     Enchant Settings  Safe Enchant: +3  Max Enchant: +16 Enchant Chance: 63%  Attribute Stone Chance: 50%  Attribute Crystal Chance: 30%     NPC Buffer all buffs, songs, dances including 3rd prof + resists Buff Slots: 24 (+4) / 12 Buff Duration: 2 Hours     Epic Bosses & Respawns Queen Ant: 24 hours +/-8h Core: 3 days +/-8h Orfen: 2 days +/-8h Baium: 5 days +/-8h Beleth: 7 days +/-8h Antharas: 7 days +/-8h Valakas: 7 days +/-8h     Instances Zones Zaken: 6 players Normal Freya: 6 players Hard Freya: 12 Players Frintezza: 6 Players Tiat: 6 Players Beleth: 12 Players     GM Shop weapon/armor/jwl (max S grade) shots/spiritshots (max S grade) mana potions (1000 MP, 10s)      Global Gatekeeper all towns including cata/necro ToI Gracia Hellbound ...     Olympiad period 7 days (Monday) no class participants min 6 base class participants min 6 max enchant +6 Start points 20     Class Transfer for Adena     Subclass Quest Not required Max Subclass 3 Subclass Max LvL 85     Events Team vs Team Capture the Flag Death Match Last Hero Korean Style Treasure Hunt      Clans All new clans start with Clan LvL 5! Clan Skills/LvL for Clan Coins     Others  max 3 windows per HWID  BoM/MoM spawned in towns Auto-learn skills Autoloot Retail LvL of Epic Bosses Cancellation return buff system (30sec) Cancellation return buff -  not effect olympiad
    • LINEAGE2.SK Summer Season is Comming! GRAND OPENING - 14.08.2026 at 20:00 GMT+1  OBT - 07.08.2025 at 20:00 GMT+1   Website :https://lineage2.sk Discord : https://discord.gg/gj7AC5juGP       Server Features and Rates Xp – 20x Sp – 20x Adena – 10x Drop – 15x Spoil - 15x  Epic Raid Boss  - 1x Regular RB - 5x  Quest - 5x Fame - 2x Epaulette - 15x Manor - 15x     Special Features Somik Interface Limited AutoFarm Vote System Champions System Achievement System And more in information below     Enchant Settings  Safe Enchant: +3  Max Enchant: +16 Enchant Chance: 63%  Attribute Stone Chance: 50%  Attribute Crystal Chance: 30%     NPC Buffer all buffs, songs, dances including 3rd prof + resists Buff Slots: 24 (+4) / 12 Buff Duration: 2 Hours     Epic Bosses & Respawns Queen Ant: 24 hours +/-8h Core: 3 days +/-8h Orfen: 2 days +/-8h Baium: 5 days +/-8h Beleth: 7 days +/-8h Antharas: 7 days +/-8h Valakas: 7 days +/-8h     Instances Zones Zaken: 6 players Normal Freya: 6 players Hard Freya: 12 Players Frintezza: 6 Players Tiat: 6 Players Beleth: 12 Players     GM Shop weapon/armor/jwl (max S grade) shots/spiritshots (max S grade) mana potions (1000 MP, 10s)      Global Gatekeeper all towns including cata/necro ToI Gracia Hellbound ...     Olympiad period 7 days (Monday) no class participants min 6 base class participants min 6 max enchant +6 Start points 20     Class Transfer for Adena     Subclass Quest Not required Max Subclass 3 Subclass Max LvL 85     Events Team vs Team Capture the Flag Death Match Last Hero Korean Style Treasure Hunt      Clans All new clans start with Clan LvL 5! Clan Skills/LvL for Clan Coins     Others  max 3 windows per HWID  BoM/MoM spawned in towns Auto-learn skills Autoloot Retail LvL of Epic Bosses Cancellation return buff system (30sec) Cancellation return buff -  not effect olympiad
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..