|
||
|
|||||||
| General Discussion General discussion for the RunUO community, all off-topic posts will be deleted. This forum is NOT FOR SUPPORT! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Join Date: Dec 2004
Location: Sweden
Posts: 117
|
i started to wonder how you check the current players online outside of game. ive seen a Bot that does this on a channel on Quakenet. but i dont know where the client checks the current players. any sugestions?
|
|
|
|
|
|
#2 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
|
Here's a PHP example of how to get this info. If you know enough about C/C++/C# you can write an app (or a plugin for an existing client like an mIRC dll) to connect to IRC and display this info.
Online status and players online
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
|
|
#3 (permalink) | |
|
Forum Expert
Join Date: Mar 2005
Location: York, UK
Age: 28
Posts: 708
|
Quote:
You will need thorough knowledge of raw irc commands (not mIRC commands). Either way when you get it done the possibilities are endless. Unfortunatly our project is classed strictly private, and I am not at liberty to discuss the other functions of it. I can however assure you that succesfully coding this leads to a major improvement of your shards functionality. I can also state with extreme confidence that there is no other shard out there that has a better irc bot running from the runuo code then ours does. (Little moment of pride, sorry )Of course you could also dump data in an mysql database and extract it with another bot such as eggdrop from there. We chose coding it in c# inside the runuo code so that we could interact both ways, not just relay information to an irc channel. |
|
|
|
|
|
|
#4 (permalink) |
|
Forum Novice
Join Date: Mar 2004
Location: Germany
Age: 23
Posts: 301
|
http://thresher.sourceforge.net/
There are already C# classes for IRC connectivity. It's threaded so it should perfectly co-exists with RunUO and can simply be used in on of the scripts. It contains several examples, so it should be really easy to implement. Have fun ![]()
__________________
RunUO RemoteAdmin - Control your shard remotely and keep an eye on the page queue MulEditor - Modify gump, art, tiledata, multimap, localization files and map/statics. CentrED - A Client/Server based multi-user map editor. |
|
|
|
|
|
#5 (permalink) | |
|
Forum Expert
|
Quote:
![]() |
|
|
|
|
|
|
#6 (permalink) | |
|
Forum Novice
Join Date: Jan 2005
Location: The People's Republic of Massachusetts
Age: 33
Posts: 158
|
__________________
So long and thanks for all the fish. :D 時々私poop Quote:
|
|
|
|
|
|
|
#8 (permalink) |
|
Forum Expert
Join Date: Sep 2002
Age: 23
Posts: 1,472
|
Here's a very basic bot that will listen for commands to be sent over an IRC channel, and reply with things like usercount. It's an early-on modification of a script by Mark called PageBot.
Code:
using System;
using Server;
using System.IO;
using System.Net;
using Server.Network;
using System.Threading;
using System.Net.Sockets;
namespace Server.Misc
{
public class StatusBot
{
public static string Nickname = "StatusBot";
public static string Username = "StatusBot";
public static string Realname = "StatusBot";
public static string Channel = "#shard";
public static string Server = "irc.serveraddress.net";
public static int Port = 6667;
public static string NickservPassword = null; // If you want to register StatusBot with nickserv, enter the password you registered the nickname to here.
public static bool ReconnectOnDisc = true;
public static bool Connected = false;
public static TimeSpan SpamDelay = TimeSpan.FromSeconds( 5.0 ); // StatusBot only accepts one command every 5 seconds, so users won't spam it.
public static DateTime LastCommand;
public static string Message = "";
public static void Initialize()
{
Thread t = new Thread( new ThreadStart( Connect ) );
t.Start();
}
private static StreamReader SR;
private static StreamWriter SW;
public static string FormatTimeSpan( TimeSpan ts )
{
return String.Format( "{0:D2} Days, {1:D2} Hours, {2:D2} Minutes, and {3:D2} Seconds", ts.Days, ts.Hours % 24, ts.Minutes % 60, ts.Seconds % 60 );
}
public static void Connect()
{
try
{
TcpClient C = new TcpClient( Server, Port );
NetworkStream S = C.GetStream();
SW = new StreamWriter( S );
SR = new StreamReader( S );
}
catch
{
Thread.Sleep(60000);
Connect();
}
Connected = true;
SendRaw( "USER "+Username+" 0 * :"+Realname );
SetNick( Nickname );
if (NickservPassword != null)
Identify( NickservPassword );
JoinChannel( Channel );
GetInput();
}
public static void Stop()
{
Connected = false;
SR.Close();
SW.Close();
}
private static void GetInput()
{
try
{
while ( Connected && ParseIncoming( SR.ReadLine() ) );
}
catch( Exception )
{
// Something's Wrong... Probably Disconnected
Connected = false;
}
if ( ReconnectOnDisc )
{
Thread.Sleep(60000);
Connect();
}
}
private static bool ParseIncoming( string inputLine )
{
if ( inputLine == null )
return false;
string[] parts = inputLine.Split(':');
if ( parts.Length == 3 )
Message = parts[2];
else
Message = "";
if( inputLine.StartsWith( "PING" ) )
SendRaw("PONG "+ inputLine.Substring(6));
if ( Message.StartsWith( "!" ) && LastCommand + SpamDelay <= DateTime.Now )
ReadCommand( Message );
return true;
}
private static void ReadCommand( string inputLine )
{
int userCount = NetState.Instances.Count;
string uptime = FormatTimeSpan( DateTime.Now - Clock.ServerStart );
LastCommand = DateTime.Now;
switch( inputLine.ToLower() )
{
case "!status":
{
SendMessage( Channel, String.Format( "Users Online: {0} .:. Uptime {1} .:. -[StatusBot]-", userCount, uptime ) );
break;
}
}
}
private static void SendRaw( string Message )
{
try
{
if ( Connected )
{
SW.WriteLine( Message );
SW.Flush();
}
}
catch
{
// Something's Wrong... Probably Disconnected
Connected = false;
}
}
private static void Identify( string Password )
{
SendMessage("Nickserv", "Identify " + Password );
}
private static void JoinChannel( string C )
{
SendRaw( "JOIN "+C );
}
private static void PartChannel( string C )
{
SendRaw( "PART "+C );
}
private static void PartChannel( string C, string Message )
{
SendRaw( "PART "+C+" :"+Message );
}
private static void Quit()
{
SendRaw( "QUIT" );
Stop();
}
private static void Quit( string Message )
{
SendRaw( "QUIT :"+Message );
Stop();
}
private static void SendMessage( string Target, string Message )
{
SendRaw( "PRIVMSG "+Target+" :"+Message );
}
private static void SendNotice( string Target, string Message )
{
SendRaw( "NOTICE "+Target+" :"+Message );
}
private static void SetMode( string Target, string Modes )
{
SendRaw( "MODE "+Target+" :"+Modes );
}
private static void SetNick( string N )
{
SendRaw( "NICK "+N );
}
}
}
|
|
|
|
|
|
#10 (permalink) | ||
|
Forum Novice
Join Date: Jan 2005
Location: The People's Republic of Massachusetts
Age: 33
Posts: 158
|
Quote:
~Jason
__________________
So long and thanks for all the fish. :D 時々私poop Quote:
|
||
|
|
|
|
|
#11 (permalink) | |
|
Forum Expert
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
|
Well along with all the other crap I am working on, I am also working on a IRC bot based off of PHP that works for the most part. Currently though it is just a hacked together version that is kind of hard to understand and I am in the process of rewriting it. However, the most efficient way to use it (since it is based off a webserver) is if you are able to use cron jobs so that the script will restart once a day, in case it loses connection (or you can manually restart it). This way your RunUO server isnt wasting resources or bandwidth on an IRC bot. Ill release this eventually, so hopefully I get in a coding mood and get this and the online server status script done lol.
If you are going to do it yourself though, make sure you know a bit about IRC protocol cause I dont think it is quite uniform for every command, which makes it annoying when processing commands (although it might be easier in C#, cause i noticed that inputLine.StartsWith function)... Here are some useful websites though: http://www.mirc.net/raws/ http://www.irchelp.org/irchelp/rfc/rfc.html [edit] Quote:
Just my two cents... Last edited by mordero; 03-04-2006 at 06:34 AM. |
|
|
|
|
|
|
#12 (permalink) | ||
|
Forum Expert
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
|
Quote:
OR just check when someone asks the bot if there is any users online like says !Users or /msg Bot !Users
__________________
Quote:
Just a Simple Staff Tool You can leave me messages. Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else." |
||
|
|
|
|
|
#13 (permalink) | |
|
Forum Expert
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
|
Quote:
|
|
|
|
|
|
|
#14 (permalink) | |
|
Forum Novice
|
Quote:
__________________
Meh. |
|
|
|
|
|
|
#15 (permalink) | ||
|
Forum Expert
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
|
Quote:
__________________
Quote:
Just a Simple Staff Tool You can leave me messages. Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else." |
||
|
|
|
|
|
#16 (permalink) |
|
Forum Expert
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
|
That would also work because that is what we currently use. However, then you have the problem of people asking the ops to see how many people are online. To avoid this you could make the op only for the channel but also allow people to PM the bot and have the number sent by PM to the user.
|
|
|
|
|
|
#17 (permalink) |
|
Forum Novice
Join Date: May 2005
Age: 36
Posts: 220
|
Here's a question regarding to this. I'm just wondering... Why an IRC bot? Isn't there any way possible to create a script that can log into a designated account an admin creates on a shard, that can perform the same functions?
|
|
|
|
|
|
#19 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
|
If you are interested in displaying the current number of players online VIA your website, this information is now available free from ConnectUO.com.
All you have to do is register your shard (like UOgateway and/or TopShards). Www.ConnectUO.com for more info.
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
|
|
#21 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
|
I always found it a big pain to upload the status page to the webserver. I think most other people find that a PITA or just don't know how.
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
|
|
#23 (permalink) |
|
Forum Newbie
Join Date: Jul 2004
Age: 25
Posts: 48
|
Well for those who want to publish their status.html file and don't know how, here's how, provided you run your UO server on the same machine as your webpage. Open WebStatus.cs and search for the following line:
Code:
using ( StreamWriter op = new StreamWriter( "web/status.html" ) ) )Code:
using ( StreamWriter op = new StreamWriter( @"D:\webroot\uo\status.html" ) ) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|