RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Online status and players online

mordero

Knight
Online status and players online

Ok, well i dont know how many people will want to use this or not, but i thought it might be nice to share since it is Christmas :D. What it does is open a connection to a server (doesnt have to be a RunUO to determine if it is online) and then if it is a RunUO server, it retrieves the number of players online. The header pretty much explains everything i think and i put enough comments for even a beginner to understand. One quick note though, is i am not sure what I am sending to the server to get the number of players online except it is UOGateway sends when it checks the status.

So here it is and if anyone has any questions, dont be afraid to ask, but im a definately no expert. Some initial tips though are: make sure the directory that it is in is chmod 777 so the cache file can be created (although you might be able to create it youself and not worry about that, i didnt test that though);make sure your webserver supports allowing php to use sockets because some dont; and dont ever use 0 for the interval except for testing because this means every new page load will connect to your server, which isnt good. Be sure to change the extension to php instead of txt (the forums dont allow uploading php extensions).

Oh and yes it might be faster if i didnt do some of the checks and various things i did, but i wanted to make it simple when you use it, so you dont have to set all of the options, since it will do it automactially.

Edit: Alright well here is the updated version in the zip, you need to upload both the install and the checkserver.php. Also make sure the directory is 775 otherwise you actually have to mess with some stuff manually (deleting and making a config file). It will tell you if it cant write these files and such. Be sure that the table name and the cache file name are unique cause i didnt do any checks so i dunno what will happen and make sure that atleast one or the other is checked. If both are checked, then the cachefile is used as a backup incase the database fails. Only the mySQL database is supported (i have version 4.0.24, but it should work with any, if not, please tell me what the error says), and i have no plans of supporting any others since i believe this is the most popular and i dont have access to anyothers.


UPDATE: I got rid of the install script cause too many variables to check if it doesnt work, now all you have to do is drop it in a directory, read the header of checkserver.php, change your values in the config file, and you should be set. Shouldnt be hard at all if you know anything about php and Ill try to answer questions if i can. I know I havent updated this in a while (and this isnt much of an update anyways), but Ill see if I can be around more now. Oh and I didnt test these changes at all (cause they were small) so if you notice something weird, let me know.
 

Attachments

  • morderoStatusChecker.zip
    4.6 KB · Views: 399

Bham

Sorceror
question

Thank you so much for this script I would love to use it but have a question, What do I edit and where should I put this on my site? Can you do a readme file for this please.

sorry im a newb when it comes to php
 

mordero

Knight
Ok, well first off, your site needs to support php of course, and you need to be able to edit the php to add this in (or if your CMS allows you to add php into blocks). Anyways, you could add this anywhere on your page that you want. Ill give you an example of what you could do.

First checkserver.php needs to be in the same directory for this example to work...

Example page (ill use where i play as an example):
PHP:
<?php
include "checkserver.php";
$defaults = array('host'=> "shadowsofsunder.game-host.org",//the IP/Host of the server
'link'=> "7E51EA873A8989EA32F1742DA37CEE31",//this is the UOGateway ID of the server);
$checkserver = new checkserver($defaults);
?>
<html>
<head>
<title>Server Status</title>
</head>
<body>
Status:
<?php
$status = $checkserver->statusCheck;
//this returns the string "STATUS [PLAYERS ONLINE] ---Ex. Online [5]
print $status;//print it
?>
</body>
</html>
This is the most basic page for it, so if you want to include the status on your main page or some such, you just need to do this:

Near the beginning of the index
PHP:
<?php
include "checkserver.php";
$defaults = array('host'=> "shadowsofsunder.game-host.org",//the IP/Host of the server
'link'=> "7E51EA873A8989EA32F1742DA37CEE31",//this is the UOGateway ID of the server);
$checkserver = new checkserver($defaults);
?>

Insert this where ever you want to print the status
PHP:
print $checkserver->statusCheck;

Oh and I guess there is kind of one bug with the script, that ill check out someday. Sometimes, the page will load before it is finished pinging and all that, so the user will have to refresh. Its not really that big of deal though.

If you need anymore help, just ask :)
 

orgis

Wanderer
this looks great ! i use php-nukewhichuses blocks do you have any idead how to implement it into this type of site?
 

mordero

Knight
Yeah, you will have to give me a bit though, cause i am really busy up till next Thursday (exams and work :S), but I think it should be a really easy to change it over from what I have been reading on the php-nuke site.

Since I am going to be doing this for php-nuke, I think I am also going to change the normal one to be able to use a database as well for all this and create a install script to make it easier to configure it, that way you really don't need to know much about php.

Edit (2/23/06): Ok, been more busy than I thought I would be, but I have the database support working and a rough installation script, so all i need to do now is see what I need to do for it to work for Nuke)
 

