public override void StreamOut()
 {
     if (blip != null && blip.Exists())
     {
         blip.Delete();
     }
     if (nickDraw != null)
     {
         nickDraw.destroy();
     }
     if (healthDraw != null)
     {
         healthDraw.destroy();
     }
     if (healthDraw2 != null)
     {
         healthDraw2.destroy();
     }
     if (carHealthDraw != null)
     {
         carHealthDraw.destroy();
     }
     if (carHealthDraw2 != null)
     {
         carHealthDraw2.destroy();
     }
     if (chatDraw != null)
     {
         chatDraw.destroy();
     }
     if (iconDraw != null)
     {
         iconDraw.destroy();
     }
     nickDraw = null;
     if (gameReference != null && gameReference.Exists())
     {
         gameReference.Delete();
     }
     gameReference  = null;
     hasNetworkName = false;
 }
示例#2
0
        private void initAndConnect(string ip, short port, string nickname)
        {
            currentIP = ip;
            GTA.Native.Function.Call("DISABLE_PAUSE_MENU", 1);
            GTA.Native.Function.Call("SET_FILTER_MENU_ON", 1);
            BroadcastingPaused = true;
            playerNames        = new Dictionary <uint, string>();
            playerModels       = new Dictionary <uint, string>();
            isCurrentlyDead    = false;
            actionQueue        = new Queue <Action>();
            instance           = this;

            jsEngine = new JavaScriptEngine();

            CurrentVirtualWorld = 0;

            cameraController = new CameraController(this);

            debugDraw = new ClientTextView(new System.Drawing.PointF(10, 400), "", new GTA.Font("Segoe UI", 24, FontScaling.Pixel), System.Drawing.Color.White);

            pedStreamer     = new PedStreamer(this, 100.0f);
            vehicleStreamer = new VehicleStreamer(this, 100.0f);

            pedController           = new PlayerPedController();
            npcPedController        = new NPCPedController();
            vehicleController       = new VehicleController();
            playerVehicleController = new PlayerVehicleController();
            chatController          = new ChatController(this);
            keyboardHandler         = new KeyboardHandler(this);
            currentState            = ClientState.Initializing;
            Interval = 80;
            //cam = new Camera();
            //cam.Activate();
            currentState = ClientState.Disconnected;
            System.IO.File.WriteAllText("multiv-log.txt", "");
            perFrameRenderer = new PerFrameRenderer(this);


            Player.Character.CurrentRoom = Room.FromString("R_00000000_00000000");

            startTimersandBindEvents();
            try
            {
                if (client != null && client.Connected)
                {
                    client.Close();
                }
                client = new TcpClient();
                IPAddress address = IPAddress.Parse(ip);
                nick = nickname;

                client.Connect(address, port);

                Client.currentData = UpdateDataStruct.Zero;

                serverConnection = new ServerConnection(this);

                World.CurrentDayTime = new TimeSpan(12, 00, 00);
                World.PedDensity     = 0;
                World.CarDensity     = 0;
                // AlternateHook.call(AlternateHook.OtherCommands.TERMINATE_ALL_SCRIPTS_FOR_NETWORK_GAME);
                GTA.Native.Function.Call("CLEAR_AREA", 0.0f, 0.0f, 0.0f, 4000.0f, true);
                currentState = ClientState.Connecting;
            }
            catch
            {
                currentState = ClientState.Disconnected;
                if (client != null && client.Connected)
                {
                    client.Close();
                }
                throw;
            }
        }