Exemplo n.º 1
0
        internal static ServerMessage SerializeRoomChatlog(uint roomID)
        {
            // NEW CHATLOGS [March 2014] Coded by Finn
            // Please don't remove credits, this took me some time to do... :(
            // Credits to Itachi for the structure's "context" enigma :D




            ServerMessage Message = new ServerMessage();
            RoomData Room = SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomID);
            if (Room == null)
            {
                throw new NullReferenceException("No room found.");
            }




            Message.Init(Outgoing.RoomChatlog);
            Message.AppendByte(1);
            Message.AppendShort(2);
            Message.AppendString("roomName");
            Message.AppendByte(2);
            Message.AppendString(Room.Name);
            Message.AppendString("roomId");
            Message.AppendByte(1);
            Message.AppendInt32(Room.Id);




            Message.AppendShort(Room.RoomChat.Count);
            Room.RoomChat.Reverse();
            foreach (Chatlog Log in Room.RoomChat)
            {
                Habbo Habbo = SilverwaveEnvironment.getHabboForId(Log.UserId);
                DateTime Date = SilverwaveEnvironment.UnixToDateTime(Log.Timestamp);
                if (Habbo == null)
                {
                    Message.AppendInt32((DateTime.Now - Date).Seconds);
                    Message.AppendInt32(Log.UserId);
                    Message.AppendString("*User not found*");
                    Message.AppendString(Log.Message);
                    Message.AppendBoolean(true);
                }
                else
                {
                    Message.AppendInt32((DateTime.Now - Date).Seconds);
                    Message.AppendInt32(Habbo.Id);
                    Message.AppendString(Habbo.Username);
                    Message.AppendString(Log.Message);
                    Message.AppendBoolean(false); // Text is bold
                }
            }
            Room.RoomChat.Reverse();
            return Message;
        }
Exemplo n.º 2
0
        public void OnTrigger(GameClients.GameClient Session, RoomItem Item, int Request, bool HasRights)
        {
            if (Session == null || Item == null)
                return;

            if (!HasRights)
                return;

            String ExtraInfo = "";
            int Delay = 0;
            List<RoomItem> items = new List<RoomItem>();

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT * FROM wired_items WHERE id=@id LIMIT 1");
                dbClient.addParameter("id", Item.Id);
                DataRow Row = dbClient.getRow();

                ExtraInfo = Row["string"].ToString();
                Delay = (int)Row["delay"] / 500;
                foreach (String sItem in Row["items"].ToString().Split(';'))
                {
                    uint Id = 0;
                    if (uint.TryParse(sItem, out Id))
                    {
                        RoomItem rItem = Item.GetRoom().GetRoomItemHandler().GetItem(Id);

                        if (rItem == null || items.Contains(rItem))
                            continue;

                        items.Add(rItem);
                    }
                }
            }

            switch (Item.GetBaseItem().InteractionType)
            {
                #region Triggers

                case InteractionType.triggerwalkonfurni:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);

                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggergamestart:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredTrigger);
                        message.AppendBoolean(false);
                        message.AppendInt32(0);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggerroomenter:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredTrigger);
                        message.AppendBoolean(false);
                        message.AppendInt32(0);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(7);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggergameend:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredTrigger);
                        message.AppendBoolean(false);
                        message.AppendInt32(0);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggertimer:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredTrigger);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);

                        message.AppendString(ExtraInfo);
                        message.AppendInt32(1);
                        message.AppendInt32(1);
                        message.AppendInt32(1);
                        message.AppendInt32(3);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggerwalkofffurni:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);

                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggeronusersay:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredTrigger);
                        message.AppendBoolean(false);
                        message.AppendInt32(0);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggerscoreachieved:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredTrigger);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(1);
                        message.AppendInt32(100);
                        message.AppendInt32(0);
                        message.AppendInt32(10);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggerrepeater:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredTrigger);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(1);
                        message.AppendInt32(Delay);
                        message.AppendInt32(0);
                        message.AppendInt32(6);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.triggerstatechanged:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(Delay);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }
                #endregion

                #region Effects
                case InteractionType.actionposreset:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString("");
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(3);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.actiongivescore:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(2);
                        message.AppendInt32(5);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(6);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.actionresettimer:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.actiontogglestate:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(Delay);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.actionkickuser:
                case InteractionType.actionshowmessage:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(0);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(7);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.actionteleportto:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(Delay);
                        message.AppendInt32(0);
                        message.AppendByte(2);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.actionmoverotate:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(2);
                        message.AppendInt32(int.Parse(ExtraInfo.Split(';')[0]));
                        message.AppendInt32(int.Parse(ExtraInfo.Split(';')[1]));
                        message.AppendInt32(0);
                        message.AppendInt32(4);
                        message.AppendInt32(Delay);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                #endregion

                #region Add-ons
                case InteractionType.specialrandom:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.specialunseen:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredEffect);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendString(ExtraInfo);
                        message.AppendInt32(0);
                        message.AppendInt32(8);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }
                #endregion

                #region Conditions
                case InteractionType.conditiontimelessthan:
                case InteractionType.conditiontimemorethan:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredCondition);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);

                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.conditionfurnihasfurni:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredCondition);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);

                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendBoolean(false);
                        message.AppendBoolean(true);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.conditionfurnishaveusers:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredCondition);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);

                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendBoolean(false);
                        message.AppendBoolean(true);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.conditionstatepos:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredCondition);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);

                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendBoolean(false);
                        message.AppendBoolean(false);
                        Session.SendMessage(message);
                        break;
                    }

                case InteractionType.conditiontriggeronfurni:
                    {
                        ServerMessage message = new ServerMessage(Outgoing.WiredCondition);
                        message.AppendBoolean(false);
                        message.AppendInt32(5);
                        message.AppendInt32(items.Count);
                        foreach (RoomItem item in items)
                            message.AppendInt32(item.Id);
                        message.AppendInt32(Item.GetBaseItem().SpriteId);
                        message.AppendInt32(Item.Id);

                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendInt32(0);
                        message.AppendBoolean(false);
                        message.AppendBoolean(true);

                        Session.SendMessage(message);
                        break;
                    }

                //Unknown:
                //2 radio + 5 selct
                #endregion

            }
        }