Пример #1
0
        internal static void ToggleAfk(Player p, string message, bool isAuto = false)
        {
            if (p.joker)
            {
                message = "";
            }
            p.AutoAfk    = false;
            p.IsAfk      = !p.IsAfk;
            p.afkMessage = p.IsAfk ? message : null;
            TabList.Update(p, true);

            var oldLastAction = p.LastAction;

            p.LastAction = DateTime.UtcNow;

            bool cantSend = p.muted || (Server.chatmod && !p.voice);

            if (p.IsAfk)
            {
                if (cantSend)
                {
                    p.Message("You are now marked as being AFK.");
                }
                else
                {
                    if (message == null || message.Trim() == "")
                    {
                        ShowMessage(p, "-λNICK%S- is AFK");
                    }
                    else
                    {
                        if (isAuto)
                        {
                            ShowMessage(p, "-λNICK%S- is AFK " + message);
                        }
                        else
                        {
                            ShowMessage(p, "-λNICK%S- is AFK: " + message);
                        }
                    }
                    p.CheckForMessageSpam();
                }
                p.AFKCooldown = DateTime.UtcNow.AddSeconds(2);
                OnPlayerActionEvent.Call(p, PlayerAction.AFK, null, cantSend);
            }
            else
            {
                if (cantSend)
                {
                    p.Message("You are no longer marked as being AFK.");
                }
                else
                {
                    TimeSpan idleTime = DateTime.UtcNow - oldLastAction;
                    ShowMessage(p, string.Format("-λNICK%S- is no longer AFK ({0})", idleTime.Shorten()));
                    p.CheckForMessageSpam();
                }
                OnPlayerActionEvent.Call(p, PlayerAction.UnAFK, null, cantSend);
            }
        }
Пример #2
0
        protected void HandlePlayerAction(Player p, PlayerAction action, string message, bool stealth)
        {
            if (!(action == PlayerAction.Referee || action == PlayerAction.UnReferee))
            {
                return;
            }
            if (p.level != Map)
            {
                return;
            }

            if (action == PlayerAction.UnReferee)
            {
                PlayerActions.Respawn(p);
                PlayerJoinedGame(p);
                p.Game.Referee = false;
            }
            else
            {
                PlayerLeftGame(p);
                p.Game.Referee = true;
                Entities.GlobalDespawn(p, false, false);
            }

            Entities.GlobalSpawn(p, false, "");
            TabList.Update(p, true);
        }
Пример #3
0
        protected override void SetPlayerData(Player p, string target, string nick)
        {
            if (Colors.Strip(nick).Length >= 30)
            {
                p.Message("Nick must be under 30 letters."); return;
            }
            Player who = PlayerInfo.FindExact(target);

            if (nick.Length == 0)
            {
                MessageFrom(target, who, "had their custom nick reset");
                nick = target.RemoveLastPlus();
            }
            else
            {
                // TODO: select color from database?
                string color = who != null ? who.color : Group.GroupIn(target).Color;
                MessageFrom(target, who, "had their nick set to " + color + nick);
            }

            if (who != null)
            {
                who.DisplayName = nick;
            }
            if (who != null)
            {
                TabList.Update(who, true);
            }
            PlayerDB.SetNick(target, nick);
        }
Пример #4
0
 void JoinTeam(Player p, CtfTeam team)
 {
     Get(p).HasFlag = false;
     team.Members.Add(p);
     Map.Message(p.ColoredName + " &Sjoined the " + team.ColoredName + " &Steam");
     p.Message("You are now on the " + team.ColoredName + " team!");
     TabList.Update(p, true);
 }
Пример #5
0
        void JoinTeam(Player p, TWTeam team)
        {
            team.Members.Add(p);
            Map.Message(p.ColoredName + " &Sjoined the " + team.ColoredName + " &Steam");

            p.UpdateColor(team.Color);
            p.Message("You are now on the " + team.ColoredName + " team!");
            TabList.Update(p, true);
        }
