• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

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