/blackchat

/blackchat

Postby HETAL » 13 Jul 2013, 23:04

edited from conor's rchat cmd, if you want to change the black to another color you will have to edit the code, it took me a few seconds to make the cmd with conor's rchat backing me up, a lot of credit to conor
Code: Select all
    using System;

    namespace MCDzienny
    {
        public class CmdBlackchat : Command
        {
            public override string name { get { return "blackchat"; } }
            public override string shortcut { get { return "bc"; } }
            public override string type { get { return "other"; } }
            public override bool museumUsable { get { return false; } }
            public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }

            public const string r = "BlackChat";

            public override void Help(Player p)
            {
                Player.SendMessage(p, "/bchat - enables/disables black chat.");
            }

            public override void Use(Player p, string message)
            {
                if (!p.ExtraData.ContainsKey(r))
                {
                    p.ExtraData.Add(r, false);
                }

                if ((bool)p.ExtraData[r] == true)
                {
                    p.ExtraData[r] = false;
                    Player.SendMessage(p, "Black chat disabled.");
                }
                else
                {
                    p.ExtraData[r] = true;
                    Player.SendMessage(p, "Black chat enabled.");
                }
            }

            public override void Init()
            {
                Player.PlayerChatEvent += MakeBlack;
            }

            private void MakeBlack(Player p, ref string message, ref bool stopIt)
            {
                if (p.ExtraData.ContainsKey(r) && (bool)p.ExtraData[r] == true)
                {
                    message =Black(message);
                }
            }

            private string Black(string msg)
            {
                try
                {
                    string blackMsg = "";
                    char[] Msgchar = msg.ToCharArray();
                    int counter = 0;

                    for (int i = 0; i < msg.Length; i++)
                    {
                        if (Msgchar[i] != ' ')
                        {
                            switch (counter)
                            {
                                case 0: blackMsg += "&0" + Msgchar[i]; break;
                                case 1: blackMsg += "&0" + Msgchar[i]; break;
                                case 2: blackMsg += "&0" + Msgchar[i]; break;
                                case 3: blackMsg += "&0" + Msgchar[i]; break;
                            }
                        }
                        else { blackMsg += " "; }

                        counter++;
                        if (counter > 3)
                        {
                            counter = 0;
                        }
                    }
                    return blackMsg;
                }
                catch
                {
                    return msg;
                }
            }
        }
    }
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /blackchat

Postby HETAL » 13 Jul 2013, 23:59

Lime chat
Spoiler:
and can some change the shortcut of black chat to bchat And i havent test limechat so plz report an bugs
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /blackchat

Postby Conor » 15 Jul 2013, 00:23

You don't need that whole loop and everything when you're just using one colour :lol:

You can just do this:
Code: Select all
private string Lime(string msg)
{
   return c.lime + msg;
}
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /blackchat

Postby lucasds12 » 15 Jul 2013, 23:26

Here is the version where you use /bchat and /blackchat, hope this answers your question on making the shortcut different :D
Code: Select all
    using System;

    namespace MCDzienny
    {
        public class CmdBlackchat : Command
        {
            public override string name { get { return "blackchat"; } }
            public override string shortcut { get { return "bchat"; } }
            public override string type { get { return "other"; } }
            public override bool museumUsable { get { return false; } }
            public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }

            public const string r = "BlackChat";

            public override void Help(Player p)
            {
                Player.SendMessage(p, "/bchat - enables/disables black chat.");
            }

            public override void Use(Player p, string message)
            {
                if (!p.ExtraData.ContainsKey(r))
                {
                    p.ExtraData.Add(r, false);
                }

                if ((bool)p.ExtraData[r] == true)
                {
                    p.ExtraData[r] = false;
                    Player.SendMessage(p, "Black chat disabled.");
                }
                else
                {
                    p.ExtraData[r] = true;
                    Player.SendMessage(p, "Black chat enabled.");
                }
            }

            public override void Init()
            {
                Player.PlayerChatEvent += MakeBlack;
            }

            private void MakeBlack(Player p, ref string message, ref bool stopIt)
            {
                if (p.ExtraData.ContainsKey(r) && (bool)p.ExtraData[r] == true)
                {
                    message =Black(message);
                }
            }

            private string Black(string msg)
            {
                try
                {
                    string blackMsg = "";
                    char[] Msgchar = msg.ToCharArray();
                    int counter = 0;

                    for (int i = 0; i < msg.Length; i++)
                    {
                        if (Msgchar[i] != ' ')
                        {
                            switch (counter)
                            {
                                case 0: blackMsg += "&0" + Msgchar[i]; break;
                                case 1: blackMsg += "&0" + Msgchar[i]; break;
                                case 2: blackMsg += "&0" + Msgchar[i]; break;
                                case 3: blackMsg += "&0" + Msgchar[i]; break;
                            }
                        }
                        else { blackMsg += " "; }

                        counter++;
                        if (counter > 3)
                        {
                            counter = 0;
                        }
                    }
                    return blackMsg;
                }
                catch
                {
                    return msg;
                }
            }
        }
    }

Enjoy!
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /blackchat

Postby HETAL » 15 Jul 2013, 23:33

I know how I just wanted a mod to update my post
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /blackchat

Postby joppiesaus » 16 Jul 2013, 13:59

HETAL wrote:Lime chat
Spoiler:
and can some change the shortcut of black chat to bchat And i havent test limechat so plz report an bugs


in the /help method:
Player.SendMessage(p, "/limechat - enables/disables black chat.");
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!

Re: /blackchat

Postby lucasds12 » 16 Jul 2013, 17:46

As Joppiesaus as noticed, you did a minor mistake to /limechat, in the /help limechat description, it says disables/enables black chat and it should say disables/enables lime chat so basically you have to change:
Code: Select all
Player.SendMessage(p, "/limechat - enables/disables black chat.");

To
Code: Select all
Player.SendMessage(p, "/limechat - enables/disables lime chat.");


It was just a minor mistake you forgot, now that should help.
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: /blackchat

Postby Stuwie » 16 Jul 2013, 17:58

Me being a noob and forgetting how to change the permission of the command. Can anyone please tell me the command?
Image
User avatar
Stuwie
 
Posts: 78
Joined: 27 Nov 2011, 23:49

Re: /blackchat

Postby HETAL » 16 Jul 2013, 18:08

/cmdset
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /blackchat

Postby Stuwie » 17 Jul 2013, 21:01

Thanks.
Image
User avatar
Stuwie
 
Posts: 78
Joined: 27 Nov 2011, 23:49


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 4 guests

cron