Пример #6
0
        void JoinTeam(Player p, TWTeam team)
        {
            team.Members.Add(p);
            Map.Message(p.ColoredName + " %Sjoined the " + team.ColoredName + " %Steam");

            p.color = team.Color;
            p.SetPrefix();

            p.Message("You are now on the " + team.ColoredName + " team!");
            TabList.Update(p, true);
        }
Пример #7
0
        void RestoreColor(Player p)
        {
            TWData data = TryGet(p);

            // TODO: p.Socket.Disconnected check should be elsewhere
            if (data == null || p.Socket.Disconnected)
            {
                return;
            }

            p.UpdateColor(PlayerInfo.DefaultColor(p));
            TabList.Update(p, true);
        }
Пример #8
0
        void RestoreColor(Player p)
        {
            TWData data = TryGet(p);

            if (data == null)
            {
                return;
            }

            p.color = data.OrigCol;
            p.SetPrefix();
            TabList.Update(p, true);
        }
Пример #9
0
        internal static void ToggleAfk(Player p, string message)
        {
            if (p.joker)
            {
                message = "";
            }
            p.AutoAfk    = false;
            p.IsAfk      = !p.IsAfk;
            p.afkMessage = p.IsAfk ? message : null;
            TabList.Update(p, true);
            p.LastAction = DateTime.UtcNow;

            bool cantSend = p.muted || (Server.chatmod && !p.voice);

            if (p.IsAfk)
            {
                if (cantSend)
                {
                    Player.Message(p, "You are now marked as being AFK.");
                }
                else
                {
                    Chat.MessageWhere("-{0}%S- is AFK {1}",
                                      pl => Entities.CanSee(pl, p) && !pl.listignored.Contains(p.name) && !pl.ignoreAll,
                                      p.ColoredName, message);
                    Player.RaisePlayerAction(p, PlayerAction.AFK, message);
                    p.CheckForMessageSpam();
                }

                p.AFKCooldown = DateTime.UtcNow.AddSeconds(2);
                p.RaiseONAFK();
                Player.RaiseAFK(p);
                OnPlayerAFKEvent.Call(p);
            }
            else
            {
                if (cantSend)
                {
                    Player.Message(p, "You are no longer marked as being AFK.");
                }
                else
                {
                    Chat.MessageWhere("-{0}%S- is no longer AFK",
                                      pl => Entities.CanSee(pl, p) && !pl.listignored.Contains(p.name) && !pl.ignoreAll,
                                      p.ColoredName);
                    Player.RaisePlayerAction(p, PlayerAction.UnAFK, message);
                    p.CheckForMessageSpam();
                }
            }
        }
Пример #10
0
        void RestoreColor(Player p)
        {
            TWData data = TryGet(p);

            // TODO: p.Socket.Disconnected check should be elsewhere
            if (data == null || p.Socket.Disconnected)
            {
                return;
            }

            p.color = data.OrigCol;
            p.SetPrefix();
            TabList.Update(p, true);
        }
Пример #11
0
        internal static void ToggleAfk(Player p, string message)
        {
            if (p.joker)
            {
                message = "";
            }
            p.AutoAfk    = false;
            p.IsAfk      = !p.IsAfk;
            p.afkMessage = p.IsAfk ? message : null;
            TabList.Update(p, true);
            p.LastAction = DateTime.UtcNow;

            bool cantSend = !p.CanSpeak();

            if (p.IsAfk)
            {
                if (cantSend)
                {
                    p.Message("You are now marked as being AFK.");
                }
                else
                {
                    ShowMessage(p, "-λNICK%S- is AFK " + message);
                    p.CheckForMessageSpam();
                }
                p.AFKCooldown = DateTime.UtcNow.AddSeconds(2);
                OnPlayerActionEvent.Call(p, PlayerAction.AFK, null, cantSend);
            }
            else
            {
                if (cantSend)
                {
                    p.Message("You are no longer marked as being AFK.");
                }
                else
                {
                    ShowMessage(p, "-λNICK%S- is no longer AFK");
                    p.CheckForMessageSpam();
                }
                OnPlayerActionEvent.Call(p, PlayerAction.UnAFK, null, cantSend);
            }
        }
