Пример #1
0
        public static void AddObject(string[] args, WorldClass session)
        {
            var pChar = session.Character;

            int objectId = CommandParser.Read<int>(args, 1);

            GameObject gObject = DataMgr.FindGameObject(objectId);
            if (gObject != null)
            {
                ChatMessageValues chatMessage = new ChatMessageValues(0, "");

                GameObjectSpawn spawn = new GameObjectSpawn()
                {
                    Guid = GameObjectSpawn.GetLastGuid() + 1,
                    Id = objectId,
                    GameObject = gObject,
                    Position = pChar.Position,
                    Map = pChar.Map
                };

                if (spawn.AddToDB())
                {
                    chatMessage.Message = "Spawn successfully added.";

                    spawn.AddToWorld();
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
                else
                {
                    chatMessage.Message = "Spawn can't be added.";

                    ChatHandler.SendMessage(ref session, chatMessage);
                }
            }
        }
Пример #2
0
        public static void AddNpc(string[] args, WorldClass session)
        {
            var level = CommandParser.Read<byte>(args, 1);
            var chatMessage = new ChatMessageValues(0, "Please enter a level between 0 and 91.");

            if (level > 90 || level < 1)
            {
                ChatHandler.SendMessage(ref session, chatMessage);
                return;
            }

            var pChar = session.Character;

            if (SmartGuid.GetGuidType(pChar.TargetGuid) == HighGuidType.Player)
            {
               if (DB.Characters.Execute("UPDATE Characters SET Level = ? WHERE Guid = ?", level, pChar.Guid))
               {
                   pChar.SetUpdateField<uint>((int)UnitFields.Level, level);

                   ObjectHandler.HandleUpdateObjectValues(ref session);
               }
            }
            else
            {
                chatMessage.Message = "Please select a player.";

                ChatHandler.SendMessage(ref session, chatMessage);
            }
        }
Пример #3
0
        public static void AddNpc(string[] args, WorldClass session)
        {
            var pChar = session.Character;

            int creatureId = CommandParser.Read<int>(args, 1);

            Creature creature = DataMgr.FindCreature(creatureId);
            if (creature != null)
            {
                ChatMessageValues chatMessage = new ChatMessageValues(0, "");

                CreatureSpawn spawn = new CreatureSpawn()
                {
                    Guid     = CreatureSpawn.GetLastGuid() + 1,
                    Id       = creatureId,
                    Creature = creature,
                    Position = pChar.Position,
                    Map      = pChar.Map
                };

                if (spawn.AddToDB())
                {
                    chatMessage.Message = "Spawn successfully added.";

                    spawn.AddToWorld();
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
                else
                {
                    chatMessage.Message = "Spawn can't be added.";
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
            }
        }
Пример #4
0
        public static void AddTele(string[] args, WorldClass session)
        {
            var pChar = session.Character;

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

            ChatMessageValues chatMessage = new ChatMessageValues(0, "");

            if (result.Count == 0)
            {
                if (DB.World.Execute("INSERT INTO teleport_locations (location, x, y, z, o, map) " +
                    "VALUES (?, ?, ?, ?, ?, ?)", location, pChar.Position.X, pChar.Position.Y, pChar.Position.Z, pChar.Position.O, pChar.Map))
                {
                    chatMessage.Message = string.Format("Teleport location '{0}' successfully added.", location);

                    ChatHandler.SendMessage(ref session, chatMessage);
                }
            }
            else
            {
                chatMessage.Message = string.Format("Teleport location '{0}' already exist.", location);

                ChatHandler.SendMessage(ref session, chatMessage);
            }
        }
Пример #5
0
        public static void DeleteNpc(string[] args, WorldClass session)
        {
            ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageSystem, "");

            var pChar = session.Character;
            var spawn = SpawnMgr.FindSpawn(pChar.TargetGuid);

            if (spawn != null)
            {
                SpawnMgr.RemoveSpawn(spawn);

                var destroyObject = ObjectHandler.HandleDestroyObject(ref session, pChar.TargetGuid);

                session.Send(ref destroyObject);
                WorldMgr.SendToInRangeCharacter(pChar, destroyObject);

                chatMessage.Message = "Selected Spawn successfully removed.";

                ChatHandler.SendMessage(ref session, chatMessage);
            }
            else
            {
                chatMessage.Message = "Not a creature.";

                ChatHandler.SendMessage(ref session, chatMessage);
            }
        }
Пример #6
0
        public static void FlightSpeed(string[] args, WorldClass session)
        {
            ChatMessageValues chatMessage = new ChatMessageValues(0, "");

            if (args.Length == 1)
                MoveHandler.HandleMoveSetFlightSpeed(ref session);
            else
            {
                var speed = CommandParser.Read<float>(args, 1);

                if (speed <= 50 && speed > 0)
                {
                    chatMessage.Message = "Flight speed set to " + speed + "!";

                    MoveHandler.HandleMoveSetFlightSpeed(ref session, speed);
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
                else
                {
                    chatMessage.Message = "Please enter a value between 0.0 and 50.0!";

                    ChatHandler.SendMessage(ref session, chatMessage);
                }

                return;
            }

            chatMessage.Message = "Flight speed set to default.";

            ChatHandler.SendMessage(ref session, chatMessage);
        }
Пример #7
0
        public static void Save(string[] args, WorldClass session)
        {
            ObjectMgr.SavePositionToDB(session.Character);

            ChatMessageValues chatMessage = new ChatMessageValues(0, "Your character is successfully saved to the database!");

            ChatHandler.SendMessage(ref session, chatMessage);
        }
Пример #8
0
        public static void DelTele(string[] args, WorldClass session)
        {
            var pChar = session.Character;

            string location = CommandParser.Read<string>(args, 1);

            ChatMessageValues chatMessage = new ChatMessageValues(0, string.Format("Teleport location '{0}' successfully deleted.", location));

            if (DB.World.Execute("DELETE FROM teleport_locations WHERE location = ?", location))
                ChatHandler.SendMessage(ref session, chatMessage);
        }
Пример #9
0
        public static void HandleChatMessageYell(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            var language = packet.ReadInt32();

            var messageLength = packet.ReadByte();
            var message = packet.ReadString(messageLength);

            ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageYell, message, true, true);
            chatMessage.Language = (byte)language;

            SendMessage(ref session, chatMessage);
        }
Пример #10
0
        public static void Morph(string[] args, WorldClass session)
        {
            var displayId = CommandParser.Read<uint>(args, 1);
            var pChar = session.Character;

            if (pChar != null)
            {
                if (pChar.TargetGuid == 0)
                {
                    pChar.SetUpdateField<uint>((int)UnitFields.DisplayID, displayId);
                    pChar.SetUpdateField<uint>((int)UnitFields.NativeDisplayID, displayId);

                    ObjectHandler.HandleUpdateObjectValues(ref session, true);

                    var chatMessage = new ChatMessageValues(0, "Successfully morphed");
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
                else
                {
                    HighGuidType type = SmartGuid.GetGuidType(pChar.TargetGuid);
                    bool success = false;

                    switch (type)
                    {
                        case HighGuidType.Player:
                            var pSession = WorldMgr.GetSession(pChar.TargetGuid);
                            if (pSession == null)
                                return;
                            pSession.Character.SetUpdateField<uint>((int)UnitFields.DisplayID, displayId);
                            pSession.Character.SetUpdateField<uint>((int)UnitFields.NativeDisplayID, displayId);

                            ObjectHandler.HandleUpdateObjectValues(ref pSession, true);

                            success = true;
                            break;

                        case HighGuidType.Unit:
                        case HighGuidType.Pet:
                        default:
                            break;
                    }

                    if (success)
                    {
                        var chatMessage = new ChatMessageValues(0, "Successfully morphed");
                        ChatHandler.SendMessage(ref session, chatMessage);
                    }
                }
            }
        }
Пример #11
0
        public static void HandleChatMessageSay(ref PacketReader packet, WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            var language = packet.Read<int>();

            var messageLength = BitUnpack.GetBits<byte>(8);
            var message = packet.ReadString(messageLength);

            ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageSay, message, true, true);
            chatMessage.Language = (byte)language;

            if (ChatCommandParser.CheckForCommand(message))
                ChatCommandParser.ExecuteChatHandler(message, session);
            else
                SendMessage(ref session, chatMessage);
        }
Пример #12
0
        public static void Morph(string[] args, WorldClass session)
        {
            var displayId = CommandParser.Read<uint>(args, 1);
            var pChar = session.Character;

            if (pChar != null)
            {
                pChar.SetUpdateField<uint>((int)UnitFields.DisplayID, displayId);
                pChar.SetUpdateField<uint>((int)UnitFields.NativeDisplayID, displayId);

                ObjectHandler.HandleUpdateObjectValues(ref session);

                var chatMessage = new ChatMessageValues(0, "Successfully morphed");

                ChatHandler.SendMessage(ref session, chatMessage);
            }
        }
Пример #13
0
        public static void Help(string[] args, WorldClass session)
        {
            StringBuilder commandList = new StringBuilder();

            foreach (var command in ChatCommandParser.ChatCommands)
            {
                var helpAttribute = (ChatCommandAttribute[])command.Value.Method.GetCustomAttributes(typeof(ChatCommandAttribute), false);
                foreach (var desc in helpAttribute)
                {
                    if (!String.IsNullOrEmpty(desc.Description))
                        commandList.AppendLine(WorldConfig.GMCommandStart + command.Key + " [" + desc.Description + "]");
                    else
                        commandList.AppendLine(WorldConfig.GMCommandStart + command.Key);
                }
            }

            ChatMessageValues chatMessage = new ChatMessageValues(0, commandList.ToString());

            ChatHandler.SendMessage(ref session, chatMessage);
        }
Пример #14
0
        public static void Ban(string[] args, WorldClass session)
        {
            var pName = CommandParser.Read<string>(args, 1);
            ChatMessageValues ChatMessage = new ChatMessageValues(0, "");

            SQLResult result = DB.Characters.Select("SELECT * FROM characters WHERE name = ?", pName);
            if (result.Count == 0)
            {

                ChatMessage.Message = "Could not find character with that name";
                ChatHandler.SendMessage(ref session, ChatMessage);
            }
            else
            {
                var AccId = result.Read<string>(0, "accountid");
                DB.Realms.Execute("UPDATE accounts SET banned = 1 WHERE id = ?", AccId);

                ChatMessage.Message = "Successfully banned account";
                ChatHandler.SendMessage(ref session, ChatMessage);
            }
        }
Пример #15
0
        public static void HandleChatMessageWhisper(ref PacketReader packet, WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            var language = packet.Read<int>();

            var nameLength = BitUnpack.GetBits<byte>(9);
            var messageLength = BitUnpack.GetBits<byte>(8);

            string receiverName = packet.ReadString(nameLength);
            string message = packet.ReadString(messageLength);

            WorldClass rSession = WorldMgr.GetSession(receiverName);

            if (rSession == null)
                return;

            ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisperInform, message, false, true);
            SendMessage(ref session, chatMessage, rSession);

            chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisper, message, false, true);
            SendMessage(ref rSession, chatMessage, session);
        }
