Example #1
0
        public static void Start(string[] args)
        {
            var session = GetSession();
            var pChar   = session.Character;

            SQLResult result = DB.Characters.Select("SELECT map, posX, posY, posZ, posO FROM character_creation_data WHERE race = {0} AND class = {1}", pChar.Race, pChar.Class);

            Vector4 vector = new Vector4()
            {
                X = result.Read <float>(0, "PosX"),
                Y = result.Read <float>(0, "PosY"),
                Z = result.Read <float>(0, "PosZ"),
                W = result.Read <float>(0, "PosO")
            };

            uint mapId = result.Read <uint>(0, "Map");

            if (pChar.Map == mapId)
            {
                MoveHandler.HandleMoveTeleport(ref session, vector);
                ObjectMgr.SetPosition(ref pChar, vector);
            }
            else
            {
                MoveHandler.HandleTransferPending(ref session, mapId);
                MoveHandler.HandleNewWorld(ref session, vector, mapId);

                ObjectMgr.SetPosition(ref pChar, vector);
                ObjectMgr.SetMap(ref pChar, mapId);

                ObjectHandler.HandleUpdateObject(ref session);
            }
        }
Example #2
0
        public static void Teleport(string[] args, WorldClass session)
        {
            var     pChar = session.Character;
            Vector4 vector;
            uint    mapId;

            if (args.Length > 2)
            {
                vector = new Vector4()
                {
                    X = CommandParser.Read <float>(args, 1),
                    Y = CommandParser.Read <float>(args, 2),
                    Z = CommandParser.Read <float>(args, 3),
                    O = CommandParser.Read <float>(args, 4)
                };

                mapId = CommandParser.Read <uint>(args, 5);
            }
            else
            {
                string    location = CommandParser.Read <string>(args, 1);
                SQLResult result   = DB.World.Select("SELECT * FROM teleport_locations WHERE location = ?", location);

                if (result.Count == 0)
                {
                    ChatMessageValues chatMessage = new ChatMessageValues(0, "Teleport location '" + location + "' does not exist.");

                    ChatHandler.SendMessage(ref session, chatMessage);
                    return;
                }

                vector = new Vector4()
                {
                    X = result.Read <float>(0, "X"),
                    Y = result.Read <float>(0, "Y"),
                    Z = result.Read <float>(0, "Z"),
                    O = result.Read <float>(0, "O")
                };

                mapId = result.Read <uint>(0, "Map");
            }

            if (pChar.Map == mapId)
            {
                MoveHandler.HandleMoveTeleport(ref session, vector);
                ObjectMgr.SetPosition(ref pChar, vector);
            }
            else
            {
                MoveHandler.HandleTransferPending(ref session, mapId);
                MoveHandler.HandleNewWorld(ref session, vector, mapId);

                ObjectMgr.SetPosition(ref pChar, vector);
                ObjectMgr.SetMap(ref pChar, mapId);

                ObjectHandler.HandleUpdateObjectCreate(ref session);
            }
        }
Example #3
0
        public static void Teleport(string[] args)
        {
            var     session = GetSession();
            var     pChar   = session.Character;
            Vector4 vector;
            uint    mapId;

            if (args.Length > 2)
            {
                vector = new Vector4()
                {
                    X = CommandParser.Read <float>(args, 1),
                    Y = CommandParser.Read <float>(args, 2),
                    Z = CommandParser.Read <float>(args, 3),
                    W = CommandParser.Read <float>(args, 4)
                };

                mapId = CommandParser.Read <uint>(args, 5);
            }
            else
            {
                string    location = CommandParser.Read <string>(args, 1);
                SQLResult result   = DB.World.Select("SELECT * FROM teleport_locations WHERE location = '{0}'", location);

                vector = new Vector4()
                {
                    X = result.Read <float>(0, "X"),
                    Y = result.Read <float>(0, "Y"),
                    Z = result.Read <float>(0, "Z"),
                    W = result.Read <float>(0, "O")
                };

                mapId = result.Read <uint>(0, "Map");
            }

            if (pChar.Map == mapId)
            {
                MoveHandler.HandleMoveTeleport(ref session, vector);
                ObjectMgr.SetPosition(ref pChar, vector);
            }
            else
            {
                MoveHandler.HandleTransferPending(ref session, mapId);
                MoveHandler.HandleNewWorld(ref session, vector, mapId);

                ObjectMgr.SetPosition(ref pChar, vector);
                ObjectMgr.SetMap(ref pChar, mapId);

                ObjectHandler.HandleUpdateObject(ref session);
            }
        }