Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

C#, Anyway of doing this better?

Newbie Spellweaver
Joined
Mar 30, 2016
Messages
6
Reaction score
0
Hi, i've been working on some scripts and i was wondering if there was any way of making this code better?

Code:
using Zepheus.Zone.InterServer;
using Zepheus.FiestaLib;


namespace Something
{
	public class WelcomeMessage
	{
		public static void Main()
		{
	     InterHandler.SendWorldMessage(WorldMessageType.Level20, "Stu from Extrinsic Studio is awesome!")
				Thread.Sleep (4000)
				Main();
			}
		}
	}
}
 
Last edited:
Joined
Apr 21, 2010
Messages
461
Reaction score
188
I'm going to help you because of the penis sucking.

What are you trying to do exactly?

P.S.: This is the worst code I have ever seen in my lifetime.
 
Last edited:
Newbie Spellweaver
Joined
Mar 30, 2016
Messages
6
Reaction score
0
Well... i'm trying to broadcast a message every 4 seconds, so It won't go away.
 
Joined
Apr 21, 2010
Messages
461
Reaction score
188
Well, to simply loop something every 4 seconds, you can use a while loop. Example:

Code:
public static void Main()
{
	while (true)
	{
		InterHandler.SendWorldMessage(WorldMessageType.Level20, "Stu from Extrinsic Studio is awesome!");
		Thread.Sleep(4000);
	}
}

But that's bad and you don't want to do that. Well you could, but you would have to spawn a thread dedicated to this function alone.

What you want to do, is put it inside the server main loop (No idea where it is, I don't duck around with poop emulators).

Create a new long variable, called NextNoticeTime. In the server's main loop you want to do this:

Code:
if (NextNoticeTime < GetCurrentMilliseconds())
	{
		NextNoticeTime = GetCurrentMilliseconds() + 4000;
		
		InterHandler.SendWorldMessage(WorldMessageType.Level20, "Stu from Extrinsic Studio is awesome!");
	}

Where GetCurrentMilliseconds is a function that returns current milliseconds since epoch (google it).
 
Back
Top