public void Message(string Message, ChatType Type, Color Color, string From = "SYSTEM", string To = "ALLUSERS") { Chat *Packet = PacketHelper.CreateChat(From, To, Message); Packet->ChatType = Type; Packet->ID = Entity.UID; Packet->Color = (uint)Color.ToArgb(); Send(Packet, Packet->Size); Memory.Free(Packet); }
public static string[] ParseChat(Chat *Packet) { List <string> Parameters = new List <string>(); for (int i = 0, Index = 0; i < Packet->Count; i++) { string Parameter = new string(Packet->Data, Index + 1, Packet->Data[Index]); Index = Index + (Parameter.Length + 1); Parameters.Add(Parameter); } return(Parameters.ToArray()); }
public static Chat *CreateChat(string From, string To, string Message) { int Size = 24 + From.Length + To.Length + Message.Length; Chat *Packet = (Chat *)Memory.Alloc(Size + 1); Packet->Size = (ushort)Size; Packet->Type = 0x3EC; Packet->Count = 4; byte[] Payload = StringPayload(From, "", To, Message); fixed(byte *pPayload = Payload) { Memory.Copy(pPayload, Packet->Data, Payload.Length); } return(Packet); }
public override void Execute(GameClient Client, byte *pPacket) { AuthMessage *Message = (AuthMessage *)pPacket; uint Token = Message->AccountID | 0xAABB; Token = Message->AccountID << 8 | Message->AccountID; Token = Token ^ 0x4321; Token = Token << 8 | Token; if (Token == Message->LoginToken) { Client.UID = Message->AccountID; Client.GenerateKeys(Message->LoginToken, Message->AccountID); if (Database.GetCharacterData(Client)) { Chat *Response = PacketHelper.CreateChat("SYSTEM", "ALLUSERS", "ANSWER_OK"); Response->ChatType = ChatType.LoginInformation; Response->ID = Message->AccountID; Client.Send(Response, Response->Size); Memory.Free(Response); CharacterInformation *Information = PacketHelper.CreateInformation(Client); Client.Send(Information, Information->Size); Memory.Free(Information); EntityManager.Add(Client); Client.Status = LoginStatus.Complete; } else { Chat *Response = PacketHelper.CreateChat("SYSTEM", "ALLUSERS", "NEW_ROLE"); Response->ChatType = ChatType.LoginInformation; Response->ID = Message->AccountID; Client.Send(Response, Response->Size); Memory.Free(Response); } } else { Client.Disconnect(); } }
public override void Execute(GameClient Client, byte *pPacket) { Chat *Packet = (Chat *)pPacket; string[] Parameters = PacketHelper.ParseChat(Packet); CommandAction Action = CommandAction.None; if ((Action = CommandProcessor.Process(Client, Parameters)) != CommandAction.None) { if (Action == CommandAction.Processed) { } else if (Action == CommandAction.ClearNpcScripts) { NpcScriptEngine.Clear(); } return; } switch (Packet->ChatType) { case ChatType.Talk: Client.SendScreen(Packet, Packet->Size); break; case ChatType.Whisper: GameClient Receiver = EntityManager.FindByName(Parameters[1]); if (Receiver != null) { Receiver.Send(Packet, Packet->Size); } else { Client.Message("It appears that " + Parameters[1] + " is offline", ChatType.Top, Color.White); } break; } }