Ejemplo n.º 1
0
        static void ShowAltsTask(SchedulerTask task)
        {
            string name = (string)task.State;
            Player p    = PlayerInfo.FindExact(name);

            if (p == null || p.ip == "127.0.0.1" || p.disconnected)
            {
                return;
            }

            List <string> alts = PlayerInfo.FindAccounts(p.ip);

            // in older versions it was possible for your name to appear multiple times in DB
            while (alts.CaselessRemove(p.name))
            {
            }
            if (alts.Count == 0)
            {
                return;
            }

            LevelPermission adminChatRank = CommandExtraPerms.MinPerm("adminchat", LevelPermission.Admin);
            string          altsMsg       = p.ColoredName + " %Sis lately known as: " + alts.Join();

            if (p.group.Permission < adminChatRank || !ServerConfig.AdminsJoinSilently)
            {
                Chat.MessageOps(altsMsg);
                //IRCBot.Say(temp, true); //Tells people in op channel on IRC
            }
            Logger.Log(LogType.UserActivity, altsMsg);
        }
Ejemplo n.º 2
0
        public static void Append(Player p, string ai, string action, string[] args)
        {
            using (StreamWriter w = new StreamWriter("bots/" + ai, true)) {
                if (action.Length == 0)
                {
                    action = "walk";
                }
                if (action.CaselessEq("tp"))
                {
                    action = "teleport";
                }

                BotInstruction ins = BotInstruction.Find(action);
                if (ins == null)
                {
                    Player.Message(p, "Could not find instruction \"" + action + "\""); return;
                }

                LevelPermission killPerm = CommandExtraPerms.MinPerm("botset");
                if (ins.Name.CaselessEq("kill") && p.Rank < killPerm)
                {
                    Formatter.MessageNeedMinPerm(p, "+ can toggle a bot's killer instinct.", killPerm);
                    return;
                }
                ins.Output(p, args, w);
            }
        }
Ejemplo n.º 3
0
        public override void Help(Player p)
        {
            Player.Message(p, "%T/Patrol");
            LevelPermission perm = CommandExtraPerms.MinPerm(name);

            Player.Message(p, "%HTeleports you to a random {0} %Hor lower", Group.GetColoredName(perm));
            Player.Message(p, "%HPlayers patrolled within the last 15 seconds are ignored");
        }
Ejemplo n.º 4
0
        public static void MessageOps(Player p, string message)
        {
            LevelPermission rank = CommandExtraPerms.MinPerm("OpChat", LevelPermission.Operator);

            if (!MessageCmd.CanSpeak(p, "OpChat"))
            {
                return;
            }
            MessageStaff(p, message, rank, "Ops");
        }
Ejemplo n.º 5
0
        public static void MessageAdmins(Player p, string message)
        {
            LevelPermission rank = CommandExtraPerms.MinPerm("AdminChat", LevelPermission.Admin);

            if (!MessageCmd.CanSpeak(p, "AdminChat"))
            {
                return;
            }
            MessageStaff(p, message, rank, "Admins");
        }
Ejemplo n.º 6
0
        static void DoUnbanIP(ModAction e)
        {
            LevelPermission perm = CommandExtraPerms.MinPerm("whois");

            Chat.MessageWhere(e.FormatMessage("An IP", "&8IP unbanned"), pl => pl.Rank < perm);
            Chat.MessageWhere(e.FormatMessage(e.TargetName, "&8IP unbanned"), pl => pl.Rank >= perm);

            Logger.Log(LogType.UserActivity, "IP-UNBANNED: {0} by {1}.", e.Target, e.ActorName);
            Server.bannedIP.Remove(e.Target);
            Server.bannedIP.Save();
        }
Ejemplo n.º 7
0
        static void CheckReviewList(Player p)
        {
            Command         cmd  = Command.all.FindByName("Review");
            LevelPermission perm = CommandExtraPerms.MinPerm("Review");

            if (p.group.Permission < perm || !p.group.CanExecute(cmd))
            {
                return;
            }
            int count = Server.reviewlist.Count;

            if (count == 0)
            {
                return;
            }

            string suffix = count == 1 ? " player is " : " players are ";

            Player.Message(p, count + suffix + "waiting for a review. Type %T/Review view");
        }
Ejemplo n.º 8
0
        /// <summary> Returns the allowed state for the given player. </summary>
        public AccessResult Check(string name, Group rank)
        {
            if (Blacklisted.CaselessContains(name))
            {
                return(AccessResult.Blacklisted);
            }
            if (Whitelisted.CaselessContains(name))
            {
                return(AccessResult.Whitelisted);
            }

            if (rank.Permission < Min)
            {
                return(AccessResult.BelowMinRank);
            }
            if (rank.Permission > Max && MaxCmd != null && rank.Permission < CommandExtraPerms.MinPerm(MaxCmd))
            {
                return(AccessResult.AboveMaxRank);
            }
            return(AccessResult.Allowed);
        }