Пример #16
0
        public static void goLoc(string[] args, WorldClass session)
        {
            var pChar = session.Character;
            ChatMessageValues chatMessage;

            if (args.Length != 2)
            {
                chatMessage = new ChatMessageValues(0, "You must provide an ID to retrieve its location!");
                ChatHandler.SendMessage(ref session, chatMessage);
                return;
            }

            uint WSL = CommandParser.Read<uint>(args, 1);

            var safeloc = CliDB.WorldSafeLocs.SingleOrDefault(areapoi => areapoi.ID == WSL);

            if (safeloc == null)
            {
                chatMessage = new ChatMessageValues(0, "ID not found!!!");
                ChatHandler.SendMessage(ref session, chatMessage);
                return;
            }

            Vector4 vector = new Vector4()
            {
                X = safeloc.X,
                Y = safeloc.Y,
                Z = safeloc.Z,
                O = Math.Min(Math.Max(safeloc.O, -6.2831853F), 6.2831853F) // Avoid extrange values on DBCs
            };
            uint mapId = safeloc.mapID;

            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);
            }

            chatMessage = new ChatMessageValues(0, string.Format("Teleported to {0}", safeloc.Name));
            ChatHandler.SendMessage(ref session, chatMessage);
        }
Пример #17
0
        public static void goPOI(string[] args, WorldClass session)
        {
            var pChar = session.Character;
            ChatMessageValues chatMessage;

            int nPOIs = CliDB.AreaPOI.Count;
            if ((args.Length < 2) || (args.Length > 3))
            {
                chatMessage = new ChatMessageValues(0, "wrong number of parameters!");
                ChatHandler.SendMessage(ref session, chatMessage);
                return;
            }

            uint POI = CommandParser.Read<uint>(args, 1);

            // Z value not stored into AreaPOI.dbc, so I take a fixed value or the one given at command line
            float z = (args.Length == 3) ? CommandParser.Read<float>(args, 2) : (float)300.0;

            var area = CliDB.AreaPOI.SingleOrDefault(areapoi => areapoi.AreaID == POI);
            if (area == null)
            {
                chatMessage = new ChatMessageValues(0, "POI not found!!!");
                ChatHandler.SendMessage(ref session, chatMessage);
                return;
            }

            Vector4 vector = new Vector4()
            {
                X = area.X,
                Y = area.Y,
                Z = z,
                O = 0
            };

            uint mapId = area.mapID;

            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);
            }

            chatMessage = new ChatMessageValues(0, string.Format("Teleported to {0}!", area.Name));
            ChatHandler.SendMessage(ref session, chatMessage);
        }
