Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 13:30

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Huge Question] Events Triggered by Time [5165]

Discussion on [Huge Question] Events Triggered by Time [5165] within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2010
Posts: 378
Received Thanks: 86
[Huge Question] Events Triggered by Time [5165]

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.

Thanks =\
-NewDawn- is offline  
Old 03/02/2010, 02:52   #2
 
spare2's Avatar
 
elite*gold: 20
Join Date: Oct 2009
Posts: 1,009
Received Thanks: 621
It does, a simple timer can be used to solve your problem.
You can use the class.
spare2 is offline  
Thanks
1 User
Old 03/02/2010, 03:27   #3
 
elite*gold: 0
Join Date: Feb 2010
Posts: 378
Received Thanks: 86
Quote:
Originally Posted by spare2 View Post
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...
-NewDawn- is offline  
Old 03/02/2010, 03:32   #4
 
walmartboi's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Code:
using System.Timers;
Code:
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.
walmartboi is offline  
Thanks
1 User
Old 03/02/2010, 04:09   #5
 
hunterman01's Avatar
 
elite*gold: 20
Join Date: Dec 2006
Posts: 945
Received Thanks: 175
Here is a little tip though

Don't use a lot of timers if you do it will cause major lag spikes + it takes up a lot of memory
hunterman01 is offline  
Old 03/02/2010, 04:25   #6
 
elite*gold: 0
Join Date: Feb 2010
Posts: 378
Received Thanks: 86
Figured it out on my own.
#request close (<-- if that's how one does it xP)
-NewDawn- is offline  
Old 03/02/2010, 04:34   #7
 
walmartboi's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Not even a simple thanks for me typing my code on a standard text editor?
walmartboi is offline  
Old 03/02/2010, 04:35   #8
 
ImFlamedCOD's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 378
Received Thanks: 140
If (Date.Time.Hour == 1 && Date.Time.Minute == 30)
{
Global.Public.Events.Start(PKEvent)//just made this part up but you get my idea.
}
ImFlamedCOD is offline  
Old 03/02/2010, 04:51   #9
 
walmartboi's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Just thought of this:

Code:
byte triggerhour = hour;
byte triggermin = minute;
for (; ; ) //Never-ending loop
{
    System.Threading.Thread.Sleep(60 * 1000);//checks every minute
    if (Date.Time.Hour == triggerhour && Date.Time.Minute == triggermin)
    {
       PKEvent.PKer.Start();
    }
    
}
walmartboi is offline  
Old 03/02/2010, 05:06   #10
 
elite*gold: 0
Join Date: Feb 2010
Posts: 378
Received Thanks: 86
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
-NewDawn- is offline  
Old 03/02/2010, 05:11   #11
 
spare2's Avatar
 
elite*gold: 20
Join Date: Oct 2009
Posts: 1,009
Received Thanks: 621
Quote:
Originally Posted by -NewDawn- View Post
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.
spare2 is offline  
Old 03/02/2010, 06:55   #12
 
.Ocularis's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 309
Received Thanks: 208
PHP Code:
        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
.Ocularis is offline  
Thanks
1 User
Old 03/02/2010, 07:58   #13
 
Nullable's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
Quote:
Originally Posted by walmartboi View Post
Code:
using System.Timers;
Code:
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.
Nullable is offline  
Old 03/06/2010, 16:16   #14
 
elite*gold: 0
Join Date: Feb 2010
Posts: 492
Received Thanks: 222
Ok then well is there a way to like make it repeat it self ever 2 hours so like i dono sleep == Hours);

so an event can auto start every 2 hours ?
Paralyzer[GM] is offline  
Old 03/06/2010, 16:27   #15
 
Nullable's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
Quote:
Originally Posted by Paralyzer[GM] View Post
Ok then well is there a way to like make it repeat it self ever 2 hours so like i dono sleep == Hours);

so an event can auto start every 2 hours ?
Using timers, this is really easy, all what you have to do is set the timer class member AutoReset to true;
like
Code:
Timer T = new Timer(2 HOURS VAL);
T.AutoReset = true;
T.Start();
Nullable is offline  
Reply


Similar Threads Similar Threads
[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



All times are GMT +2. The time now is 13:30.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.