Ejemplo n.º 9
0
        internal static void IPLine(Player p, string name, string ip)
        {
            LevelPermission seeIPPerm = CommandExtraPerms.MinPerm("whois");

            if (p != null && p.Rank < seeIPPerm)
            {
                return;
            }

            string ipMsg = ip;

            if (Server.bannedIP.Contains(ip))
            {
                ipMsg = "&8" + ip + ", which is banned";
            }

            Player.Message(p, "  The IP of " + ipMsg);
            if (ServerConfig.WhitelistedOnly && Server.whiteList.Contains(name))
            {
                Player.Message(p, "  Player is &fWhitelisted");
            }
        }
Ejemplo n.º 10
0
        List <Player> GetPatrolCandidates(Player p)
        {
            List <Player>   candidates = new List <Player>();
            LevelPermission perm       = CommandExtraPerms.MinPerm(name);

            Player[] online = PlayerInfo.Online.Items;
            DateTime cutoff = DateTime.UtcNow.AddSeconds(-15);

            foreach (Player target in online)
            {
                if (target.Rank > perm || target == p || !Entities.CanSee(p, target))
                {
                    continue;
                }
                if (target.LastPatrol > cutoff)
                {
                    continue;
                }
                candidates.Add(target);
            }
            return(candidates);
        }
Ejemplo n.º 11
0
        void HandleEnter(Player p)
        {
            if (p == null)
            {
                Player.Message(p, "Console cannot enter the review queue."); return;
            }
            if (DateTime.UtcNow < p.NextReviewTime)
            {
                Player.Message(p, "You have to wait " + ServerConfig.ReviewCooldown + " seconds everytime you use this command");
                return;
            }

            foreach (string name in Server.reviewlist)
            {
                if (!name.CaselessEq(p.name))
                {
                    continue;
                }
                Player.Message(p, "You already entered the review queue!"); return;
            }

            bool opsOn = false;

            Player[]        players  = PlayerInfo.Online.Items;
            LevelPermission nextPerm = CommandExtraPerms.MinPerm(this.name, 2);

            foreach (Player pl in players)
            {
                if (pl.Rank >= nextPerm && Entities.CanSee(p, pl))
                {
                    opsOn = true; break;
                }
            }

            Server.reviewlist.Add(p.name);
            int pos = Server.reviewlist.IndexOf(p.name);

            if (pos > 1)
            {
                Player.Message(p, "You entered the &creview %Squeue. You have &c" + pos + " %Speople in front of you in the queue");
            }
            if (pos == 1)
            {
                Player.Message(p, "You entered the &creview %Squeue. There is &c1 %Sperson in front of you in the queue");
            }
            if (pos == 0)
            {
                Player.Message(p, "You entered the &creview %Squeue. You are &cfirst %Sin line!");
            }

            string msg = opsOn ?
                         "The Online staff have been notified. Someone should be with you shortly." :
                         "There are currently no staff online. Staff will be notified when they join the server.";

            Player.Message(p, msg);

            string start = pos > 0 ? "There are now &c" + (pos + 1) + " %Speople" : "There is now &c1 %Sperson";

            Chat.MessageWhere(p.ColoredName + " %Sentered the review queue", pl => pl.Rank >= nextPerm);
            Chat.MessageWhere(start + " waiting for a &creview!", pl => pl.Rank >= nextPerm);
            p.NextReviewTime = DateTime.UtcNow.AddSeconds(ServerConfig.ReviewCooldown);
            OnPlayerActionEvent.Call(p, PlayerAction.Review, null, true);
        }
Ejemplo n.º 12
0
        /// <summary> Sends a message to all players who are have the permission to read adminchat. </summary>
        public static void MessageAdmins(string message)
        {
            LevelPermission rank = CommandExtraPerms.MinPerm("adminchat", LevelPermission.Admin);

            MessageWhere(message, pl => pl.Rank >= rank);
        }
Ejemplo n.º 13
0
        public void ChatLevelAdmins(string message)
        {
            LevelPermission rank = CommandExtraPerms.MinPerm("adminchat", LevelPermission.Admin);

            ChatLevel(message, rank);
        }
Ejemplo n.º 14
0
        public void ChatLevelOps(string message)
        {
            LevelPermission rank = CommandExtraPerms.MinPerm("opchat", LevelPermission.Operator);

            ChatLevel(message, rank);
        }
Ejemplo n.º 15
0
 protected bool HasExtraPerm(Player p, int num)
 {
     return(p == null || p.Rank >= CommandExtraPerms.MinPerm(name, num));
 }
