Exemplo n.º 1
0
 public static void Spawn(Player p, string message)
 {
     short x = (short)(Program.server.world.spawnx << 5);
     short y = (short)(Program.server.world.spawny << 5);
     short z = (short)(Program.server.world.spawnz << 5);
     p.SendSpawn(new short[] { x, y, z }, new byte[] { Program.server.world.srotx, Program.server.world.sroty });
 }
Exemplo n.º 2
0
 public static void FreezePlayer(Player p, short[] oldPos, byte[] oldRot, short[] newPos, byte[] newRot)
 {
     int dx = newPos[0] - oldPos[0];
     int dy = newPos[1] - oldPos[1];
     int dz = newPos[2] - oldPos[2];
     if ((int)(Math.Sqrt((double)(dx*dx + dz*dz))) > 4)
     {
         p.SendSpawn(oldPos, newRot);
     }
 }
Exemplo n.º 3
0
        public static void Tp(Player p, string message)
        {
            if (message.Trim().Equals(""))
            {
                p.SendMessage(0xFF, "No username specified");
                return;
            }

            Player pl = Player.FindPlayer(p, message, true);
            if (pl != null)
            {
                p.SendSpawn(new short[3] { pl.x, pl.y, pl.z }, new byte[2] { 0, 0 });
                p.SendMessage(0xFF, "Teleported to " + pl.GetFormattedName());
                return;
            }
        }
Exemplo n.º 4
0
        public static void Check(Player p, short[] oldPos, byte[] oldRot, short[] newPos, byte[] newRot)
        {
            //If the player has moved a whole block since the last teleport, allow them to be teleported by resetting p.lastTeleport
            if (newPos[0] >> 5 != p.lastTeleport[0] || newPos[1] >> 5 != p.lastTeleport[1] || newPos[2] >> 5 != p.lastTeleport[2]) p.lastTeleport = new short[] { 0, 0, 0 };

            //If they're standing in the place they were teleported to, don't do anything
            if (newPos[0] >> 5 == p.lastTeleport[0] && newPos[1] >> 5 == p.lastTeleport[1] && newPos[2] >> 5 == p.lastTeleport[2]) return;

            short x = (short)(newPos[0] >> 5);
            short y = (short)((newPos[1] >> 5) - 2);
            short z = (short)(newPos[2] >> 5);

            if (p.world.teleportBlocks.ContainsKey(p.world.CoordsToIndex(x, y, z)))
            {
                //Get the coordinates from the map index
                short[] rawcoords = p.world.IndexToCoords(p.world.teleportBlocks[p.world.CoordsToIndex(x, y, z)]);
                //Teleport to the center of the block
                p.SendSpawn(new short[] { (short)((rawcoords[0] << 5) + 16), (short)((rawcoords[1] << 5) + 64), (short)((rawcoords[2] << 5) + 16) }, newRot);
                //Set the lastTeleport to the new location
                p.lastTeleport = new short[] { rawcoords[0], (short)(rawcoords[1] + 2), rawcoords[2] };
            }
        }