public void TryRedeemVoucher(GameClient Session, string Code)
        {
            if (!IsValidCode(Code))
            {
                ServerPacket Error = new ServerPacket(213);
                Error.AppendRawInt32(1);
                Session.SendPacket(Error);
                return;
            }

            int Value = GetVoucherValue(Code);

            TryDeleteVoucher(Code);

            if (Value > 0)
            {
                Session.GetHabbo().Credits += Value;
                Session.GetHabbo().UpdateCreditsBalance(true);
            }

            Session.SendPacket(new ServerPacket(212));
        }
Beispiel #2
0
        public void RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
        {
            /*
            ServerMessage SendReminder = new ServerMessage(7);
            SendReminder.AppendString("");
            SendMessage(SendReminder);
            */

            try
            {
                if (Session == null)
                {
                    return;
                }

                RoomUser User = GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (!UserList.Remove(GetRoomUserByHabbo(Session.GetHabbo().Id)))
                {
                    return;
                }

                if (NotifyClient)
                {
                    if (NotifyKick)
                    {
                        ServerPacket packet = new ServerPacket(33);
                        packet.AppendInt32(4008);
                        Session.SendPacket(packet);
                    }

                    Session.SendPacket(new ServerPacket(18));
                }

                List<RoomUser> PetsToRemove = new List<RoomUser>();

                if (!User.IsSpectator)
                {
                    if (User != null)
                    {
                        UserMatrix[User.X, User.Y] = false;

                        ServerPacket LeaveMessage = new ServerPacket(29);
                        LeaveMessage.AppendRawInt32(User.VirtualId);
                        SendMessage(LeaveMessage);
                    }

                    if (Session.GetHabbo() != null)
                    {
                        if (HasActiveTrade(Session.GetHabbo().Id))
                        {
                            TryStopTrade(Session.GetHabbo().Id);
                        }

                        if (Session.GetHabbo().Username.ToLower() == Owner.ToLower())
                        {
                            if (HasOngoingEvent)
                            {
                                Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

                                if (Room == null || Room.Event == null)
                                {
                                    return;
                                }

                                Event = null;

                                ServerPacket Message = new ServerPacket(370);
                                Message.AppendStringWithBreak("-1");
                                SendMessage(Message);
                            }
                        }

                        Session.GetHabbo().OnLeaveRoom();
                    }
                }

                if (!User.IsSpectator)
                {
                    UpdateUserCount();

                    List<RoomUser> Bots = new List<RoomUser>();

                    foreach (RoomUser Usr in UserList)
                    {
                        if (!Usr.IsBot)
                        {
                            continue;
                        }

                        Bots.Add(Usr);
                    }

                    foreach (RoomUser Bot in Bots)
                    {
                        Bot.BotAI.OnUserLeaveRoom(Session);

                        if (Bot.IsPet && Bot.PetData.OwnerId == Session.GetHabbo().Id && !CheckRights(Session, true))
                        {
                            PetsToRemove.Add(Bot);
                        }
                    }
                }

                foreach (RoomUser toRemove in PetsToRemove)
                {
                    Session.GetHabbo().GetInventoryComponent().AddPet(toRemove.PetData);
                    RemoveBot(toRemove.VirtualId, false);
                }
            }
            catch { UberEnvironment.GetLogging().WriteLine("error in removeruserfromroom", Core.LogLevel.Error); }
        }
Beispiel #3
0
        public void RemoveBot(int VirtualId, bool Kicked)
        {
            RoomUser User = GetRoomUserByVirtualId(VirtualId);

            if (User == null || !User.IsBot)
            {
                return;
            }

            User.BotAI.OnSelfLeaveRoom(Kicked);

            ServerPacket LeaveMessage = new ServerPacket(29);
            LeaveMessage.AppendRawInt32(User.VirtualId);
            SendMessage(LeaveMessage);

            UserMatrix[User.X, User.Y] = false;

            UserList.Remove(User);
        }