Ejemplo n.º 16
0
        void CompleteLoginProcess()
        {
            // Lock to ensure that no two players can end up with the same playerid
            lock (PlayerInfo.Online.locker) {
                id = NextFreeId();
                PlayerInfo.Online.Add(this);
            }

            SendMap(null);
            if (disconnected)
            {
                return;
            }
            loggedIn = true;
            connections.Remove(this);
            RemoveFromPending();
            Server.PlayerListUpdate();

            SessionStartTime = DateTime.UtcNow;
            LastLogin        = DateTime.Now;
            TotalTime        = TimeSpan.FromSeconds(1);
            GetPlayerStats();
            ShowWelcome();

            Server.Background.QueueOnce(ShowAltsTask, name, TimeSpan.Zero);
            CheckState();
            ZombieStats stats = Server.zombie.LoadZombieStats(name);

            Game.MaxInfected       = stats.MaxInfected; Game.TotalInfected = stats.TotalInfected;
            Game.MaxRoundsSurvived = stats.MaxRounds; Game.TotalRoundsSurvived = stats.TotalRounds;

            if (!Directory.Exists("players"))
            {
                Directory.CreateDirectory("players");
            }
            PlayerDB.Load(this);
            Game.Team = Team.TeamIn(this);
            SetPrefix();
            LoadCpeData();

            if (ServerConfig.verifyadmins && group.Permission >= ServerConfig.VerifyAdminsRank)
            {
                adminpen = true;
            }
            if (Server.noEmotes.Contains(name))
            {
                parseEmotes = !ServerConfig.ParseEmotes;
            }

            LevelPermission adminChatRank = CommandExtraPerms.MinPerm("adminchat", LevelPermission.Admin);

            hidden = group.CanExecute("hide") && Server.hidden.Contains(name);
            if (hidden)
            {
                SendMessage("&8Reminder: You are still hidden.");
            }
            if (group.Permission >= adminChatRank && ServerConfig.AdminsJoinSilently)
            {
                hidden = true; adminchat = true;
            }

            OnPlayerConnectEvent.Call(this);
            if (cancellogin)
            {
                cancellogin = false; return;
            }

            string joinm = "&a+ " + FullName + " %S" + PlayerDB.GetLoginMessage(this);

            if (hidden)
            {
                joinm = "&8(hidden)" + joinm;
            }

            const LevelPermission perm = LevelPermission.Guest;

            if (group.Permission > perm || (ServerConfig.GuestJoinsNotify && group.Permission <= perm))
            {
                Chat.MessageGlobal(this, joinm, false, true);
            }

            if (ServerConfig.AgreeToRulesOnEntry && group.Permission == LevelPermission.Guest && !Server.agreed.Contains(name))
            {
                SendMessage("&9You must read the &c/Rules&9 and &c/Agree&9 to them before you can build and use commands!");
                agreed = false;
            }

            if (ServerConfig.verifyadmins && group.Permission >= ServerConfig.VerifyAdminsRank)
            {
                if (!Directory.Exists("extra/passwords") || !File.Exists("extra/passwords/" + name + ".dat"))
                {
                    SendMessage("&cPlease set your admin verification password with %T/SetPass [Password]!");
                }
                else
                {
                    SendMessage("&cPlease complete admin verification with %T/Pass [Password]!");
                }
            }

            try {
                if (group.CanExecute("inbox") && Database.TableExists("Inbox" + name))
                {
                    using (DataTable table = Database.Backend.GetRows("Inbox" + name, "*")) {
                        if (table.Rows.Count > 0)
                        {
                            SendMessage("You have &a" + table.Rows.Count + " %Smessages in %T/Inbox");
                        }
                    }
                }
            } catch {
            }

            if (ServerConfig.PositionUpdateInterval > 1000)
            {
                SendMessage("Lowlag mode is currently &aON.");
            }

            if (String.IsNullOrEmpty(appName))
            {
                Logger.Log(LogType.UserActivity, "{0} [{1}] connected.", name, ip);
            }
            else
            {
                Logger.Log(LogType.UserActivity, "{0} [{1}] connected using {2}.", name, ip, appName);
            }
            Game.InfectMessages = PlayerDB.GetInfectMessages(this);
            Server.lava.PlayerJoinedServer(this);

            Position pos = level.SpawnPos;
            byte     yaw = level.rotx, pitch = level.roty;

            OnPlayerSpawningEvent.Call(this, ref pos, ref yaw, ref pitch, false);
            Pos = pos;
            SetYawPitch(yaw, pitch);

            Entities.SpawnEntities(this, true);
            PlayerActions.CheckGamesJoin(this, null);
            Loading = false;
        }
Ejemplo n.º 17
0
        /// <summary> Sends a message to all players who are have the permission to read opchat. </summary>
        public static void MessageOps(string message)
        {
            LevelPermission rank = CommandExtraPerms.MinPerm("opchat", LevelPermission.Operator);

            MessageWhere(message, pl => pl.Rank >= rank);
        }