本文整理汇总了C#中MCForge.Entity.Player.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Player.SendMessage方法的具体用法?C# Player.SendMessage怎么用?C# Player.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCForge.Entity.Player
的用法示例。
在下文中一共展示了Player.SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
public void Use(Player p, string[] args)
{
int _ = 0;
string message = "";
for (int i = 1; i <= args.Length; i++)
{
message += args[i] + " ";
}
string newreason = message.Trim().Substring(args[0].Length + 1);
string[] lines = File.ReadAllLines("bans/BanInfo.txt");
if (lines.Length < 1) { p.SendMessage("Could not find ban information for \"" + args[0] + "\"."); return; }
foreach (string line in lines)
{
if (line.Split('`')[0] == args[0])
{
string date = line.Split('`')[2];
string time = line.Split('`')[3];
string banner = line.Split('`')[4];
for (int o = 1; o <= lines.Length; o++)
{
if (lines[o].Split('`')[0] == args[0]) lines[o] = args[0] + "`" + newreason + "`" + date + "`" + time + "`" + banner;
}
File.WriteAllLines("bans/BanInfo.txt", lines);
p.SendMessage("Successfully set " + args[0] + "'s ban reason to \"" + newreason + "\".");
}
else
{
_++;
if (_ == 1)
p.SendMessage("Could not find ban information for \"" + args[0] + "\".");
}
}
}
示例2: Help
public void Help(Player p)
{
p.SendMessage("/bot add [name] - creates a bot where you are standing.");
p.SendMessage("/bot remove [name] - removes bot with [name] from your level.");
p.SendMessage("/bot ai \"[name]\" [type] - toggles ai to bot. \"'s are required.");
p.SendMessage("Available types of AI: follow, break");
}
示例3: Use
public void Use(Player p, string[] args)
{
if (args.Length != 0) { Help(p); return; }
p.SendMessage("This server's name is &b" + ServerSettings.GetSetting("servername") + Server.DefaultColor + ".");
p.SendMessage(Server.Players.Count == 1 ? "There is no one else on the server" : "There are currently " + Server.Players.Count + " players on this server"); //TODO dont include hidden if above current rank
//p.SendMessage("This server currently has $banned people that are &8banned" + Server.DefaultColor + ".");
p.SendMessage("This server currently has " + Level.Levels.Count + " levels loaded.");
//p.SendMessage("This server's currency is: " + Server.moneys); // later for when money works.
p.SendMessage("This server runs on &bMCForge 2.0" + Server.DefaultColor + ".");
p.SendMessage("This server's version: &a" + Assembly.GetExecutingAssembly().GetName().Version);
TimeSpan up = DateTime.Now - Server.StartTime;
string upTime = "Time online: &b";
if (up.Days == 1) upTime += up.Days + " day, ";
else if (up.Days > 0) upTime += up.Days + " days, ";
if (up.Hours == 1) upTime += up.Hours + " hour, ";
else if (up.Days > 0 || up.Hours > 0) upTime += up.Hours + " hours, ";
if (up.Minutes == 1) upTime += up.Minutes + " minute and ";
else if (up.Hours > 0 || up.Days > 0 || up.Minutes > 0) upTime += up.Minutes + " minutes and ";
upTime += up.Seconds == 1 ? up.Seconds + " second" : up.Seconds + " seconds";
p.SendMessage(upTime);
p.SendMessage("Type \"yes\" to see the devs list.");
p.OnPlayerChat.Normal += (sender, eventargs) => {
sender.ExtraData.CreateIfNotExist("LastCmd", "");
if (eventargs.Message.ToLower() == "yes" && sender.ExtraData["LastCmd"] == "info")
Command.all["devs"].Use(p, new string[0]);
eventargs.Cancel();
eventargs.Unregister();
};
}
示例4: Use
public void Use(Player p, string[] args)
{
if (args.Length == 0) { Help(p); return; }
Player who = Player.Find(args[0]);
if (who == null) { p.SendMessage("Cannot find player!"); return; }
who.ExtraData.CreateIfNotExist("Muted", false);
if (Server.devs.Contains(who.Username)) { p.SendMessage("Cannot mute a MCForge Developer!"); return; }
if (who == p) {
if ((bool)who.ExtraData["Muted"]) { p.SendMessage("Cannot unmute yourself!"); }
else { p.SendMessage("Cannot mute yourself!"); }
return;
}
if (args.Length == 2) //XMute
{
int time = 0;
if ((bool)who.ExtraData["Muted"]) { who.ExtraData["Muted"] = false; Player.UniversalChat(who.Username + " has been unmuted!"); return; }
try { time = Int32.Parse(args[1]) * 1000; }
catch { p.SendMessage("Please use a valid number!"); return; }
if (time > 600000) { p.SendMessage("Cannot mute for more than 10 minutes"); return; }
who.ExtraData["Muted"] = true;
Player.UniversalChat(who.Username + " %chas been muted for " + time / 1000 + " seconds!");
Thread.Sleep(time);
who.ExtraData["Muted"] = false;
Player.UniversalChat(who.Username + " has been unmuted!");
}
else //Regular mute
{
if ((bool)who.ExtraData["Muted"]) { who.ExtraData["Muted"] = false; Player.UniversalChat(who.Username + " has been unmuted!"); return; }
else { who.ExtraData["Muted"] = true; Player.UniversalChat(who.Username + " has been muted!"); return; }
}
}
示例5: Use
public void Use(Player p, string[] args) {
if (args.Length == 0 || args.Length > 2) { Help(p); return; }
Player who;
string color;
p.Color = p.Group.Color;
if (args.Length == 1) {
who = p;
color = args[0] == "del" ? p.Group.Color : Colors.Parse(args[0]);
if (p.Color == color) { p.SendMessage("You are already that color!"); return; }
}
else {
who = Player.Find(args[0]);
if (who == null) { p.SendMessage("Could not find player."); return; }
if (p.Group.Permission <= who.Group.Permission) { p.SendMessage("You can't change the color of someone of equal or higher rank!"); return; }
color = args[1] == "del" ? who.Group.Color : Colors.Parse(args[1]);
if (who.Color == color) { p.SendMessage("They are already that color!"); return; }
}
if (color == "") { p.SendMessage("Could not find color."); return; }
string message = "";
if (color == who.Group.Color)
message = "their groups default.";
else
message = color + Colors.Name(color) + who.Color+ ".";
Player.UniversalChat(who.Color + "*" + who.Username + (who.Username.EndsWith("s") || who.Username.EndsWith("x") ? "'" : "'s") + " color was changed to " + message);
who.Color= color;
who.GlobalDie();
who.SendSpawn(who);
who.SetPrefix();
//TODO Save to database.
}
示例6: Help
public void Help(Player p)
{
p.SendMessage("/click [x z y]- Fakes a click");
p.SendMessage("if no xyz is given, it uses the last place clicked.");
p.SendMessage("/click 200 z 200 will cuase it to click at 200x, last z, and 200y");
p.SendMessage("Shortcut: /x");
}
示例7: Use
public void Use(Player p, string[] args) {
if (args.Length < 1) {
Help(p);
return;
}
if (args.Length > 2) {
if (args[0].ToLower() == "help") {
if (ServerSettings.HasKey(args[1]))
p.SendMessage(ServerSettings.GetDescription(args[1]));
else
p.SendMessage("Key doesn't exist");
return;
}
else if (ServerSettings.HasKey(args[0])) {
ServerSettings.SetSetting(args[0], values: String.Join(" ", args, 1, args.Count()));
return;
}
else {
Help(p);
return;
}
}
if (!ServerSettings.HasKey(args[0]))
p.SendMessage("Key doesn't exist");
else
p.SendMessage(String.Format("Value for {0} is {1}", args[0], ServerSettings.GetSetting(args[0])));
}
示例8: Help
public void Help(Player p) {
p.SendMessage("Usage: /settings <key> [value]");
p.SendMessage("To get a value, do not add a value at the end of the command.");
p.SendMessage("To set a value, add a value at the end of the command.");
p.SendMessage("ex: /settings motd Welcome $user");
p.SendMessage("To get a description of a setting, type /settings help <key>.");
}
示例9: OnAllPlayersCommand_Normal
void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs args) {
if (args.Command != "ag")
return;
args.Cancel();
if (args.Args.Length < 2) {
Help(sender);
return;
}
if (args.Args[0].ToLower() == "allow") {
Player who = Player.Find(args.Args[1]);
if (who == null || who is ConsolePlayer) {
sender.SendMessage("The specified player was not found");
return;
}
AllowList.AddValue<string, Player>(sender.Username, who);
return;
}
else if (args.Args[0].ToLower() == "disallow") {
Player who = Player.Find(args.Args[1]);
if (who == null || who is ConsolePlayer) {
sender.SendMessage("The specified player was not found");
return;
}
AllowList.RemoveValue<string, Player>(sender.Username, who);
return;
}
}
示例10: Help
public void Help(Player p)
{
p.SendMessage("/queue level [level] - Queues [level] to be selected next");
p.SendMessage("/queue zombie [zombie] - Queues [zombie] to be selected next (Doesn't apply on Normal gamemode)");
p.SendMessage("/queue gamemode [gamemode] - Queues [gamemode] to be selected next");
p.SendMessage("0 for Normal, 1 for Classic, 2 for Classic Happy, 3 for cure");
}
示例11: Use
public void Use(Player p, string[] args)
{
if (args.Length != 2)
{
p.SendMessage("Invalid number of arguments!");
Help(p);
return;
}
List<string> temp;
if (args[0].Contains(","))
temp = new List<string>(args[0].Split(','));
else
temp = new List<string>() { args[0] };
temp = temp.Distinct().ToList(); // Remove duplicates
List<string> invalid = new List<string>(); //Check for invalid blocks
foreach (string name in temp)
if (!Block.ValidBlockName(name))
invalid.Add(name);
if (!Block.ValidBlockName(args[1]))
invalid.Add(args[1]);
if (invalid.Count > 0)
{
p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid)));
return;
}
if (temp.Contains(args[1]))
temp.Remove(args[1]);
if (temp.Count < 1)
{
p.SendMessage("Replacing a block with the same one would be pointless!");
return;
}
List<byte> oldType = new List<byte>();
foreach (string name in temp)
oldType.Add(Block.NameToBlock(name));
byte newType = Block.NameToBlock(args[1]);
List<Vector3S> buffer = new List<Vector3S>();
int currentBlock = 0;
foreach (byte b in p.Level.Data)
{
if (oldType.Contains(b))
buffer.Add(p.Level.IntToPos(currentBlock));
currentBlock++;
}
p.SendMessage(buffer.Count.ToString() + " blocks.");
buffer.ForEach(delegate(Vector3S pos)
{
p.Level.BlockChange((ushort)(pos.x), (ushort)(pos.z), (ushort)(pos.y), newType, p);
});
p.SendMessage("&4/replaceall finished!");
}
示例12: Use
public void Use(Player p, string[] args)
{
if (Server.Voting) { p.SendMessage("A vote is already in progress!"); return; }
Player who = null;
if (args.Length == 0) { who = null; }
else { who = Player.Find(args[0]); }
if (who == null) { p.SendMessage("Cannot find that player!"); return; }
Server.Kicker = who;
ResetVotes();
Server.Voting = true;
Server.KickVote = true;
Player.UniversalChat("VOTE: Kick " + who.Username + "?");
Player.UniversalChat("Use: %aYes " + Server.DefaultColor + "or %cNo " + Server.DefaultColor + "to vote!");
Thread.Sleep(15000);
Player.UniversalChat("The votes are in! %aYes: " + Server.YesVotes + " %cNo: " + Server.NoVotes + Server.DefaultColor + "!");
if (Server.YesVotes > Server.NoVotes) { who.Kick("Votekick'd"); return; }
else if (Server.NoVotes > Server.YesVotes || Server.YesVotes == Server.NoVotes) { Player.UniversalChat("Looks like " + who.Username + " is staying!"); return; }
Server.ForeachPlayer(delegate(Player pl)
{
pl.ExtraData.CreateIfNotExist("Voted", false);
pl.ExtraData["Voted"] = false;
});
Server.Voting = false;
ResetVotes();
}
示例13: Use
public void Use(Player p, string[] args)
{
Level tempLevel = Level.FindLevel(args[0]);
if (tempLevel != null)
{
if (tempLevel.visit != null && tempLevel.visit.Permission < p.Group.Permission) {
p.SendMessage("You dont have permission to go to this level");
return;
}
#region Send and Spawn
p.GlobalDie();
p.IsLoading = true;
p.Level = tempLevel;
short x = (short)((0.5 + tempLevel.SpawnPos.x) * 32);
short y = (short)((1 + tempLevel.SpawnPos.y) * 32);
short z = (short)((0.5 + tempLevel.SpawnPos.z) * 32);
p.Pos = new Vector3S(x, z, y);
p.Rot = tempLevel.SpawnRot;
p.oldPos = p.Pos;
p.oldRot = p.Rot;
p.SendSpawn(p);
p.IsLoading = false;
p.SpawnOtherPlayersForThisPlayer();
p.SpawnThisPlayerToOtherPlayers();
p.SpawnBotsForThisPlayer();
#endregion
Player.UniversalChat(p.Username + " went to " + args[0] + "!");
}
else
{
p.SendMessage("This level does not exist!");
}
}
示例14: Use
public void Use(Player p, string[] args)
{
if (!File.Exists("text/news.txt"))
{
File.Create("text/news.txt").Close();
Logger.Log("[File] Created news.txt", Color.White, Color.Black);
p.SendMessage("No News file was available!");
return;
}
string[] lines = File.ReadAllLines("text/news.txt");
DateTime editdate = File.GetLastWriteTime("text/news.txt");
if (args.Length == 0)
{
p.SendMessage("News as of " + editdate.ToShortDateString() + ":");
foreach (string line in lines)
{
p.SendMessage(line);
}
}
else
{
Player who = Player.Find(args[0].ToLower());
who.SendMessage("News as of " + editdate.ToShortDateString() + ":");
foreach (string line in lines)
{
who.SendMessage(line);
}
}
}
示例15: Use
public void Use(Player p, string[] args)
{
p.ExtraData.CreateIfNotExist("ReadRules", false);
if (Server.agreed.Contains(p.Username)) { p.SendMessage("You have already agreed to the rules!"); return; }
if (!(bool)p.ExtraData["ReadRules"]) { p.SendMessage("You need to read the /rules before you can disagree!"); return; }
p.Kick("Kicked for disagreeing to the rules!");
}