Пример #12
0
        internal static void ToggleAfk(Player p, string message)
        {
            if (p.joker)
            {
                message = "";
            }
            p.AutoAfk    = false;
            p.IsAfk      = !p.IsAfk;
            p.afkMessage = p.IsAfk ? message : null;
            TabList.Update(p, true);
            p.LastAction = DateTime.UtcNow;

            bool cantSend = p.muted || (Server.chatmod && !p.voice);

            if (p.IsAfk)
            {
                if (cantSend)
                {
                    Player.Message(p, "You are now marked as being AFK.");
                }
                else
                {
                    ShowMessage(p, "-" + p.ColoredName + "%S- is AFK " + message);
                    p.CheckForMessageSpam();
                }
                p.AFKCooldown = DateTime.UtcNow.AddSeconds(2);
                OnPlayerActionEvent.Call(p, PlayerAction.AFK, message);
            }
            else
            {
                if (cantSend)
                {
                    Player.Message(p, "You are no longer marked as being AFK.");
                }
                else
                {
                    ShowMessage(p, "-" + p.ColoredName + "%S- is no longer AFK");
                    p.CheckForMessageSpam();
                }
                OnPlayerActionEvent.Call(p, PlayerAction.UnAFK, message);
            }
        }
Пример #13
0
        protected override void SetPlayerData(Player p, string target, string nick)
        {
            if (Colors.Strip(nick).Length >= 30)
            {
                p.Message("Nick must be under 30 letters."); return;
            }
            Player who; string editee; bool globalMessage;

            GetPlayerDataMessageInfo(p, target, out who, out editee, out globalMessage);

            string message;

            if (nick.Length == 0)
            {
                message = p.ColoredName + " &Sremoved " + editee + " nick";
                nick    = target.RemoveLastPlus();
            }
            else
            {
                // TODO: select color from database?
                string color = who != null ? who.color : Group.GroupIn(target).Color;
                message = p.ColoredName + " &Schanged " + editee + " nick to " + color + nick;
            }
            if (globalMessage)
            {
                Chat.MessageAll(message);
            }
            else
            {
                Chat.MessageFrom(p, message);
            }

            if (who != null)
            {
                who.DisplayName = nick;
            }
            if (who != null)
            {
                TabList.Update(who, true);
            }
            PlayerDB.SetNick(target, nick);
        }
Пример #14
0
        protected override void SetOnlineData(Player p, Player who, string nick)
        {
            if (nick.Length == 0)
            {
                Chat.MessageFrom(who, "λNICK %Shad their custom nick reset");
                who.DisplayName = who.truename;
            }
            else
            {
                if (Colors.Strip(nick).Length >= 30)
                {
                    p.Message("Nick must be under 30 letters."); return;
                }

                Chat.MessageFrom(who, "λNICK %Shad their nick set to " + who.color + nick);
                who.DisplayName = nick;
            }

            PlayerDB.Save(who);
            TabList.Update(who, true);
        }
