HETAL wrote:try this
- Code: Select all
public class CmdHungergames : Command
{
const string mapname = "tnt";
Creating a variable is not going to help Hetal. Though; it is a start.
@Breakdown901, you can check if the level exists first, if it doesn't then you can create one. Here, I coded it for you to see.
- Code: Select all
using System;
using System.Threading;
namespace MCDzienny
{
public class CmdHungergames : Command
{
public override string name { get { return "hungergames"; } }
public override string shortcut { get { return "hg"; } }
public override string type { get { return "other"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public override bool ConsoleAccess { get { return false; } }
private static string mapName = "hungergames";
public override void Use(Player p, string message)
{
if (!LevelExists())
{
Command.all.Find("newlvl").Use(null, mapName + " 128 64 128 flat");
Thread.Sleep(5000);
}
if (Level.Find(mapName) == null)
{
Player.SendMessage(p, mapName + " map could not be found. Ensure it is loaded.");
return;
}
Command.all.Find("goto").Use(p, "hungergames");
Player.GlobalMessage(p.color + p.PublicName + Server.DefaultColor + " has joined the hunger games!");
Thread.Sleep (2000);
Player.SendMessage(p, "You are being given a gun, fight to the death!");
if (!p.aiming)
{
Command.all.Find("gun").Use(p, "");
}
}
private bool LevelExists()
{
foreach (FileInfo f in new DirectoryInfo("levels").GetFiles("*.lvl"))
{
if (f.Name.Split('.')[0] == mapName)
{
return true;
}
}
return false;
}
public override void Help(Player p)
{
Player.SendMessage(p, "/hungergames - Fight to the death. A level called hungergames must be made first.");
}
}
}
I haven't tested that but I think it should work, let me know if you want some more help (or if it doesn't work).