I'm trying to make a item that makes you lvl 137 for 5 minutes but i dont know how to create a timer.
Can anyone help?
Can anyone help?
Yes, a great many of people may help you. I am one of them.Quote:
I'm trying to make a item that makes you lvl 137 for 5 minutes but i dont know how to create a timer.
Can anyone help?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers; // use this to do the Timers or you can replace the Timer with System.Timers.Timer
namespace CA_TimerProject
{
class Program
{
public static Timer ExplanationTimer = new Timer(); // Create a new timer
static void Main(string[] args)
{
Console.Title = "C# Explain Timers"; // Console Title
ExplanationTimer.Elapsed += new ElapsedEventHandler(ExplanationTimer_Elapsed); // Create a new void that does something when the timer ends
ExplanationTimer.Interval = 300000; // 1000 ticks * 60 seconds * 5 minutes | tells when the timer stops and then restarts (ofcourse you can make it completely stop forever)
ExplanationTimer.Start(); // starts the timer
Console.ReadLine();
}
static void ExplanationTimer_Elapsed(object sender, ElapsedEventArgs e) // Once again this action happens once the timer reaches the interval of 5 minutes
{
Console.WriteLine("5 Minutes has passed");
ExplanationTimer.Stop(); // stops the timer so it does not repeat itself (I am sure this is what you want)
}
}
}