Esempio n. 1
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            #region Params
            if (Params.Length < 2)
            {
                Session.SendWhisper("Comando inválido, use :banwpp <usuário>", 1);
                return;
            }

            string     Chatter       = Params[1].ToString();
            GameClient TargetSession = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Chatter);

            bool BanFromMaking = false;

            if (Params.Length == 3)
            {
                if (Convert.ToString(Params[2]).ToLower().StartsWith("sim"))
                {
                    BanFromMaking = true;
                }
            }
            #endregion

            #region Conditions
            if (TargetSession == null)
            {
                Session.SendWhisper("Alvo não encontrado!", 1);
                return;
            }
            #endregion

            #region Execute

            if (TargetSession.GetRoleplay().ChatRooms.Count > 0)
            {
                foreach (WebSocketChatRoom Chat in TargetSession.GetRoleplay().ChatRooms.Values)
                {
                    if (Chat == null)
                    {
                        continue;
                    }

                    WebSocketChatManager.Disconnect(TargetSession, Chat.ChatName);
                }
            }

            Session.Shout("*Proíbe imediatamente " + TargetSession.GetHabbo().Username + " de se juntar ou criar Grupos de WhatsApp " + ((BanFromMaking) ? ""  : "") + "!*", 23);
            TargetSession.SendWhisper("Você foi banido de se juntar a uma sala de bate-papo por um membro da equipe!", 1);
            TargetSession.GetRoleplay().BannedFromChatting = true;

            if (BanFromMaking)
            {
                TargetSession.SendWhisper("Você foi proibido de fazer uma sala de bate-papo por um membro da equipe!", 1);
                TargetSession.GetRoleplay().BannedFromMakingChat = true;
            }

            RoleplayManager.Shout(TargetSession, "*Pega meu " + RoleplayManager.GetPhoneName(TargetSession) + " e deleta o Aplicativo WhatsApp*", 4);

            #endregion
        }
Esempio n. 2
0
        public void Disconnect(bool ForcedDisconnect)
        {
            if (LoggingOut)
            {
                return;
            }

            LoggingOut = true;

            try
            {
                #region WebSocket
                PlusEnvironment.GetGame().GetWebEventManager().CloseSocketByGameClient(((this.GetHabbo() == null) ? 0 : this.GetHabbo().Id));
                if (GetRoleplay() != null)
                {
                    foreach (WebSocketChatRoom ChatRoom in GetRoleplay().ChatRooms.Values)
                    {
                        if (ChatRoom == null)
                        {
                            continue;
                        }
                        WebSocketChatManager.Disconnect(this, ChatRoom.ChatName, false, null);
                    }
                }
                #endregion

                if (GetRoomUser() != null && !ForcedDisconnect)
                {
                    RoleplayManager.Chat(this, GetHabbo().Username + " irá sair em 10 segundos.", 1);
                    GetRoomUser().ApplyEffect(95);

                    if (GetHabbo() != null && GetHabbo().CurrentRoom != null)
                    {
                        GetHabbo().CurrentRoom.SendMessage(new SleepComposer(GetRoomUser(), true));
                    }

                    GetRoomUser().CanWalk = false;
                    GetRoomUser().ClearMovement(true);
                }

                if (GetRoleplay() != null)
                {
                    if (GetRoleplay().UserDataHandler != null)
                    {
                        GetRoleplay().UserDataHandler.SaveFarmingData();
                        GetRoleplay().UserDataHandler.SaveCooldownData();
                        GetRoleplay().UserDataHandler.SaveData();
                        GetRoleplay().UserDataHandler = null;
                    }
                }

                if (GetHabbo() != null)
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        dbClient.RunQuery(GetHabbo().GetQueryString);
                }

                if (!ForcedDisconnect)
                {
                    new Thread(() =>
                    {
                        Thread.Sleep(8000);

                        if (GetRoleplay() != null)
                        {
                            GetRoleplay().UserDataHandler = new UserDataHandler(this, GetRoleplay());
                            GetRoleplay().UserDataHandler.SaveFarmingData();
                            GetRoleplay().UserDataHandler.SaveCooldownData();
                            GetRoleplay().UserDataHandler.SaveData();
                            GetRoleplay().UserDataHandler = null;
                        }

                        if (GetHabbo() != null)
                        {
                            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                                dbClient.RunQuery(GetHabbo().GetQueryString);
                        }

                        EventManager.TriggerEvent("OnDisconnect", this);

                        Thread.Sleep(1000);

                        if (GetRoomUser() != null)
                        {
                            GetRoomUser().ApplyEffect(108);
                        }

                        Thread.Sleep(1000);

                        if (GetHabbo() != null)
                        {
                            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.RunQuery(GetHabbo().GetQueryString);
                            }

                            GetHabbo().OnDisconnect();
                        }

                        if (!_disconnected)
                        {
                            if (_connection != null)
                            {
                                _connection.Dispose();
                            }
                            _disconnected = true;
                        }
                    }).Start();
                }
                else
                {
                    EventManager.TriggerEvent("OnDisconnect", this);

                    if (GetHabbo() != null)
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery(GetHabbo().GetQueryString);
                        }

                        GetHabbo().OnDisconnect();
                    }

                    if (!_disconnected)
                    {
                        if (_connection != null)
                        {
                            _connection.Dispose();
                        }
                        _disconnected = true;
                    }
                }
            }
            catch (Exception e)
            {
                Logging.LogException(e.ToString());
            }
        }