Jump to content

Need PHP Script for Online Players in L2 Site


eromad

Recommended Posts

many servers use this script:

<?php
echo "<b>Real</b> Online Players in Server: ".(1200+rand(1,100));
?>

or u can use this:

cronjob.php

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    file_put_contents("online.txt",'0');
}

$result = $conn->query("SELECT COUNT(`online`) as online_ppl FROM `characters` WHERE `online`='1'");
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
  file_put_contents("online.txt",$row['online_ppl']);
    }
} else {
	file_put_contents("online.txt",'0');
}
$conn->close();
?>

https://www.w3schools.com/php/php_mysql_select.asp

example every 5~10min.

and then print in website

<?php
echo file_get_contents("online.txt");
?>

 

Link to comment
Share on other sites

This is dangerous each website visitor will open a server connection, in case of website DDOS your server is good as dead.

  • Haha 1
Link to comment
Share on other sites

1 hour ago, Nightw0lf said:

This is dangerous each website visitor will open a server connection, in case of website DDOS your server is good as dead.

how with my solution it can be? :D

Link to comment
Share on other sites

On 3/31/2020 at 1:47 PM, wongerlt said:

how with my solution it can be? :D

The ideal concept is to make a php script and then create a cron job to run this script every 5min for example and the php will create in a file the statistics you want, after that you can print the file as you like.

See how this concept avoids public interaction with server database?

 

also i dont recommend mysqli use PDO instead with try/catch so your passwords wont be printed on connection failures :laughing:

Link to comment
Share on other sites

did you even look his code? its exactly what you described, it dumps results to file, he even called his example file "cronjob"

 

cleaned example above: https://pastebin.com/raw/Si8w8emv

Edited by AlmostGood
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.



  • Posts

    • Good morning, how do I use it to open a npcname.txt file from l2 c1? I made some progress and understood that I must create a bat file with the following specifications: l2encdec_old -e 121 npcname-e.txt   When I run the .bat it creates a new enc-npcname-e.txt  But when I open it, I still can't read the files Is there something wrong with the code I ran?    
    • Hello! Since this video with those cool agathions belongs to Asuki, better ask him if they are private or free. As for me, since KejbL mentioned me, I've also done a lot of work of this kind, such as body-attached auras in the form of agathions like in the video and cool versions that attach to the back like agathions as well. If you're interested, I can show you some examples.
    • Server Rates: » Xp 500x. » Sp 500x. » Aden 500x. » Drop 1x. » PartyXp 2x. » PartySp 2x. » Starting character level -1 Enchant rates: » Safe enchant +4. » Blessed and simple scrolls max enchant (+16). » Crystal scrolls max enchant (+16). » Simple enchant scrolls chance – 65%. » Blessed enchant scrolls chance – 80%. » Crystal enchant scrolls chance – 90% Augmentations: » High life stone skill chance – 10%. » Top life stone skill chance – 15%. » Augments 1 active   1passive Unique features: » Main town – Giran » Automatic-Manual Potions. » Working 2 castle sieges. (Giran-Aden) » SPS cancel lasts 10 seconds and than buffs come back. » Stackable scrolls, lifestones, book of giants. » Unique pvp zone » More then 11 active raid bosses. » Wedding system. » Unique farming areas. » Npc skill enchanter. » Full npc buffer with auto buff. » Max count of buffs – 55. » Max subclasses – 4. » Free and no quest class change. » Free and no quest sub class. » Raid boss drop nobless item. » No weight limit. » Unique protection anti-hwy armor for archers/daggers etc. » Ingame password change. » Top pvp/pk/online ranks NPC. » Unique monsters & NPC. » Interlude retail skills. » Server up-time [24/7] [99]%. » Perfect class balance (all class can kill all class depending on players skill and setup knowledge,gear,augmentations). » Announcements on double kills triple kills etc. » Announcements on Grand Boss death , with the name of the killer as well as clan name of the player. » Information Npc in game with all servers infromations.   🌐 https://l2-prodigy.com ✅ https://discord.gg/bEphbJ4WY7
    • Good morning, how do I use it to open a npcname.txt file from l2 c1? Good morning, I made some progress and understood that I must create a bat file with the following specifications: l2encdec_old -e 121 npcname-e.txt   When I run the .bat it creates a new enc-npcname-e.txt  But when I open it, I still can't read the files Is there something wrong with the code I ran?    
    • It's on formula the skill launch time, if you decrease it, you won't see the whole visual effect, close please.
  • Topics

×
×
  • Create New...