Code:
- Code: Select all
/*
Auto-generated command skeleton class.
Use this as a basis for custom commands implemented via the MCDzienny scripting framework.
File and class should be named a specific way. For example, /update is named 'CmdUpdate.cs' for the file, and 'CmdUpdate' for the class.
*/
// Add any other using statements you need up here, of course.
// As a note, MCDzienny is designed for .NET 3.5.
using System;
using System.IO;
using System.Threading;
namespace MCDzienny
{
public class CmdBring : Command
{
public override string name { get { return "bring"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return "other"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public CmdBring() { }
public override void Use(Player p, string message)
{
if (message == "") { Help(p); return; }
if (p == null) { Player.SendMessage(p, "You cannot use this command from the console"); return; }
if (message.ToLower() == "all")
{
try
{
foreach (Player pl in Player.players)
{
if (pl.level == p.level && pl != p && p.group.Permission > pl.group.Permission)
{
unchecked { pl.SendPos((byte)-1, p.pos[0], p.pos[1], p.pos[2], p.rot[0], 0); }
pl.SendMessage("You were brought by " + p.color + p.name + Server.DefaultColor + ".");
}
}
}
catch (Exception e)
{
Server.ErrorLog(e);
}
Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " brought everyone!");
return;
}
Player who = Player.Find(message);
if (who == null || who.hidden) { Player.SendMessage(p, "There is no player \"" + message + "\"!"); return; }
if (p.group.Permission < who.group.Permission)
{
Player.SendMessage(p, "You cannot bring someone ranked higher than you!");
return;
}
if (p.level != who.level)
{
Player.SendMessage(p, who.name + " is in a different Level. Forcefetching has started!");
Level where = p.level;
Command.all.Find("goto").Use(who, where.name);
Thread.Sleep(1000);
// Sleep for a bit while they load
while (who.Loading) { Thread.Sleep(250); }
}
unchecked { who.SendPos((byte)-1, p.pos[0], p.pos[1], p.pos[2], p.rot[0], 0); }
who.SendMessage("You were brought by " + p.color + p.name + Server.DefaultColor + ".");
}
public override void Help(Player p)
{
Player.SendMessage(p, "/bring <player> - Brings a player to your position.");
Player.SendMessage(p, "/bring all - Brings all players in the map");
}
}
}
Hope This Helps!