[Release] Better Timer

10/21/2008 23:04 keving15#1
If you Noob: Stop Reading!

The most People using 2 Timers or more, i show you an way how to use only 1.
Create in Character.cs for Player the "public DateTime TestCheck;"
Code:
 public static System.Timers.Timer MainTimer;
Code:
      MainTimer = new System.Timers.Timer();
                MainTimer.Interval = 100;
                MainTimer.Elapsed += new ElapsedEventHandler(MainTimer_System);
                MainTimer.Start();
Code:
       public static void MainTimer_System(object sender, ElapsedEventArgs e)
        {
            foreach (DictionaryEntry DE in World.AllChars)
            {
                Character Char = (Character)DE.Value;
                if (Char != null && DateTime.Now > Char.TestCheck.AddMilliseconds(1000)) // Checks if the Current Date + Clocktime like "TestCheck" + 1000 Miliseconds (like 1 Sec). then continue.
                {
                    Char.TestCheck = DateTime.Now; // This sets the "TestCheck" to the current Date + Clocktime...
                    and the step is going to repeat :)
                }
            }
        }
if u have Problems with the Code just ask here.

Dont say something like this suckz or other things.
IF YOU DONT LIKE IT DONT REPLY TO MY POST , VERY EASY OR NOT!
10/21/2008 23:12 XxArcherMasterxX#2
added to my [All-In-1] thread ok?
10/21/2008 23:32 tao4229#3
Pointless.
10/21/2008 23:51 InfamousNoone#4
Quote:
Originally Posted by tao4229 View Post
Pointless.
Only because it's not being utilized to its full potential.
10/21/2008 23:58 tao4229#5
Quote:
Originally Posted by InfamousNoone View Post
Only because it's not being utilized to its full potential.
I meant this topic, it's pretty much a rip out of LOTF, just a basic example of it.
10/22/2008 09:56 keving15#6
Quote:
Originally Posted by tao4229 View Post
I meant this topic, it's pretty much a rip out of LOTF, just a basic example of it.
Its nothing Rip i have coded it myself.
If you dont know nothing about me, my codes or anything its better to be quit.
10/22/2008 13:40 Rechocto#7
mmm.. if you want to make a single timer, you're probably better off using "if"s to check how much time has passed since the last timer_elapsed, adding that to variables, then when the variables reach a certain amount, call the already existing functions for the old timers and reset the variables to 0. True, this could free up some resources on the host computer; however, if done wrong, it could also jump to 100% and stay there ^.^
10/22/2008 22:44 tao4229#8
Quote:
Originally Posted by keving15 View Post
Its nothing Rip i have coded it myself.
If you dont know nothing about me, my codes or anything its better to be quit.
I meant LOTF does this with like everything.

And wtf? I don't understand your point in the second line. You're not a famous(lol, wow >_>)/good coder, so why the hell does it matter?
10/23/2008 07:05 Ultimatum#9
iv allwayz used timespan :x, use a timeout and runtill, timout being a timespan set to whatever like (0, 0, 4) - 4 secs. Rununtill = Datetime.now.add(TimeOut)