ID:135701
![]() Mar 31 2004, 11:23 am
|
|
In future byond, mabe an idea would be a hosting alert. You could add worlds to your alert system when that world is hosted it would send you an alert type of your choice by text in the chat window or alerts or you could just disable it if you wanted so if your busy and you dont want to remove and re-add all the worlds. Please, tell me your thoughts on my idea. I hope they might add this because alot of my favorite games are hosted and I never know!
|
You wouldn't even need a world to do this - just an ordinary PHP script, which there are many more hosts for than there are for BYOND games. =)
Then you could simply do something like this: <code>world OpenPort(port) spawn() world.Export( "http://www.yourhost.com/yoursite/hostalert.php\ ?url=[world.address]:[port]&hub=[world.hub]&game=[world.name]\ &version=[world.version]") .=..() Del() world.Export( "http://www.yourhost.com/yoursite/hostalert.php\ ?closing=1&url=[world.address]:[port]") .=..()</code> At the given URL, you'd have a simple PHP script that read in the data, put it in a database, and possibly even sent you an email alert or something if you wanted it to. Then you might have another PHP script which read the data back out of the database and displayed it. I might even get around to making it myself one day! =) |
Bear in mind for your solution to be robust you should also cover situations where OpenPort() closes the port (argument is "none", a string), and do regular polling of world.port to check for any change of status. Likewise you need some way of checking up on the game from the other end in case it disconnects and can't report that it's gone.
Lummox JR |
True. I forgot that OpenPort() does that, and I just whipped that up in a couple of minutes. If I ever make it properly, it will be better. =)
|
Ya, that would be eastist, or at least seem to be. This would make no need for a host capable of php and such. But perhaps i am misunderstanding his request.
|
Garthor wrote:
You could even just parse through the information on a game's hub entry at regular intervals. And we even provide a nice format for just this purpose! Just add ";format=text" to the end of a hub entry's url. For example, http://games.byond.com/hub/Xooxer/Chatters;format=text |
I actually did something like that a while ago.
It consisted of two files. AddWorld.php (Used for adding a world to the database.) <?php /*Get some variables*/ $name=$HTTP_GET_VARS['WorldName']; $Ip=$HTTP_GET_VARS['WorldAddress']; $Port=$HTTP_GET_VARS['Port']; /*Server Stuff*/ $dbhost = ''; $dbusername = ''; $dbpasswd = ''; $database_name = ''; $connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to."); /*Insert Infomation into database*/ $sql=mysql_query("INSERT INTO GamesOnline (Worldname, address, port) VALUES('$name', '$Ip', '$Port')") or die(mysql_error()); ?> CheckWorld.php (Used to view online worlds (and remove offline worlds)) <?php /*Get some variables*/ $name=$HTTP_GET_VARS['WorldName']; /*Server Stuff*/ $dbhost = ''; $dbusername = ''; $dbpasswd = ''; $database_name = ''; $connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to."); $sql="SELECT * FROM GamesOnline WHERE worldname='$name'"; $sql_results=mysql_query($sql,$connection); while($row=mysql_fetch_array($sql_results)){ $worldname=$row['Worldname']; $worldaddress=$row['address']; $worldport=$row['port']; $fp = @fsockopen(trim($worldaddress), $worldport, $errnum, $errstr, 3); if(!$fp){ /*Removes worlds that are not online from database.*/ $sql=mysql_query("DELETE FROM GamesOnline WHERE address='$worldaddress' AND port='$worldport'"); } else { /*Tells viewer world is online (Edit this with your own message*/ echo "$worldname is online!"; @fclose($fp); } } ?> As for the database structure, it went like this. CREATE TABLE `GamesOnline` ( `Worldname` VARCHAR(255) NOT NULL, `address` VARCHAR(255) NOT NULL, `port` VARCHAR(255) NOT NULL ) TYPE = MYISAM; That was pretty much it, I never did the BYOND side of it but should be pretty simple to do (When the world starts up simple send the worlds name, address and port to AddWorld.php (Like AddWorld.php?WorldName=[worldname]&WorldAddress=[worldaddres s]&Port=[worldport]) That code can only check if one game is online (although that game could be hosted multipul times), it can easily be edited to see if multipul games are online (just take the WHERE worldname='$name' out of $sql="SELECT * FROM GamesOnline WHERE worldname='$name'";). |
Yuugi wrote:
I actually did something like that a while ago. i believe Lum. Jr made that. >_> or something similar |
You know, it might be possible to make a library and world that would do that. Have the "hosting alert" world hosted on a computer all the time, then have the other worlds report in whenever they stat up, or whatever.