当前位置: 首页>>代码示例>>C#>>正文


C# Player.SetPrefix方法代码示例

本文整理汇总了C#中Player.SetPrefix方法的典型用法代码示例。如果您正苦于以下问题:C# Player.SetPrefix方法的具体用法?C# Player.SetPrefix怎么用?C# Player.SetPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player.SetPrefix方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Use

        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Database.AddParams("@Name", p.name);
                Database.executeQuery("UPDATE Players SET color = '' WHERE name = @Name");
                Player.GlobalChat(p, p.color + "*" + p.DisplayName + Server.DefaultColor + "'s color reverted to " + p.group.color + "their group's default" + Server.DefaultColor + ".", false);
                p.color = p.group.color;

                Player.GlobalDie(p, false);
                Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                p.SetPrefix();
                return;
            }
            string color = c.Parse(message);
            if (color == "") { Player.SendMessage(p, "There is no color \"" + message + "\"."); }
            else if (color == p.color) { Player.SendMessage(p, "You already have that color."); }
            else
            {
                Database.AddParams("@Color", c.Name(color));
                Database.AddParams("@Name", p.name);
                Database.executeQuery("UPDATE Players SET color = @Color WHERE name = @Name");

                Player.GlobalChat(p, p.color + "*" + p.DisplayName + Server.DefaultColor + "'s color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
                p.color = color;

                Player.GlobalDie(p, false);
                Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                p.SetPrefix();
            }
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:31,代码来源:CmdXColor.cs

示例2: Use

        public override void Use(Player p, string message)
        { 
            string query;
            if (message == "") 
            { 
                p.title = "";
                p.SetPrefix();
                Player.GlobalChat(p, p.color + p.DisplayName + Server.DefaultColor + " had their title removed.", false);
                query = "UPDATE Players SET Title = '' WHERE Name = @Name";
                Database.AddParams("@Name", p.name);
                Database.executeQuery(query);
                return; 
            }
            int pos = message.IndexOf(' ');
            string newTitle = "";
            newTitle = message;

            if (newTitle != "")
            {
                newTitle = newTitle.ToString().Trim().Replace("[", "");
                newTitle = newTitle.Replace("]", "");
            }

            if (newTitle.Length > 17) { Player.SendMessage(p, "Title must be under 17 letters."); return; }

            if (newTitle != "")
                Player.GlobalChat(p, p.color + p.DisplayName + Server.DefaultColor + " gave themself the title of &b[" + newTitle + "%b]", false);
            else Player.GlobalChat(p, p.color + p.prefix + p.DisplayName + Server.DefaultColor + " had their title removed.", false);

            if (!Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])"))
            {
                if (Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])(.+?).*"))
                {
                    Regex rg = new Regex(@"%([0-9]|[a-f]|[k-r])(.+?)");
                    MatchCollection mc = rg.Matches(newTitle.ToLower());
                    if (mc.Count > 0)
                    {
                        Match ma = mc[0];
                        GroupCollection gc = ma.Groups;
                        newTitle.Replace("%" + gc[1].ToString().Substring(1), "&" + gc[1].ToString().Substring(1));
                    }
                }
            }

            Database.AddParams("@Title", newTitle);
            Database.AddParams("@Name", p.name);
            query = "UPDATE Players SET Title = @Title WHERE Name = @Name";
            Database.executeQuery(query);
            p.title = newTitle;
            p.SetPrefix();
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:51,代码来源:CmdXTitle.cs

