Пример #1
0
        private void OnUserAdd(object sender, EventArgs args)
        {
            try
            {
                KeyValuePair <int, RoomUser> userPair = (KeyValuePair <int, RoomUser>)sender;
                RoomUser user = userPair.Value;

                if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null)
                {
                    return;
                }

                GameClient session = user.GetClient();

                if (session == null || session.GetHabbo() == null)
                {
                    return;
                }

                if (userCount >= room.UsersMax && user.GetClient().GetHabbo().Rank < 4)
                {
                    ServerMessage msg = new ServerMessage(33);
                    msg.AppendInt32(4008);
                    session.SendMessage(msg);
                    return;
                }

                if (session.GetHabbo() != null && session.GetHabbo().userGroup != null)
                {
                    Group group = session.GetHabbo().userGroup;
                    if (!room.groups.ContainsKey(group.groupID))
                    {
                        room.groups.Add(group.groupID, group);
                    }
                }

                if (!user.IsSpectator)
                {
                    DynamicRoomModel Model = room.GetGameMap().Model;
                    if (room.IsPublic && session.SetDoorPos)
                    {
                        user.SetPos(session.newDoorPos.X, session.newDoorPos.Y, room.GetGameMap().StaticModel.SqFloorHeight[session.newDoorPos.X, session.newDoorPos.Y]);
                        user.SetRot(Model.DoorOrientation, false);
                        session.SetDoorPos = false;
                    }
                    else
                    {
                        user.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ);
                        user.SetRot(Model.DoorOrientation, false);
                    }

                    if (room.CheckRights(session, true))
                    {
                        user.AddStatus("flatcrtl", "useradmin");
                    }
                    else if (room.CheckRights(session))
                    {
                        user.AddStatus("flatcrtl", "");
                    }
                    user.CurrentItemEffect = ItemEffectType.None;

                    //UpdateUserEffect(User, User.X, User.Y);

                    if (!user.IsBot && user.GetClient().GetHabbo().IsTeleporting)
                    {
                        RoomItem Item = room.GetRoomItemHandler().GetItem(user.GetClient().GetHabbo().TeleporterId);

                        if (Item != null)
                        {
                            user.SetPos(Item.GetX, Item.GetY, Item.GetZ);
                            user.SetRot(Item.Rot, false);

                            Item.InteractingUser2 = session.GetHabbo().Id;
                            Item.ExtraData        = "2";
                            Item.UpdateState(false, true);
                        }
                    }

                    user.GetClient().GetHabbo().IsTeleporting = false;
                    user.GetClient().GetHabbo().TeleporterId  = 0;

                    ServerMessage EnterMessage = new ServerMessage(28);
                    EnterMessage.AppendInt32(1);
                    user.Serialize(EnterMessage, room.GetGameMap().gotPublicPool);
                    room.SendMessage(EnterMessage);


                    if (room.Owner != session.GetHabbo().Username&& !room.IsPublic)
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(user.GetClient(), HabboHotel.Quests.QuestType.SOCIAL_VISIT);
                    }
                }

                if (session.GetHabbo().GetMessenger() != null)
                {
                    session.GetHabbo().GetMessenger().OnStatusChanged(true);
                }


                if (!user.IsSpectator)
                {
                    foreach (RoomUser roomUser in UserList.Values)
                    {
                        if (!user.IsBot)
                        {
                            continue;
                        }

                        roomUser.BotAI.OnUserEnterRoom(user);
                    }
                }

                user.GetClient().GetMessageHandler().OnRoomUserAdd();

                if (OnUserEnter != null)
                {
                    OnUserEnter(user, null);
                }

                if (room.GotMusicController())
                {
                    room.GetRoomMusicController().OnNewUserEnter(user);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException(e.ToString());
            }
        }