HellRazor said:Don't let Jason bother you, flames like that are typical of him. I'm surprised the mods haven't banned the guy already.
:lol:
Code:
using System;
using System.Net;
using System.Net.Sockets;
using Server;
using Server.Network;
namespace Server.Misc
{
public class ServerList
{
/* Address:
*
* The default setting, a value of 'null', will attempt to detect your IP address automatically:
* private const string Address = null;
*
* This detection, however, does not work for servers behind routers. If you're running behind a router, put in your IP:
* private const string Address = "12.34.56.78";
*
* If you need to resolve a DNS host name, you can do that too:
* private const string Address = "shard.host.com";
*/
public const string Address = "123.123.123.123";
public const string LocalServerAddress = "123.123.123.123";
public const string ServerName = "Shard Name";
public static void Initialize()
{
Listener.Port = 2593;
EventSink.ServerList += new ServerListEventHandler( EventSink_ServerList );
}
public static void EventSink_ServerList( ServerListEventArgs e )
{
try
{
IPAddress ipAddr;
IPAddress LocalAddress = IPAddress.Parse( LocalServerAddress );
if ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
{
e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
e.AddServer( "Local Server", new IPEndPoint( LocalAddress, ( Listener.Port + 1 ) ) );
}
else
e.Rejected = true;
}
catch
{
e.Rejected = true;
}
}
public static bool Resolve( string addr, out IPAddress outValue )
{
try
{
outValue = IPAddress.Parse( addr );
return true;
}
catch
{
try
{
IPHostEntry iphe = Dns.Resolve( addr );
if ( iphe.AddressList.Length > 0 )
{
outValue = iphe.AddressList[iphe.AddressList.Length - 1];
return true;
}
}
catch
{
}
}
outValue = IPAddress.None;
return false;
}
private static bool IsLocalMachine( NetState state )
{
Socket sock = state.Socket;
IPAddress theirAddress = ((IPEndPoint)sock.RemoteEndPoint).Address;
if ( IPAddress.IsLoopback( theirAddress ) )
return true;
bool contains = false;
IPHostEntry iphe = Dns.Resolve( Dns.GetHostName() );
for ( int i = 0; !contains && i < iphe.AddressList.Length; ++i )
contains = theirAddress.Equals( iphe.AddressList[i] );
return contains;
}
}
}
Works just fine for me.
1) I have not flamed anyone
2) I have said buggy code is unwanted.
3) Please show me a reason one reason why I should be banned and I will leave.
4) Please post where you have given help intead of telling the people who help.
I don't think I have done anything wrong, If I have I am sure the moderators would have told me.
This code assumes your using the same computer just running two instances of runuo as two seperate shards.
Krrios has not said its possible to login to two different servers ( two different ips ) form the same ServerList.cs if it was then I am sure UO Gamers would have done it when they had their small Faction Test a few months ago.
I am not perfect, I don't think its right for somebody who never helps anyone to want somebody who does to be banned for being open about how he feels about people posting buggy code.
I am polite, I tell people exactly what I need to help them, and sometimes people are difficult about doing that.
I tell people when they break the rules, so they don't waste their time replying to themselfs over and over.
Plus I see other people doing exact samething so you going to ban those people too? I see people giving bad advice, I think people like GoldDraco who is very rude to me, who has been proven ( recently ) regarding a override to e method TO BE WRONG should be banned for BEING WRONG.
But that won't happen and there is really no reason to ban me because I am right now is there?
( right) when giving advice and support.
I am human, I am not always right, However draco has been wrong several times, and is known to post code he didn't write from scratch, which is another thing I will tell people not to do. If I work hard on a script, and other people work hard on a script, who gives draco the right to change it, update it, and repost and not giving credit to the original author for his idea.
I am not a credit whore, I believe in giving credit for the work people do, thats all I would do. Credit is = posting on this forum, having your name attached to the post with the script. Thats where credit ends for me, I hate copyright lines and I would never use them, and you won't ever see me using them.
Before anyone says I don't submit scripts, your right I don't because I see how people are about scripts people I know have written and how they basicly have gone crazy because of the complete stupity of some people.
So I am not going to post pointless scripts, unless I think of a good project, I am not going to post anything. If you think thats wrong, well I know what I can, you would be shocked in my real skill.