Пример #18
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);
            }
        }
Пример #19
0
        public static void GPS(string[] args, WorldClass session)
        {
            var pChar = session.Character;

            var message = string.Format("Your position is X: {0}, Y: {1}, Z: {2}, W(O): {3}, Map: {4}, Zone: {5}", pChar.Position.X, pChar.Position.Y, pChar.Position.Z, pChar.Position.O, pChar.Map, pChar.Zone);
            ChatMessageValues chatMessage = new ChatMessageValues(0, message);

            ChatHandler.SendMessage(ref session, chatMessage);
        }
Пример #20
0
        public static void Fly(string[] args, WorldClass session)
        {
            var state = CommandParser.Read<string>(args, 1);
            var message = state == "on" ? "Fly mode enabled." : "Fly mode disabled.";

            ChatMessageValues chatMessage = new ChatMessageValues(0, message);

            if (state == "on")
            {
                MoveHandler.HandleMoveSetCanFly(ref session);
                ChatHandler.SendMessage(ref session, chatMessage);
            }
            else if (state == "off")
            {
                MoveHandler.HandleMoveUnsetCanFly(ref session);
                ChatHandler.SendMessage(ref session, chatMessage);
            }
        }
Пример #21
0
        public static void listLocs(string[] args, WorldClass session)
        {
            var pChar = session.Character;
            ChatMessageValues chatMessage;

            int nWSLs = CliDB.WorldSafeLocs.Count;
            if (args.Length == 1)
            {
                // List all WorldSafeLocs
                foreach (var wsl in CliDB.WorldSafeLocs)
                {
                    chatMessage = new ChatMessageValues(0, string.Format("{0} -> {1}", wsl.Name, wsl.ID));
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
            }
            else if (args.Length == 2)
            {
                // List WSLs which contains the given string
                string givenstr = CommandParser.Read<string>(args, 1);
                var locs = CliDB.WorldSafeLocs.Where(safeloc => safeloc.Name.IndexOf(givenstr) > -1).ToList();

                // If no POIs found, we'll warn about it
                int count = locs.Count;
                if (count == 0)
                {
                    chatMessage = new ChatMessageValues(0, string.Format("No WorldSafeLocs found containing '{0}'!!!", givenstr));
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
                else
                {
                    chatMessage = new ChatMessageValues(0, string.Format("Found {0} WorldSafeLocs containing '{1}':", count, givenstr));
                    ChatHandler.SendMessage(ref session, chatMessage);
                    foreach (var wfl in locs)
                    {
                        chatMessage = new ChatMessageValues(0, string.Format("{0} -> {1}", wfl.Name, wfl.ID));
                        ChatHandler.SendMessage(ref session, chatMessage);
                    }
                }
            }
            else
            {
                chatMessage = new ChatMessageValues(0, "Wrong number of parameters");
                ChatHandler.SendMessage(ref session, chatMessage);
            }
        }
Пример #22
0
        public static void listPOI(string[] args, WorldClass session)
        {
            var pChar = session.Character;
            ChatMessageValues chatMessage;

            if (args.Length == 1)
            {
                // List all POIs
                foreach (var poi in CliDB.AreaPOI)
                {
                    chatMessage = new ChatMessageValues(0, string.Format("{0} -> {1}", poi.Name, poi.AreaID));
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
            }
            else if (args.Length == 2)
            {
                // List POIs which contains the given string
                string givenstr = CommandParser.Read<string>(args, 1);
                var areas = CliDB.AreaPOI.Where(areapoi => areapoi.Name.IndexOf(givenstr) > -1).ToList();

                int count = areas.Count;
                if (count == 0)
                {
                    chatMessage = new ChatMessageValues(0, string.Format("No POIs found containing '{0}'!!!", givenstr));
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
                else
                {
                    chatMessage = new ChatMessageValues(0, string.Format("Found {0} POIs containing '{1}':", count, givenstr));
                    ChatHandler.SendMessage(ref session, chatMessage);
                    foreach (var poi in areas)
                    {
                        chatMessage = new ChatMessageValues(0, string.Format("{0} -> {1}", poi.Name, poi.AreaID));
                        ChatHandler.SendMessage(ref session, chatMessage);
                    }
                }
            }
            else
            {
                chatMessage = new ChatMessageValues(0, "Wrong number of parameters");
                ChatHandler.SendMessage(ref session, chatMessage);
            }
        }
Пример #23
0
        public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage, WorldClass pSession = null)
        {
            byte[] GuidMask = { 4, 1, 3, 6, 2, 5, 0, 7 };
            byte[] GuidMask3 = { 6, 1, 3, 5, 4, 2, 7, 0 };
            byte[] GuidBytes = { 7, 4, 0, 6, 3, 2, 5, 1 };
            byte[] GuidBytes3 = { 7, 4, 1, 3, 0, 6, 5, 2 };

            var pChar = session.Character;
            var guid = pChar.Guid;

            if (pSession != null)
                guid = pSession.Character.Guid;

            PacketWriter chat = new PacketWriter(ServerMessage.Chat);
            BitPack BitPack = new BitPack(chat, guid);

            BitPack.Write(!chatMessage.HasLanguage);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask3);

            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(!chatMessage.HasRealmId);
            BitPack.Write(0);
            BitPack.WriteStringLength(chatMessage.Message, 12);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask);

            BitPack.Write(0);
            BitPack.Write(8, 9);

            BitPack.Flush();

            BitPack.WriteGuidBytes(GuidBytes3);

            if (chatMessage.HasLanguage)
                chat.WriteUInt8(chatMessage.Language);

            BitPack.WriteGuidBytes(GuidBytes);

            chat.WriteString(chatMessage.Message, false);
            chat.WriteUInt8((byte)chatMessage.ChatType);

            chat.WriteInt32(0);

            if (chatMessage.HasRealmId)
                chat.WriteInt32(chatMessage.RealmId);

            switch (chatMessage.ChatType)
            {
                case MessageType.ChatMessageSay:
                    WorldMgr.SendByDist(pChar, chat, 625);
                    break;
                case MessageType.ChatMessageYell:
                    WorldMgr.SendByDist(pChar, chat, 90000);
                    break;
                default:
                    session.Send(ref chat);
                    break;
            }
        }
Пример #24
0
        public static void TeleList(string[] args, WorldClass session)
        {
            var infoMsg = "No locations found!";
            SQLResult result;

            // If there is an argument, use it as 'LIKE' parameter into the SQL command
            if (args.Length > 1)
            {
                string query = string.Format("SELECT location FROM teleport_locations WHERE location LIKE '%{0}%' ORDER BY location ASC", CommandParser.Read<string>(args, 1));
                infoMsg = "No locations found matching your criteria!";
                result = DB.World.Select(query);
            }
            else
            {
                result = DB.World.Select("SELECT location FROM teleport_locations ORDER BY location ASC");
            }

            if (result.Count == 0)
            {
                var chatMessage = new ChatMessageValues(0, infoMsg);
                ChatHandler.SendMessage(ref session, chatMessage);
            }
            else
            {
                var chatMessage = new ChatMessageValues(0, string.Format("{0} match(es) found:", result.Count));
                ChatHandler.SendMessage(ref session, chatMessage);

                for (int i = 0; i < result.Count; i++)
                {
                    chatMessage = new ChatMessageValues(0, result.Read<string>(i, "location"));
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
            }
        }
Пример #25
0
        public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage)
        {
            byte[] GuidMask = { 4, 7, 6, 3, 0, 5, 1, 2 };
            byte[] GuidMask3 = { 4, 0, 7, 2, 1, 5, 3, 6 };
            byte[] GuidBytes = { 3, 5, 1, 4, 2, 6, 0, 7 };
            byte[] GuidBytes3 = { 7, 6, 0, 3, 4, 1, 5, 2 };

            var pChar = session.Character;

            PacketWriter chat = new PacketWriter(ServerMessage.Chat);
            BitPack BitPack = new BitPack(chat, pChar.Guid);

            BitPack.Write(1);
            BitPack.Write(!chatMessage.HasLanguage);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.WriteGuidMask(GuidMask);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(chatMessage.Message.Length, 12);
            BitPack.Write(!chatMessage.HasRealmId);
            BitPack.WriteGuidMask(GuidMask3);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(8, 9);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Flush();

            BitPack.WriteGuidBytes(GuidBytes);

            chat.WriteString(chatMessage.Message);

            if (chatMessage.HasRealmId)
                chat.WriteInt32(chatMessage.RealmId);

            BitPack.WriteGuidBytes(GuidBytes3);

            if (chatMessage.HasLanguage)
                chat.WriteUInt8(chatMessage.Language);

            chat.WriteUInt8((byte)chatMessage.ChatType);

            switch (chatMessage.ChatType)
            {
                case MessageType.ChatMessageSay:
                    WorldMgr.SendByDist(pChar, chat, 625);
                    break;
                case MessageType.ChatMessageYell:
                    WorldMgr.SendByDist(pChar, chat, 90000);
                    break;
                default:
                    break;
            }
        }
Пример #26
0
 public static void Unban(string[] args, WorldClass session)
 {
     ChatMessageValues ChatMessage = new ChatMessageValues(0, "");
     ChatMessage.Message = "Command not yet implemented";
     ChatHandler.SendMessage(ref session, ChatMessage);
 }