Pox151515

Sorceror
It doesnt seem to be displaying anything. Either the script isn't pinging the server, or the ping information isn't displaying. It shows the word "Status:" But nothing else. I changed the IP to the correct IP. Same with the UOG link. I'd really like to use this script. Sorry for bumping this month old thread lol.
 

mordero

Knight
no no, i should have updated this thing a while ago, but i never had time. But try adding "//" to the first line in the script and running it and seeing if an error comes up...
 

Pox151515

Sorceror
//class checkserver {


Parse error: parse error, unexpected T_VAR in /home/www/abcuo.awardspace.com/checkserver.php on line 3
 

mordero

Knight
oh crap, nevermind, i didnt know i already had the error reporting turned off... so do this... copy and paste this into a page

<?php
phpinfo();
?>

and save that as info.php, upload it and go to the page and make sure that in the "Configure Command" row there is "--enable-sockets"
 

Pox151515

Sorceror
Configure Command '--enable-sockets' Among other things. lol But yes that is there in that big list of things. Still nothing is displaying after it says "Status:"

How many files need to be here to work? I have:
Index.html
checkserver.php
servcheck.txt
Info.php

servcheck has nothing written in it.
 

mordero

Knight
Ok I thought it might be a file permission issue (the directory needs to be chmod 775), but if the file is being creating this isnt the case, so i am not sure why this would be happening. Try the new version and see if you can get it to work...
 

Pox151515

Sorceror
Gets to "Installing mordero's RunUO Server Status Checker" And then sits there. Is it supposed to do something? And what do you mean the directory needs to be "chmod 775". As in this all has to be in a folder named "chmod 775"? I cannot make folders with spacing in the name.. I will look around on my host and see what I can learn.

But I put all that in and it still comes up "Status:" and thats it. Doesn't even ping my server.
 

mordero

Knight
chmod stands for change mode and is used for file permissions. The folder can be named whatever you like.

copy and paste this into a file in the same directory as your checkserver.php

PHP:
<?php
include "checkserver.php";
$checkserver = new checkserver(false);
print "Complete string: " . $checkserver->statusCheck() . "...<br />\n";
print "Just status: " . $checkserver->status . "...<br />\n";
print "Player's online: " . $checkserver->playersOnline . "...<br />\n";
?>

and give me the output for it. I have no idea why it isnt working... and if you dont mind me asking have you ever worked with php before?
 

Pox151515

Sorceror
Complete string: Offline...
Just status: 0...
Player's online: -1...

I thought it would be obvious that I havent worked with php before. hehe sry.

I even changed the timer part to "1" instead of "1800" to try and see if it was that at all, but that changed nothing. I look on my RunUo console. And it shows nothing. Right now my shard is not public so no one goes on so I'd be able to tell.. No activity at all.
 

mordero

Knight
Ok well since it says it is offline that means the ping isnt getting to your server and thats why you arent seeing anything... you need to look at the config file and make sure that the host is the correct ip or hostname
 

Pox151515

Sorceror
Yes everything is input right. If you want to know the IP its. empireuo.no-ip.info. Server name Empire Uo. website = http://empire.awardspace.com.

I dont know whats wrong with it. Has anyone got this working?

Sorry if Im bugging you. If you dont feel like helping me out anymore thats all good. I can go without the server status on the website =p =[
 

mordero

Knight
Lol, no its fine, I dont mind helping you, but i have 3 exams this week plus classes and work, so I wont be able to even look at this really for a bit. But Ill see if iI can get it to detect your server and see what happens. I really dont know if there is something you need to set up on the RunUO side of things to make this work, but I think I found a function in PHP that will verify that your webhost can use those certain functions, so ill include that in the next version to check for compatability with the host of the site.
 

Pox151515

Sorceror
Alright cool that would be awesome. And I got a crap load of work to catch up on too. =[ I havent even had my shard up for the past like 4 days. C# class ftl lol Doing. "do...while" statements right now. So annoying lol. But thanks for all the help!
 
i really cant get this to work eaither any help? i do what you say but i dont get anything on the index.php in teh same DIR, the databse has installed correctly but when i go to index.php i dont get anything at all
 

mordero

Knight
ahhh finally back... ok, i dont know how much time i am going to have to do this, but im gonna try to rewrite the installation script to make some more sense and make it easier and to also check to make sure you can actually use this. If you cannot get it to work still and until i figure this out, check out the other status check but remember, that it wont cache any results so everytime your page is refreshed, thats another ping to your server
 
Top