Пример #1
0
        public override void Use(Player p, string message)
        {
            if (message.Length > 0)
            {
                Help(p); return;
            }
            bool     cpSpawn = p.useCheckpointSpawn;
            Position pos;

            pos.X = 16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32;
            pos.Y = 32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32;
            pos.Z = 16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32;
            byte yaw   = cpSpawn ? p.checkpointRotX : p.level.rotx;
            byte pitch = cpSpawn ? p.checkpointRotY : p.level.roty;

            OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, true);

            if (p.PlayingTntWars)
            {
                TntWarsGame game = TntWarsGame.GameIn(p);
                if (game.GameMode == TntWarsGame.TntWarsGameMode.TDM && game.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers &&
                    game.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && game.RedSpawn != null && game.BlueSpawn != null)
                {
                    bool blue = game.FindPlayer(p).Blue;

                    pos.X = 16 + (blue ? game.BlueSpawn[0] : game.RedSpawn[0]) * 32;
                    pos.Y = 32 + (blue ? game.BlueSpawn[1] : game.RedSpawn[1]) * 32;
                    pos.Z = 16 + (blue ? game.BlueSpawn[2] : game.RedSpawn[2]) * 32;
                    yaw   = (byte)(blue ? game.BlueSpawn[3] : game.RedSpawn[3]);
                    pitch = (byte)(blue ? game.BlueSpawn[4] : game.RedSpawn[4]);
                }
            }

            p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch));
        }
Пример #2
0
        internal static void PostSentMap(Player p, Level prev, Level lvl, bool announce)
        {
            Position    pos = lvl.SpawnPos;
            Orientation rot = p.Rot;
            byte        yaw = lvl.rotx, pitch = lvl.roty;

            // in case player disconnected mid-way through loading map
            if (p.Socket.Disconnected)
            {
                return;
            }

            OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, false);
            rot.RotY  = yaw;
            rot.HeadX = pitch;
            p.Pos     = pos;
            p.SetYawPitch(yaw, pitch);
            if (p.Socket.Disconnected)
            {
                return;
            }

            Entities.SpawnEntities(p, pos, rot);
            OnJoinedLevelEvent.Call(p, prev, lvl, ref announce);
            if (!announce || !Server.Config.ShowWorldChanges)
            {
                return;
            }

            announce = !p.hidden && Server.Config.IRCShowWorldChanges;
            string msg = p.level.IsMuseum ? "λNICK %Swent to the " : "λNICK %Swent to ";

            Chat.MessageFrom(ChatScope.Global, p, msg + lvl.ColoredName,
                             null, FilterGoto(p), announce);
        }
Пример #3
0
        static bool GotoLevel(Player p, Level lvl)
        {
            if (p.level == lvl)
            {
                Player.Message(p, "You are already in {0}%S.", lvl.ColoredName); return(false);
            }
            if (!lvl.CanJoin(p))
            {
                return(false);
            }

            p.Loading = true;
            Entities.DespawnEntities(p);
            Level oldLevel = p.level;

            p.level = lvl;
            p.SendMap(oldLevel);

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

            OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, false);
            Entities.SpawnEntities(p, pos, new Orientation(yaw, pitch));
            CheckGamesJoin(p, oldLevel);

            if (p.level.ShouldShowJoinMessage(oldLevel))
            {
                string msg = p.level.IsMuseum ? " %Swent to the " : " %Swent to ";
                Chat.MessageGlobal(p, p.ColoredName + msg + lvl.ColoredName, false, true);
                OnPlayerActionEvent.Call(p, PlayerAction.JoinWorld, lvl.name);
            }
            return(true);
        }
Пример #4
0
        public static void Respawn(Player p)
        {
            bool     cpSpawn = p.useCheckpointSpawn;
            Position pos;

            pos.X = 16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32;
            pos.Y = 32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32;
            pos.Z = 16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32;
            byte yaw   = cpSpawn ? p.checkpointRotX : p.level.rotx;
            byte pitch = cpSpawn ? p.checkpointRotY : p.level.roty;

            OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, true);

            p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch));
        }
Пример #5
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;
        }