Пример #15
0
        void HandlePlayerAction(Player p, PlayerAction action, string message, bool stealth)
        {
            if (!(action == PlayerAction.Referee || action == PlayerAction.UnReferee))
            {
                return;
            }
            if (p.level != Game.Map)
            {
                return;
            }

            if (action == PlayerAction.UnReferee)
            {
                Game.PlayerJoinedLevel(p, Game.Map, Game.Map);
                Command.all.FindByName("Spawn").Use(p, "");
                p.Game.Referee = false;

                if (p.Supports(CpeExt.HackControl))
                {
                    p.Send(Hacks.MakeHackControl(p, p.level.GetMotd(p)));
                }
            }
            else
            {
                HandlePlayerDisconnect(p, null);
                p.Game.Referee = true;
                Entities.GlobalDespawn(p, false, false);

                if (p.Supports(CpeExt.HackControl))
                {
                    p.Send(Packet.HackControl(true, true, true, true, true, -1));
                }
            }

            Entities.GlobalSpawn(p, false, "");
            TabList.Update(p, true);
            p.SetPrefix();
        }
Пример #16
0
        public override void End()
        {
            if (!Running)
            {
                return;
            }
            Running = false;
            IGame.RunningGames.Remove(this);
            UnhookEventHandlers();

            if (RoundInProgress)
            {
                EndRound();
                RoundInProgress = false;
            }

            EndGame();
            OnStateChangedEvent.Call(this);

            RoundStart      = DateTime.MinValue;
            RoundsLeft      = 0;
            RoundInProgress = false;

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (pl.level != Map)
                {
                    continue;
                }
                pl.Game.RatedMap      = false;
                pl.Game.PledgeSurvive = false;
                PlayerLeftGame(pl);

                TabList.Update(pl, true);
                ResetStatus(pl);
                pl.SetPrefix();
            }

            // in case players left game partway through
            foreach (Player pl in players)
            {
                SaveStats(pl);
            }

            if (Map != null)
            {
                Map.Message(GameName + " &Sgame ended");
            }
            Logger.Log(LogType.GameActivity, "[{0}] Game ended", GameName);
            if (Picker != null)
            {
                Picker.Clear();
            }

            LastMap = "";
            if (Map != null)
            {
                Map.AutoUnload();
            }
            Map = null;
        }
Пример #17
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args   = message.SplitSpaces();
            string   action = args[0].ToLower();

            if (action == "all")
            {
                Toggle(p, ref p.Ignores.All, "{0} ignoring all chat"); return;
            }
            else if (action == "irc")
            {
                if (args.Length > 1)
                {
                    IgnoreIRCNick(p, args[1]);
                }
                else
                {
                    Toggle(p, ref p.Ignores.IRC, "{0} ignoring IRC chat");
                }
                return;
            }
            else if (action == "titles")
            {
                Toggle(p, ref p.Ignores.Titles, "{1}Player titles {0} show before names in chat"); return;
            }
            else if (action == "nicks")
            {
                Toggle(p, ref p.Ignores.Nicks, "{1}Custom player nicks {0} show in chat");
                TabList.Update(p, true); return;
            }
            else if (action == "8ball")
            {
                Toggle(p, ref p.Ignores.EightBall, "{0} ignoring %T/8ball"); return;
            }
            else if (action == "drawoutput")
            {
                Toggle(p, ref p.Ignores.DrawOutput, "{0} ignoring draw command output"); return;
            }
            else if (action == "worldchanges")
            {
                Toggle(p, ref p.Ignores.WorldChanges, "{0} ignoring world changes"); return;
            }
            else if (IsListCommand(action))
            {
                p.Ignores.Output(p); return;
            }

            if (p.Ignores.Names.CaselessRemove(action))
            {
                p.Message("&aNo longer ignoring {0}", action);
            }
            else
            {
                int    matches;
                Player who = PlayerInfo.FindMatches(p, action, out matches);
                if (who == null)
                {
                    if (matches == 0)
                    {
                        p.Message("You must use the full name when unignoring offline players.");
                    }
                    return;
                }

                if (p.Ignores.Names.CaselessRemove(who.name))
                {
                    p.Message("&aNo longer ignoring {0}", who.ColoredName);
                }
                else
                {
                    p.Ignores.Names.Add(who.name);
                    p.Message("&cNow ignoring {0}", who.ColoredName);
                }
            }
            p.Ignores.Save(p);
        }