Example #1
0
 public static void Goto(string waypoint, Player p) {
     if ( !Exists(waypoint, p) ) return;
     Waypoint wp = Find(waypoint, p);
     Level lvl = Level.Find(wp.lvlname);
     if ( wp == null ) return;
     if ( lvl != null ) {
         if ( p.level != lvl ) {
             Command.all.Find("goto").Use(p, lvl.name);
             while ( p.Loading ) { Thread.Sleep(250); }
         }
         unchecked { p.SendPos((byte)-1, wp.x, wp.y, wp.z, wp.rotx, wp.roty); }
         Player.SendMessage(p, "Sent you to waypoint");
     }
     else { Player.SendMessage(p, "The map that that waypoint is on isn't loaded right now (" + wp.lvlname + ")"); return; }
 }
Example #2
0
        void DoLocationChecks()
        {
            while (true)
            {
                Thread.Sleep(3);
                Player[] players = PlayerInfo.Online.Items;
                for (int i = 0; i < players.Length; i++)
                {
                    try {
                        Player p = players[i];

                        if (p.frozen)
                        {
                            p.SendPos(0xFF, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]); continue;
                        }
                        else if (p.following != "")
                        {
                            Player who = PlayerInfo.FindExact(p.following);
                            if (who == null || who.level != p.level)
                            {
                                p.following = "";
                                if (!p.canBuild)
                                {
                                    p.canBuild = true;
                                }
                                if (who != null && who.possess == p.name)
                                {
                                    who.possess = "";
                                }
                                continue;
                            }

                            if (p.canBuild)
                            {
                                p.SendPos(0xFF, who.pos[0], (ushort)(who.pos[1] - 16), who.pos[2], who.rot[0], who.rot[1]);
                            }
                            else
                            {
                                p.SendPos(0xFF, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
                            }
                        }
                        else if (p.possess != "")
                        {
                            Player who = PlayerInfo.Find(p.possess);
                            if (who == null || who.level != p.level)
                            {
                                p.possess = "";
                            }
                        }

                        ushort x = (ushort)(p.pos[0] / 32);
                        ushort y = (ushort)(p.pos[1] / 32);
                        ushort z = (ushort)(p.pos[2] / 32);

                        if (p.level.Death)
                        {
                            p.CheckSurvival(x, y, z);
                        }
                        p.CheckBlock(x, y, z);
                        p.oldIndex = p.level.PosToInt(x, y, z);
                    } catch (Exception e) {
                        Server.ErrorLog(e);
                    }
                }
            }
        }
Example #3
0
        public void SendToSpawn(Level mainlevel, Auto_CTF game, Player p1)
        {
            Random rand = new Random();
            if (spawnx == 0 && spawny == 0 && spawnz == 0)
            {
                ushort xx = (ushort)(rand.Next(0, mainlevel.Width));
                ushort yy = (ushort)(rand.Next(0, mainlevel.Height));
                ushort zz = (ushort)(rand.Next(0, mainlevel.Length));
                while (mainlevel.GetTile(xx, yy, zz) != Block.air && game.OnSide((ushort)(zz * 32), this))
                {
                    xx = (ushort)(rand.Next(0, mainlevel.Width));
                    yy = (ushort)(rand.Next(0, mainlevel.Height));
                    zz = (ushort)(rand.Next(0, mainlevel.Length));
                }
                unchecked { p1.SendPos((byte)-1, (ushort)(xx * 32), (ushort)(yy * 32), (ushort)(zz * 32), p1.rot[0], p1.rot[1]); }
            }
            else
                unchecked { p1.SendPos((byte)-1, spawnx, spawny, spawnz, p1.rot[0], p1.rot[1]); }

        }
Example #4
0
        /// <summary> Moves the player to the specified block coordinates. (bY is treated as player feet) </summary>
        public static void MoveCoords(Player p, int bX, int bY, int bZ, byte rotX, byte rotY)
        {
            Position pos = Position.FromFeet(16 + bX * 32, bY * 32, 16 + bZ * 32);

            p.SendPos(Entities.SelfID, pos, new Orientation(rotX, rotY));
        }