Shako 97 Report post Posted October 15, 2016 Hello guys! I'm just trying to figure out how to write a simple server information script. I want to put each aspect into their own separate variables. Such as: $online_players = "Amount_of_online_players_in_server" $characters_server = "The amount of characters in the server" All with mssql queries. Quote Sunny Go! Online pko.host Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted October 15, 2016 Hello @Shako! Here you are: <?php // MSSQL Server settings $db_host = ''; $db_user = ''; $db_pass = ''; // Our statistics $online_number = 0; $total_number = 0; // Let's connect to DB $db_connection = @mssql_connect($db_host, $db_user, $db_pass); if ($db_connection == false) { die('<b>Error:</b> Cannot connect to MSSQL Server!'); } // Getting online character number $sql = 'SELECT COUNT(*) as number FROM GameDB.dbo.character WHERE mem_addr > 0'; $query = @mssql_query($sql); if ($query == false) { die('<b>Error:</b> Cannot make query to get online character number!'); } $row = mssql_fetch_object($query); $online_number = $row->number; // 'number' is the name of field in query 'SELECT COUNT(*) as number ...' // Getting total character number $sql = 'SELECT COUNT(*) as total FROM GameDB.dbo.character WHERE delflag = 0'; $query = @mssql_query($sql); if ($query == false) { die('<b>Error:</b> Cannot make query to get total character number!'); } $row = mssql_fetch_object($query); $total_number = $row->total; // Closing DB connection (not neccessary) mssql_close($db_connection); ?> <html> <head> <title>Server statistics</title> </head> <body> <h1>Server statistics</h1> <p>Total characters: <?php echo $total_number; ?></p> <p>Online characters: <?php echo $online_number; ?></p> </body> </html> 2 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
Shako 97 Report post Posted October 15, 2016 @V3ct0r Amazing! I will try it out soon. Also, for example I want to make a web link: https://mywebsite.com/page.php into something like https://mywebsite.com/index.php?act=page How would I do it? Thanks! Quote Sunny Go! Online pko.host Share this post Link to post Share on other sites
Shako 97 Report post Posted October 15, 2016 (edited) @V3ct0r it works. Big thanks! One more question,, how do I make Max Players Online? and would it be better to keep these information in a text database cached every X seconds? Edited October 15, 2016 by Shako Quote Sunny Go! Online pko.host Share this post Link to post Share on other sites
Totoka 152 Report post Posted October 15, 2016 (edited) Quote and would it be better to keep these information in a text database cached every X seconds? 1: use a middleware file with a timestamp inside(try to lock, and unlock it when you finish *if your lock success) if your LOCK success, compare dates ( now > lastupdate + X seconds ? and then re-call you query and store its result into a file, otherwise use a cached one 2: make a crontab/cron or winTask pointed to an script who record these result into cache files every X time ------------------------------------ a deleted answer was here ---------------------------------------- [I never noticed that was max online characters ] Quote One more question,, how do I make Max Players Online? Does your/s server work with [stat_log]? if it does: SELECT MAX(play_num) MaxChaOnline FROM [stat_log] Edited October 15, 2016 by Totoka +link 1 Quote Discord: andresc Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted October 15, 2016 7 часов назад, Shako сказал: @V3ct0r Amazing! I will try it out soon. Also, for example I want to make a web link: https://mywebsite.com/page.php into something like https://mywebsite.com/index.php?act=page How would I do it? Thanks! Do you use PKOSite? You can make a new page with statistics following the example of existing pages. Цитата One more question,, how do I make Max Players Online? As @Totoka wrote, you can use SQL query: SELECT MAX(play_num) as max_online FROM GameDB.dbo.stat_log $max_online = 0; // Getting max online record $sql = 'SELECT MAX(play_num) as max_online FROM GameDB.dbo.stat_log'; $query = @mssql_query($sql); if ($query == false) { die('<b>Error:</b> Cannot make query to get total max online record!'); } $row = mssql_fetch_object($query); $max_online = $row->max_online; <p>Max online: <?php echo $max_online; ?></p> Цитата and would it be better to keep these information in a text database cached every X seconds? Sure. It will increase the performance and reduce the load 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
Napoleon 0 Report post Posted October 16, 2016 Looking for this also.. Quote Share this post Link to post Share on other sites