Ok, I've been wanting to create events that happen at a certain time on the server. What I mean is, at an "x" time, i want something that will trigger an event that does "y".
For example:
------------
- I would like a "/c" command message to be sent to everyone at 5:00 pm saying "Event Test". (That's basicly what I've been trying to do)
My big question is, does the client support it? If it does, where do I put the even code? If it doesn't then can someone help me out? I've been working on this for a few days and had no luck.
It does, a simple timer can be used to solve your problem.
You can use the class.
Holy ****. Lol...
I can't understand that. I'm self taught and I've only been looking at code for a week and a half. Can you or someone help me out and give me an example? =\
Code:
using System;
using System.Timers;
public class Timer1
{
private static System.Timers.Timer aTimer;
public static void Main()
{
// Normally, the timer is declared at the class level,
// so that it stays in scope as long as it is needed.
// If the timer is declared in a long-running method,
// KeepAlive must be used to prevent the JIT compiler
// from allowing aggressive garbage collection to occur
// before the method ends. (See end of method.)
//System.Timers.Timer aTimer;
// Create a timer with a ten second interval.
aTimer = new System.Timers.Timer(10000);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
// Set the Interval to 2 seconds (2000 milliseconds).
aTimer.Interval = 2000;
aTimer.Enabled = true;
Console.WriteLine("Press the Enter key to exit the program.");
Console.ReadLine();
// If the timer is declared in a long-running method, use
// KeepAlive to prevent garbage collection from occurring
// before the method ends.
//GC.KeepAlive(aTimer);
}
// Specify what you want to happen when the Elapsed event is
// raised.
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime);
}
}
/* This code example produces output similar to the following:
Press the Enter key to exit the program.
The Elapsed event was raised at 5/20/2007 8:42:27 PM
The Elapsed event was raised at 5/20/2007 8:42:29 PM
The Elapsed event was raised at 5/20/2007 8:42:31 PM
...
*/
is the example they give but I don't really understand it...
double minutes_to_send = NUMBER OF MINUTES YOU WANT IT TO SEND AT;
Timer Broadcast = new Timer();
Broadcast.Elapsed += new ElaspedEventHandler( sendmsg );
Broadcast.Interval = (minutes_to_send * 60 * 1000);
Broadcast.Start();
That's EXTREMELY basic, and you have to code the sendmsg void like this:
Code:
public static void sendmsg(object o, ElapsedEventArgs e)
{
}
And that was all hard coded in a quick reply box, so the errors you might get will be easy to fix, and will give you practice, but it DOES work.
Well you're all wrong. lol.
I figured it out and I'll release it when I'm done with a huge project i'm trying to release. i'm thinking it'll be done in a few weeks. It's a huge project =P I'm so proud of it working (so far >< lol). Thanks for your help though. I just have no idea what u're talking about =P
Well you're all wrong. lol.
I figured it out and I'll release it when I'm done with a huge project i'm trying to release. i'm thinking it'll be done in a few weeks. It's a huge project =P I'm so proud of it working (so far >< lol). Thanks for your help though. I just have no idea what u're talking about =P
I doubt that's true. It's just you did it another way.
static void EventTimer() { switch (DateTime.Now.Minute) { case 00: { if (DateTime.Now.Hour == 23) { World.API.SendMessAll2("Family Guy time!", 1); } break; } case 10: case 20: case 30: case 40: case 50: break; } }
Fairly simple.... Easily expandable. Put it somewhere like.... World... Idk
I made this for my 1.0 pioneer source, so don't use the broadcast
Make a new one
double minutes_to_send = NUMBER OF MINUTES YOU WANT IT TO SEND AT;
Timer Broadcast = new Timer();
Broadcast.Elapsed += new ElaspedEventHandler( sendmsg );
Broadcast.Interval = (minutes_to_send * 60 * 1000);
Broadcast.Start();
That's EXTREMELY basic, and you have to code the sendmsg void like this:
Code:
public static void sendmsg(object o, ElapsedEventArgs e)
{
}
And that was all hard coded in a quick reply box, so the errors you might get will be easy to fix, and will give you practice, but it DOES work.
You don't.
Code:
double minutes_to_send = NUMBER OF MINUTES YOU WANT IT TO SEND AT;
Timer Broadcast = new Timer();
Broadcast.Elapsed += delegate { sendmsg(arguments); };
Broadcast.Interval = (minutes_to_send * 60 * 1000);
Broadcast.Start();
*Where arguments is whatever you want to pass to the method.
[5165] Making events question 05/27/2010 - CO2 Private Server - 4 Replies Hey guys. I was just thinking, if I make my own events would it be better to make a new thread for the event or just stick stuff into character.cs? Because I've been thinking, if I stick it into character.cs and there are x people online, wouldn't that just lag the whole server? Or it wouldn't matter that much? Just looking for some feedback.
Currently I have most of my events in character.cs which I think is causing some lag. I just cant pinpoint whether its my client or the server.
[HUGE PROBLEM] 5165 archer bow damage bug 04/30/2010 - CO2 Private Server - 9 Replies hey guys :x
i have a big problem...
i have a 5165 conquer server, and i found a huge bug x_X
the archer's bow have a bug that makes them kill every player with 1 shot o_o
they cause a huge damage.... can someone helpme fix this?
[Huge-Release] All-In-One Basic NPC Scripts For The 5165 Source! 02/19/2010 - CO2 PServer Guides & Releases - 30 Replies Well I'm sorry that I spammed the whole forum full of my posts So pro4never and .Ryu gave me the idea of making this All-In-One thread about all my NPC's! THESE ARE UPDATED DAILY!
NOTE: TO PEOPLE... SOME OF THE CODES ARE NOT MADE BY ME! I USUALLY JUST FIXED/UPDATED THE BASIC ONES! SORRY I'M LEARNING ON HOW TO CODE!
1. Birth-Island-NPC's(The NPC text is not from "REAL CONQUER" SORRY!...)
#region BirthOldGeneralYang
case 425:
{
Time on messages and events in SRO? 04/12/2007 - Silkroad Online - 4 Replies Well sometimes i don't know what time is is but i want to know with out stop grind
anyway to make a time thats in front of ppl message and events?
Also any know any info on this?
http://www.gzp.net/forums/showthr...7685#post7876 85