Spoiler:
- Code: Select all
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;
using System.ComponentModel;
using System.Collections.Generic;
using System.Threading;
namespace MCDzienny
{
public class CmdWeatherSystem : Command
{
public override string name { get { return "weather_system"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return "information"; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
bool day = false;
bool night = false;
bool active = false;
bool weathertimerison = false;
public override void Use(Player p, string message)
{
if (message == "enable")
{
if (active)
{
Player.SendMessage(p, "It is already active!");
return;
}
else
{
active = true;
Player.GlobalMessage(p.color + p.name +":%7 Activated the weather system.");
}
}
if (message == "disable")
{
if (!active)
{
Player.SendMessage(p, "It is already deactivated!");
return;
}
else
{
active = false;
Player.GlobalMessage("%7Weather system turned off.");
}
}
while (active)
{
if (!weathertimerison)
{
var timer = new System.Timers.Timer(1000);
int count = 0;
weathertimerison = true;
timer.AutoReset = true;
timer.Elapsed += delegate
{
count++;
Player.SendMessage(p, count.ToString());
if (count == 1)
{
foreach (Player pl in Player.players) // Morning / Default
{
if (pl.Cpe.EnvColors == 1)
{
Cpe.V1.EnvSetColor(pl, 0, 135, 206, 235);
Cpe.V1.EnvSetColor(pl, 1, 255, 255, 255);
Cpe.V1.EnvSetColor(pl, 2, 245, 245, 245);
Cpe.V1.EnvSetColor(pl, 3, 169, 169, 169);
Cpe.V1.EnvSetColor(pl, 4, 255, 255, 255);
day = true;
night = false;
}
else
Player.SendMessage(null, "");
}
}
if (count == 10) // Night Time
{
foreach (Player pl in Player.players)
{
if (pl.Cpe.EnvColors == 1)
{
Cpe.V1.EnvSetColor(pl, 0, 20, 20, 20);
Cpe.V1.EnvSetColor(pl, 1, 107, 19, 196);
Cpe.V1.EnvSetColor(pl, 2, 53, 33, 74);
Cpe.V1.EnvSetColor(pl, 3, 75, 75, 75);
Cpe.V1.EnvSetColor(pl, 4, 100, 100, 100);
night = true;
day = false;
}
else
Player.SendMessage(null, "");
}
}
if (count == 20)
{
weathertimerison = false;
timer.Stop();
}
};
timer.Start();
}
}
}
public override void Help(Player p)
{
Player.SendMessage(p, " ");
}
}
}