/humanchat

/humanchat

Postby HETAL » 06 Aug 2013, 19:36

Code: Select all
using System;
namespace MCDzienny
{
    public class CmdHumanchat : Command
    {
        public override string name { get { return "humanchat"; } }
        public override string shortcut { get { return "hchat"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
        public override bool ConsoleAccess { get { return true; } }
        public override void Init()
        {
            Player.ChatOther += new EventHandler<ChatOtherEventArgs>(ChatOE);
            Player.Joined += new EventHandler<PlayerEventArgs>(PlayerJE);
            Player.PlayerChatEvent += AddStuff;
            Player.players.ForEach(delegate(Player pl)
            {
                AddVars(pl);
            });
        }
        void AddStuff(Player p, ref string message, ref bool stopIt)
        {
            if (message[0] == '^' || message[2] == '^') //take in mind color chat people :)
            {
                SendHuman(p, null, message);
                stopIt = true;
            }
        }
        void SendHuman(Player p, Player who, string message)
        {
            if (who == null)
            {
                message = message.Substring(message.IndexOf('^') + 1);
                Player.players.ForEach(delegate(Player pl)
                {
                    if (!pl.isZombie)
                        pl.SendMessage("%eTo Humans Users %f-" + p.color + p.PublicName + "%f- " + message);
                });
            }
            else
            {
                who.SendMessage("%eTo Humans %f-" + p.color + p.PublicName + "%f- " + message);
            }
        }
        string human()
        {
            string builder = "human: ";
            Player.players.ForEach(delegate(Player pl)
            {
                    if (!pl.isZombie)
                    builder += pl.PublicName + ", ";
            });
            return builder;
        }
        public override void Use(Player p, string message)
        {
            switch (message)
            {
                case "human":
                    Player.SendMessage(p, human());
                    break;
                case "remove":
                    Player.ChatOther -= ChatOE;
                    Player.Joined -= PlayerJE;
                    Player.PlayerChatEvent -= AddStuff;
                    Player.SendMessage(p, "Events removed");
                    break;
                default:
                    p.ExtraData["hchat"] = !(bool)p.ExtraData["hchat"];
                    Player.SendMessage(p, "Human chat has been set to " + p.ExtraData["hchat"].ToString() + ".");
                    break;
            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/%ahumanchat" + Server.DefaultColor + " -- turns admin chat on/off");
            Player.SendMessage(p, "Shortcut: /hchat or use ^ as first letter in message");
        }
        public void AddVars(Player p)
        {
            if (!p.ExtraData.ContainsKey("hchat"))
                p.ExtraData.Add("hchat", false);
        }
        public void PlayerJE(object sender, PlayerEventArgs e)
        {
            AddVars(e.Player);
        }
      public void ChatOE(object sender, ChatOtherEventArgs e)
      {
         if ((bool)e.From.ExtraData["hchat"] == true)
         {
            Player.players.ForEach(delegate(Player pl)
            {
               if (!pl.isZombie)
               {
                  string message = e.Message.Substring(e.Message.IndexOf(':') + 1);
                  SendHuman(e.From, e.To, message);
               }
            });
            e.Handled = true;
         }
      }
    }
}
humanchat for zombie survival!! plz correct me if this is actually zombie chat
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /humanchat

Postby Breakdown901 » 06 Aug 2013, 20:03

Just taking a quic look of the code, it says (if pl. is zombie) then send humans a message. Meaning, the zombie would be sending humans a message.
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54

Re: /humanchat

Postby HETAL » 06 Aug 2013, 20:33

zombies can send human messages they just cant read the messages in humanchat ps it says !pl. is zombie ! makes it send the messages to humans if I removed the ! it would be zombie chat
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /humanchat

Postby Breakdown901 » 07 Aug 2013, 11:53

I thought it was pl. infected, must be wrong.
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54

Re: /humanchat

Postby 94ge7j998 » 08 Aug 2013, 07:05

Code: Select all
Player.SendMessage(p, "/%ahumanchat" + Server.DefaultColor + " -- turns admin chat on/off");

I think you meant to put "turns human chat on/off"?
94ge7j998
 
Posts: 64
Joined: 26 Oct 2011, 20:49

Re: /humanchat

Postby HETAL » 08 Aug 2013, 19:54

Yes I use ismellike's admin chat to help me with the chatother events so I forgot to change that btw a lot of credit goes to ismellike
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /humanchat

Postby 94ge7j998 » 08 Aug 2013, 19:58

Could you also make a /zombiechat?
94ge7j998
 
Posts: 64
Joined: 26 Oct 2011, 20:49

Re: /humanchat

Postby HETAL » 08 Aug 2013, 20:03

sure wait 5 minutes and it will be ready
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 9 guests

cron