예제 #1
0
        private void OnLocalDisconnect()
        {
            try
            {
                LogManager.RuntimeLog("PlayerDisconnect:ClearAll:Start");
                StopLoadingPrompt();
                DEBUG_STEP = 42;
                if (NetEntityHandler.ServerWorld?.LoadedIpl != null)
                {
                    foreach (var ipl in NetEntityHandler.ServerWorld.LoadedIpl)
                    {
                        Function.Call(Hash.REMOVE_IPL, ipl);
                    }
                }

                DEBUG_STEP = 43;
                if (NetEntityHandler.ServerWorld?.RemovedIpl != null)
                {
                    foreach (var ipl in NetEntityHandler.ServerWorld.RemovedIpl)
                    {
                        Function.Call(Hash.REQUEST_IPL, ipl);
                    }
                }

                DEBUG_STEP = 44;

                ClearLocalEntities();

                DEBUG_STEP = 45;

                ClearLocalBlips();

                DEBUG_STEP = 49;
                CameraManager.Reset();
                NetEntityHandler.ClearAll();
                DEBUG_STEP = 50;
                JavascriptHook.StopAllScripts();
                JavascriptHook.TextElements.Clear();
                SyncCollector.ForceAimData = false;
                StringCache.Dispose();
                StringCache         = null;
                _threadsafeSubtitle = null;
                _cancelDownload     = true;
                _httpDownloadThread?.Abort();
                CefController.ShowCursor = false;
                DEBUG_STEP = 51;
                DownloadManager.Cancel();
                DownloadManager.FileIntegrity.Clear();
                Chat = _backupChat;
                Chat.Clear();
                WeaponInventoryManager.Clear();
                VehicleSyncManager.StopAll();
                HasFinishedDownloading = false;
                ScriptChatVisible      = true;
                CanOpenChatbox         = true;
                DisplayWastedMessage   = true;
                _password       = string.Empty;
                CEFManager.Draw = false;

                UIColor = Color.White;

                DEBUG_STEP = 52;

                lock (CEFManager.Browsers)
                {
                    foreach (var browser in CEFManager.Browsers)
                    {
                        browser.Close();
                        browser.Dispose();
                    }

                    CEFManager.Browsers.Clear();
                }

                CEFManager.Dispose();
                ClearStats();

                RestoreMainMenu();

                DEBUG_STEP = 56;

                ResetWorld();

                DEBUG_STEP = 57;

                ResetPlayer();

                DEBUG_STEP = 58;

                LogManager.RuntimeLog("PlayerDisconnect:ClearAll:Finish");

                if (_serverProcess != null)
                {
                    GTA.UI.Notification.Show("~b~~h~AMP~h~~w~~n~Shutting down server...");
                    _serverProcess.Kill();
                    _serverProcess.Dispose();
                    _serverProcess = null;
                }
            }
            catch (AccessViolationException ex)
            {
                LogManager.LogException(ex, "OnPlayerDisconnect");
            }
        }