示例3: Use

 public override void Use(Player p, string message)
 {
     if (message == "") 
     {
         p.titlecolor = "";
         Player.GlobalChat(p, p.color + p.DisplayName + Server.DefaultColor + " had their title color removed.", false);
         Database.AddParams("@Name", p.name);
         Database.executeQuery("UPDATE Players SET title_color = '' WHERE Name = @Name");
         p.SetPrefix();
         return; 
     }
     string color = c.Parse(message);
     if (color == "") { Player.SendMessage(p, "There is no color \"" + message + "\"."); return; }
     else if (color == p.titlecolor) { Player.SendMessage(p, "You already have that title color."); return; }
     else
     {
         Database.AddParams("@Color", c.Name(color));
         Database.AddParams("@Name", p.name);
         Database.executeQuery("UPDATE Players SET title_color = @Color WHERE Name = @Name");
         Player.GlobalChat(p, p.color + p.DisplayName + Server.DefaultColor + " had their title color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
         p.titlecolor = color;
         p.SetPrefix();
     }
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:24,代码来源:CmdXTColor.cs

示例4: Use

        public override void Use(Player p, string message)
        {
            if ( message == "" || message.Split(' ').Length > 2 ) { Help(p); return; }
            int pos = message.IndexOf(' ');
            if ( pos != -1 ) {
                Player who = Player.Find(message.Substring(0, pos));

                if ( p != null && who.group.Permission > p.group.Permission ) { Player.SendMessage(p, "You cannot change the color of someone ranked higher than you!"); return; }

                if ( who == null ) { Player.SendMessage(p, "There is no player \"" + message.Substring(0, pos) + "\"!"); return; }

                if ( message.Substring(pos + 1) == "del" ) {
                    Database.AddParams("@Name", who.name);
                    Database.executeQuery("UPDATE Players SET color = '' WHERE name = @Name");
                    Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color reverted to " + who.group.color + "their group's default" + Server.DefaultColor + ".", false);
                    who.color = who.group.color;

                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    who.SetPrefix();
                    return;
                }
                string color = c.Parse(message.Substring(pos + 1));
                if ( color == "" ) { Player.SendMessage(p, "There is no color \"" + message + "\"."); }
                else if ( color == who.color ) { Player.SendMessage(p, who.name + " already has that color."); }
                else {
                    //Player.GlobalChat(who, p.color + "*" + p.name + "&e changed " + who.color + Name(who.name) +
                    //                  " color to " + color +
                    //                  c.Name(color) + "&e.", false);
                    Database.AddParams("@Color", c.Name(color));
                    Database.AddParams("@Name", who.name);
                    Database.executeQuery("UPDATE Players SET color = @Color WHERE name = @Name");

                    Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
                    if ( p == null ) {
                        Player.SendMessage(p, "*" + Name(who.name) + " color was changed to " + c.Name(color) + ".");
                    }
                    who.color = color;

                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    who.SetPrefix();
                }
            }
            else {
                if ( p != null ) {
                    if ( message == "del" ) {
                        Database.AddParams("@Name", p.name);
                        Database.executeQuery("UPDATE Players SET color = '' WHERE name = @Name");

                        Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color reverted to " + p.group.color + "their group's default" + Server.DefaultColor + ".", false);
                        p.color = p.group.color;

                        Player.GlobalDie(p, false);
                        Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                        p.SetPrefix();
                        return;
                    }
                    string color = c.Parse(message);
                    if ( color == "" ) { Player.SendMessage(p, "There is no color \"" + message + "\"."); }
                    else if ( color == p.color ) { Player.SendMessage(p, "You already have that color."); }
                    else {
                        Database.AddParams("@Color", c.Name(color));
                        Database.AddParams("@Name", p.name);
                        Database.executeQuery("UPDATE Players SET color = @Color WHERE name = @Name");

                        Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
                        p.color = color;

                        Player.GlobalDie(p, false);
                        Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                        p.SetPrefix();
                    }
                }
            }
        }
开发者ID:Fire200055,项目名称:MCGalaxy,代码行数:76,代码来源:CmdColor.cs

示例5: Use

        public override void Use(Player p, string message)
        {
            if (message == "" || message.Split(' ').Length > 2) { Help(p); return; }
            int pos = message.IndexOf(' ');
            if (pos != -1)
            {
                Player who = Player.Find(message.Substring(0, pos));
                if (!Server.devs.Contains(p.name.ToLower()) && !Server.gcmodhasprotection(p.name.ToLower())) {
                if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "You cannot change the color of someone ranked higher than you!"); return; }
                }
                if (who == null) { Player.SendMessage(p, "There is no player \"" + message.Substring(0, pos) + "\"!"); return; }
                if (Server.devs.Contains(who.name.ToLower()))
                    {
                        if (!Server.devs.Contains(p.name.ToLower()))
                        {
                        Player.SendMessage(p, "You can't change the color of a developer.");
                        return;
                        }
                    }
                if (Server.gcmods.Contains(who.name.ToLower()))
                {
                    if (!Server.devs.Contains(p.name.ToLower()))
                    {
                        Player.SendMessage(p, "You can't change the color of a Global Chat Moderator.");
                        return;
                    }
                }
                if (message.Substring(pos + 1) == "del")
                {
                    if (Server.useMySQL) MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + who.name + "'"); else SQLite.executeQuery("UPDATE Players SET color = '' WHERE name = '" + who.name + "'");
                    Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color reverted to " + who.group.color + "their group's default" + Server.DefaultColor + ".", false);
                    who.color = who.group.color;

                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    who.SetPrefix();
                    return;
                }
                string color = c.Parse(message.Substring(pos + 1));
                if (color == "") { Player.SendMessage(p, "There is no color \"" + message + "\"."); }
                else if (color == who.color) { Player.SendMessage(p, who.name + " already has that color."); }
                else
                {
                    //Player.GlobalChat(who, p.color + "*" + p.name + "&e changed " + who.color + Name(who.name) +
                    //                  " color to " + color +
                    //                  c.Name(color) + "&e.", false);
                    if (Server.useMySQL) MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + who.name + "'"); else SQLite.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + who.name + "'");

                    Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
                    if (p == null)
                    {
                        Player.SendMessage(p, "*" + Name(who.name) + " color was changed to " + c.Name(color) + ".");
                    }
                    who.color = color;

                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    who.SetPrefix();
                }
            }
            else
            {
                if (p != null)
                {
                    if (message == "del")
                    {
                        if (Server.useMySQL) MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + p.name + "'"); else

                        Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color reverted to " + p.group.color + "their group's default" + Server.DefaultColor + ".", false);
                        p.color = p.group.color;

                        Player.GlobalDie(p, false);
                        Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                        p.SetPrefix();
                        return;
                    }
                    string color = c.Parse(message);
                    if (color == "") { Player.SendMessage(p, "There is no color \"" + message + "\"."); }
                    else if (color == p.color) { Player.SendMessage(p, "You already have that color."); }
                    else
                    {
                        if (Server.useMySQL) MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + p.name + "'"); else SQLite.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + p.name + "'");

                        Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
                        p.color = color;

                        Player.GlobalDie(p, false);
                        Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                        p.SetPrefix();
                    }
                }
            }
        }
开发者ID:celebrir,项目名称:MCForge-Vanilla,代码行数:93,代码来源:CmdColor.cs

示例6: Use

        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }

            int pos = message.IndexOf(' ');
            Player who = Player.Find(message.Split(' ')[0]);
            if (who == null) { Player.SendMessage(p, "Could not find player."); return; }
            if (p != null && who.group.Permission > p.group.Permission)
            {
                Player.SendMessage(p, "Cannot change the title of someone of greater rank");
                return;
            }
			if (who != p && (int)p.group.Permission >= CommandOtherPerms.GetPerm(this))
            {
            	string query;
            	string newTitle = "";
            	if (message.Split(' ').Length > 1) newTitle = message.Substring(pos + 1);
            	else
            	{
                	who.title = "";
                	who.SetPrefix();
                	Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " had their title removed.", false);
                	query = "UPDATE Players SET Title = '' WHERE Name = @Name";
                	Database.AddParams("@Name", who.name);
                	Database.executeQuery(query);
                	return;
            	}

            	if (newTitle != "")
            	{ //remove the brackets from the given title
                	newTitle = newTitle.ToString().Trim().Replace("[", "");
                	newTitle = newTitle.Replace("]", "");
            	}

            	if (newTitle.Length > 17) { Player.SendMessage(p, "Title must be under 17 letters."); return; }


            /*string title = newTitle.ToLower();
            foreach (char c in Server.ColourCodesNoPercent) { title = title.Replace("%" + c, ""); title = title.Replace("&" + c, ""); }
            foreach (string occur in Server.BadTitles) {
                if (title.Contains(occur)) { Player.SendMessage(p, "%cYou're not a developer! Stop pretending you are!"); return; }
            }*/


            	if (newTitle != "")
                	Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was given the title of &b[" + newTitle + "%b]", false);
            	else Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " had their title removed.", false);

            	if (!Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])"))
            	{
                	if (Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])(.+?).*"))
                	{
                    	Regex rg = new Regex(@"%([0-9]|[a-f]|[k-r])(.+?)");
                    	MatchCollection mc = rg.Matches(newTitle.ToLower());
                    	if (mc.Count > 0)
                    	{
                        	Match ma = mc[0];
                        	GroupCollection gc = ma.Groups;
                        	newTitle.Replace("%" + gc[1].ToString().Substring(1), "&" + gc[1].ToString().Substring(1));
                    	}
                	}
            	}

            	if (newTitle == "")
            	{
                	query = "UPDATE Players SET Title = '' WHERE Name = @Name";
                	Database.AddParams("@Name", who.name);
            	}
            	else
            	{
                	query = "UPDATE Players SET Title = @Title WHERE Name = @Name";
                	Database.AddParams("@Title", newTitle);
                	Database.AddParams("@Name", who.name);
            	}
            	Database.executeQuery(query);
            	who.title = newTitle;
            	who.SetPrefix();
            }
            else if (who == p)
            {
                string query;
                string newTitle = "";
                if (message.Split(' ').Length > 1) newTitle = message.Substring(pos + 1);
                else
                {
                    p.title = "";
                    p.SetPrefix();
                    Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " had their title removed.", false);
                    query = "UPDATE Players SET Title = '' WHERE Name = @Name";
                    Database.AddParams("@Name", p.name);
                    Database.executeQuery(query);
                    return;
                }

                if (newTitle != "")
                { //remove the brackets from the given title
                    newTitle = newTitle.ToString().Trim().Replace("[", "");
                    newTitle = newTitle.Replace("]", "");
                }

//.........这里部分代码省略.........
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:101,代码来源:CmdTitle.cs


注:本文中的Player.SetPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。