Beispiel #1
0
        public void Draw()
        {
            if (!Visible) return;

            SizeF res = UIMenu.GetScreenResolutionMantainRatio();
            int middle = Convert.ToInt32(res.Width/2);

            new Sprite("mpentry", "mp_modenotselected_gradient", new Point(0, 30), new Size(Convert.ToInt32(res.Width), 300),
                0f, Color.FromArgb(230, 255, 255, 255)).Draw();

            new UIResText("mission failed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 148, 27, 46), Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Reason, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw();

            var scaleform = new Scaleform(0);
            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
            if (Game.IsControlJustPressed(0, Control.FrontendAccept))
            {
                Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
            }
        }
Beispiel #2
0
        public static Model LoadObject(int hash)
        {
            int counter = 0;
            var res = UIMenu.GetScreenResolutionMantainRatio();

            var m = new Model(hash);

            if (!m.IsValid || !m.IsInCdImage)
            {
                if (!ObjectDatabase.InvalidHashes.Contains(hash))
                {
                    ObjectDatabase.InvalidHashes.Add(hash);
                    ObjectDatabase.SaveInvalidHashes();
                }
                return null;
            }
            globalCounter++;
            var sc = new Scaleform(0);
            sc.Load("instructional_buttons");
            sc.CallFunction("CLEAR_ALL");
            sc.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            sc.CallFunction("CREATE_CONTAINER");
            sc.CallFunction("SET_DATA_SLOT", 0, "b_50", Translation.Translate("Loading Model"));
            sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            while (!m.IsLoaded && counter < 200)
            {
                m.Request();
                Script.Yield();
                counter++;
                sc.Render2D();
            }
            return m;
        }
Beispiel #3
0
        public Chatbox(Main Main)
            : base(new Point(10, 10), new Size(400, 160), Color.FromArgb(0, 0, 0, 0))
        {
            this.Main = Main;

            int x = 5;
            int y = 5;
            for(int index = 0; index < 10; index++) {
                Items.Add(new UIText("", new Point(x, y), 0.3f));
                y += 15;
            }

            ScaleForm = new Scaleform(0);
            ScaleForm.Load("multiplayer_chat");

            ScaleForm.CallFunction("SET_FOCUS", 2, 2, "ALL");
            ScaleForm.CallFunction("SET_FOCUS", 1, 2, "ALL");
        }
Beispiel #4
0
        public void Draw()
        {
            if (!Visible)
            {
                return;
            }

            Game.DisableAllControlsThisFrame();

            var res = UIMenu.GetScreenResolutionMantainRatio();

            var center = new Point((int)(res.Width / 2), (int)(res.Height / 2));

            new UIResRectangle(new Point(0, 0), new Size((int)res.Width + 1, (int)res.Height + 1), Color.Black).Draw();

            new UIResText(Header,
                          new Point((int)(res.Width / 2), (int)(res.Height / 2) - 200),
                          2f, Error ? Color.FromArgb(224, 50, 50) : Color.FromArgb(240, 200, 80),
                          Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Message,
                          new Point((int)(res.Width / 2), (int)(res.Height / 2) - 80),
                          0.4f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw();

            new UIResRectangle(center - new Size(400, 90), new Size(800, 3), Color.White).Draw();
            new UIResRectangle(center - new Size(400, 55 - (25 * (Message.Split('\n').Length) - 1)),
                               new Size(800, 3), Color.White).Draw();

            var scaleform = new Scaleform("instructional_buttons");

            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call <string>((Hash)0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Accept");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();

            if (Game.IsEnabledControlJustPressed(Control.FrontendAccept))
            {
                OnAccept?.Invoke();
            }
        }
Beispiel #5
0
        private async Task OnScaleformMessageDrawTick()
        {
            await Task.FromResult(0);

            if (died)
            {
                wastedScaleform.CallFunction("SHOW_SHARD_WASTED_MP_MESSAGE", Strings.WASTED, "", -1, true, true);
                wastedScaleform.Render2D();
            }
        }
        private async Task OnScaleformTick()
        {
            await Task.FromResult(0);

            if (organizationUpdateScaleform != null)
            {
                if (--organizationUpdateScaleformTime == 0)
                {
                    organizationUpdateScaleform.Dispose();
                    organizationUpdateScaleform = null;
                }
                else
                {
                    organizationUpdateScaleform.CallFunction("SHOW_SHARD_CENTERED_TOP_MP_MESSAGE");
                    organizationUpdateScaleform.CallFunction("SHARD_SET_TEXT", organizationUpdateScaleformMessage, "", 1);
                    organizationUpdateScaleform.Render2D();
                }
            }
        }
Beispiel #7
0
        // don't call this at high rate unless you want your game to crash
        public void Update(Dictionary <long, SyncPed> opponents)
        {
            _scaleform.CallFunction("SET_DATA_SLOT_EMPTY", 0);
            _scaleform.CallFunction("SET_DATA_SLOT", 0, $"{Main.Latency * 1000:N0}ms", Main.PlayerSettings.Username, 116, 0, "", "", "", 2, "", "", ' ');

            int i = 1;

            foreach (var opponent in opponents)
            {
                var player = opponent.Value;

                _scaleform.CallFunction("SET_DATA_SLOT", i++, $"{player.Latency * 1000:N0}ms", player.Name, 116, 0, "", "", "", 2, "", "", ' ');
            }

            _scaleform.CallFunction("SET_TITLE", "GTA Coop", (Main.Opponents.Count + 1) + " players");
            _scaleform.CallFunction("DISPLAY_VIEW");

            _lastUpdate = GetGameTimer();
        }
Beispiel #8
0
        private async Task OnTick()
        {
            try
            {
                var playerPed = Game.PlayerPed;

                if (!playerPed.IsInVehicle() &&
                    GetPedInVehicleSeat(playerPed.CurrentVehicle.Handle, -1) != playerPed.Handle)
                {
                    return;
                }

                _isNearTimeTrial = false; // Reset boolean before check

                foreach (var timetrial in TimeTrials)
                {
                    if (playerPed.Position.DistanceToSquared(timetrial.Item4) < 10)
                    {
                        Screen.Effects.Start(ScreenEffect.RaceTurbo, 0, true); // Or something else
                        Screen.DisplayHelpTextThisFrame($"Press ~INPUT_CONTEXT~ to Start TimeTrial ({timetrial.Item2})");

                        // TODO Scaleform.Dispose() is performed trashy. Find another way
                        _timetrialMarkerScaleform.CallFunction("SET_MISSION_INFO", $"{timetrial.Item2}", "Time Trial", $"{timetrial.Item3}", "", "", true, 1,
                                                               999, 9999, "");
                        _timetrialMarkerScaleform.Render3D(timetrial.Item4, -playerPed.Rotation, Vector3.One);
                        _isNearTimeTrial = true;

                        if (!Game.IsControlJustReleased(0, Control.Context))
                        {
                            continue;
                        }

                        Screen.Fading.FadeOut(500);
                        playerPed.CurrentVehicle.PositionNoOffset = timetrial.Item5;
                        _hasStarted        = true;
                        _selectedTimeTrial = timetrial.Item1;
                        Screen.Fading.FadeIn(500);
                    }
                }

                if (!_isNearTimeTrial)
                {
                    if (!Screen.Effects.IsActive(ScreenEffect.RaceTurbo))
                    {
                        Screen.Effects.Stop(ScreenEffect.RaceTurbo);
                    }
                    _timetrialMarkerScaleform.Dispose();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            await Task.FromResult(0);
        }
Beispiel #9
0
        public void DrawDeadMessage()
        {
            if (IsDead)
            {
                float x      = Screen.Width / 2;
                float y      = Screen.Height / 2;
                float width  = 350;
                float height = 120;
                //DrawRect(x - (width / 2), y - (height / 2), width, height, 255, 0, 0, 255);

                Scaleform buttons2 = new Scaleform("mp_big_message_freemode");
                //buttons2.CallFunction("CLEAR_ALL");
                //buttons2.CallFunction("UPDATE_MESSAGE", "Hello ~INPUT_RELOAD~");
                buttons2.CallFunction("SHOW_SHARD_WASTED_MP_MESSAGE", "~r~You died!", "Better luck next time");
                //buttons2.CallFunction("ROLL_UP_BACKGROUND");
                buttons2.Render2D();

                /*Rectangle rect = new Rectangle(new PointF(x - (width / 2), y - (height / 2)), new SizeF(width, height), Color.FromArgb(175, 0, 0, 0));
                 * rect.Draw();
                 *
                 * Text text = new Text("You died!", new PointF(x, rect.Position.Y + 15f), 1.0f);
                 * text.Alignment = Alignment.Center;
                 * text.WrapWidth = width;
                 * //Debug.WriteLine("WrapWidth:{0} - {1}", text.Width, (x - (text.Width)));
                 * //text.Position.X = x - (text.WrapWidth / 2);
                 * //text.Caption = "You died!";
                 * text.Draw();
                 *
                 * string btn = GetControlInstructionalButton(0, (int)Control.Reload, true);
                 * Text restartText = new Text(string.Format("Press {0} to restart!", btn), new PointF(x, rect.Position.Y + height - 50f), .5f);
                 * restartText.Alignment = Alignment.Center;
                 * restartText.WrapWidth = width;
                 * restartText.Draw();*/

                Scaleform buttons = new Scaleform("instructional_buttons");
                buttons.CallFunction("CLEAR_ALL");
                buttons.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
                buttons.CallFunction("CREATE_CONTAINER");
                buttons.CallFunction("SET_DATA_SLOT", 0, Function.Call <string>((Hash)0x0499D7B09FC9B407, 2, (int)Control.Reload, 0), "Restart");
                buttons.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", 1);
                buttons.Render2D();

                Screen.Hud.CursorSprite = CursorSprite.MiddleFinger;
                Screen.Hud.ShowCursorThisFrame();

                if (!RanDeathAnimation && PlayerSpawned)
                {
                    Scaleform minimap = new Scaleform("minimap");
                    minimap.Render2D();
                    Debug.WriteLine("DEATH FAIL OUT");
                    RanDeathAnimation = true;
                    Screen.Effects.Start(ScreenEffect.DeathFailOut, 0, true);
                }
            }
        }
Beispiel #10
0
        public void ShowInstructionalButtons()
        {
            if (_sc == null)
            {
                _sc = new Scaleform("instructional_buttons");
            }

            _sc.CallFunction("CLEAR_ALL");
            _sc.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            _sc.CallFunction("CREATE_CONTAINER");


            _sc.CallFunction("SET_DATA_SLOT", 0, Function.Call <string>(Hash._GET_CONTROL_ACTION_NAME, 2, (int)Control.PhoneSelect, 0), "Select");
            _sc.CallFunction("SET_DATA_SLOT", 1, Function.Call <string>(Hash._GET_CONTROL_ACTION_NAME, 2, (int)Control.PhoneCancel, 0), "Back");

            _sc.CallFunction("SET_DATA_SLOT", 2, Function.Call <string>(Hash._GET_CONTROL_ACTION_NAME, 2, (int)Control.FrontendRb, 0), "");
            _sc.CallFunction("SET_DATA_SLOT", 3, Function.Call <string>(Hash._GET_CONTROL_ACTION_NAME, 2, (int)Control.FrontendLb, 0), "Browse");
        }
Beispiel #11
0
        public void ShowInstructionalButtons()
        {
            if (_sc == null)
            {
                _sc = new Scaleform("instructional_buttons");
            }

            _sc.CallFunction("CLEAR_ALL");
            _sc.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            _sc.CallFunction("CREATE_CONTAINER");


            _sc.CallFunction("SET_DATA_SLOT", 0, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneSelect, 0), UIMenu._selectTextLocalized);
            _sc.CallFunction("SET_DATA_SLOT", 1, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneCancel, 0), UIMenu._backTextLocalized);

            _sc.CallFunction("SET_DATA_SLOT", 2, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendRb, 0), "");
            _sc.CallFunction("SET_DATA_SLOT", 3, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendLb, 0), _browseTextLocalized);
        }
        public async void DrawMarker()
        {
            API.Wait(0);
            World.DrawMarker(MarkerType.VerticalCylinder, startPosition, new Vector3(), new Vector3(), new Vector3(2.6f * 2f, 2.6f * 2f, 1f), markerColorOuter);
            World.DrawMarker(MarkerType.ThickChevronUp, startPosition + new Vector3(0f, 0f, 3f), finishPosition, new Vector3(89.999f, 90f, 0f), new Vector3(1f, 1f, 1f), markerColorOuter);
            scaleform.CallFunction("SET_MISSION_INFO", timeTrialName, $"~p~" + timeTrialText, "", "", "", false, "", "", "", parTimeText + FormatParTime());
            scaleform.Render3D(startPosition + new Vector3(0f, 0f, 0.75f), GameplayCamera.Rotation, new Vector3(3f, 3f, 3f));
            API.DrawLightWithRangeAndShadow(startPosition.X, startPosition.Y, startPosition.Z + 1.7f, 36, 120, 255, 10f, 5f, 64f);

            if (API.Vdist2(Game.PlayerPed.Position.X, Game.PlayerPed.Position.Y, Game.PlayerPed.Position.Z, startPosition.X, startPosition.Y, startPosition.Z) < 10f)
            {
                Game.DisableControlThisFrame(1, Control.VehicleHorn);

                if (!isRunning)
                {
                    // Can't start time trial on foot
                    if (!Game.Player.Character.IsInVehicle())
                    {
                        Screen.DisplayHelpTextThisFrame(API.GetLabelText("AMTT_CORONA"));
                    }
                    // Can't start time trial in non-land vehicle
                    else if (IsVehicleBlacklisted())
                    {
                        Screen.DisplayHelpTextThisFrame(API.GetLabelText("AMTT_LAND"));
                    }
                    // Can't start time trial with passengers
                    else if (Game.Player.Character.CurrentVehicle.PassengerCount > 0)
                    {
                        Screen.DisplayHelpTextThisFrame(API.GetLabelText("AMTT_NOPASSN"));
                    }
                    else
                    {
                        Screen.DisplayHelpTextThisFrame(API.GetLabelText("AMTT_PRESS"));

                        if (Game.IsControlJustPressed(0, Control.Context))
                        {
                            Start();
                        }
                    }
                }
            }


            // Surrounding circle


            if (isRunning)
            {
                // Draw finish marker
            }
        }
Beispiel #13
0
        private async Task ShowWastedScreen()
        {
            API.StartScreenEffect(SCREEN_EFFECT, 0, false);
            if (!lockSound)
            {
                Audio.PlaySoundFrontend(SOUND_BED, SOUNDSET);
                lockSound = true;
            }

            API.ShakeGameplayCam(SHAKE_EFFECT, 1.0f);

            wastedScaleform = new Scaleform("MP_BIG_MESSAGE_FREEMODE");
            while (!wastedScaleform.IsLoaded)
            {
                await BaseScript.Delay(0);
            }

            if (message != null)
            {
                wastedScaleform.CallFunction("SHOW_SHARD_WASTED_MP_MESSAGE", "Wasted", message);
            }
            else
            {
                wastedScaleform.CallFunction("SHOW_SHARD_WASTED_MP_MESSAGE", "Wasted");
            }

            await BaseScript.Delay(500);

            Audio.PlaySoundFrontend(SOUND_TEXT, SOUNDSET);
            if (API.IsEntityDead(playerPed.Handle))
            {
                API.DrawScaleformMovieFullscreen(wastedScaleform.Handle, 255, 255, 255, 255, 0);
                await BaseScript.Delay(0);
            }

            API.StopScreenEffect(SCREEN_EFFECT);
            lockSound = false;
        }
Beispiel #14
0
        public void ShowInstructionalButtons()
        {
            if (_sc == null)
            {
                _sc = new Scaleform(0);
                _sc.Load("instructional_buttons");
            }

            _sc.CallFunction("CLEAR_ALL");
            _sc.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            _sc.CallFunction("CREATE_CONTAINER");


            _sc.CallFunction("SET_DATA_SLOT", 0, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.CellphoneSelect, 0), "Select");
            _sc.CallFunction("SET_DATA_SLOT", 1, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.CellphoneCancel, 0), "Back");

            _sc.CallFunction("SET_DATA_SLOT", 2, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.FrontendRb, 0), "");
            _sc.CallFunction("SET_DATA_SLOT", 3, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.FrontendLb, 0), "Browse");
        }
Beispiel #15
0
 public void AddMessage(string sender, string msg)
 {
     if (string.IsNullOrEmpty(sender))
     {
         _mainScaleform.CallFunction("ADD_MESSAGE", "", SanitizeString(msg));
         if (Main.PlayerSettings.ChatLog)
         {
             System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + msg + "\n");
         }
     }
     else
     {
         _mainScaleform.CallFunction("ADD_MESSAGE", SanitizeString(sender) + ":", SanitizeString(msg));
         if (Main.PlayerSettings.ChatLog)
         {
             System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + sender + ": " + msg + "\n");
         }
     }
 }
Beispiel #16
0
 /*
  * UUpdate the first person radio to display the song name
  */
 private void DisplaySpotifyTrackOnRadio(string artist, string track)
 {
     try
     {
         // Call function.
         DashboardScaleform.CallFunction("SET_RADIO",
                                         "", "Spotify Radio",
                                         artist, track);
     }
     catch (Exception exception)
     {
         Logger.Log("Failed to display trackname on Radio dashboard: " + exception.ToString());
     }
 }
        public void Draw()
        {
            if (!Visible)
            {
                return;
            }

            SizeF res    = UIMenu.GetScreenResolutionMantainRatio();
            int   middle = Convert.ToInt32(res.Width / 2);

            new Sprite("mpentry", "mp_modenotselected_gradient", new Point(0, 30), new Size(Convert.ToInt32(res.Width), 300),
                       0f, Color.FromArgb(230, 255, 255, 255)).Draw();

            new ResText("mission failed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 148, 27, 46), Common.EFont.Pricedown, ResText.Alignment.Centered).Draw();

            new ResText(Reason, new Point(middle, 230), 0.5f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Centered).Draw();

            var scaleform = new Scaleform(0);

            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, NativeFunction.CallByHash(0x0499D7B09FC9B407, typeof(string), 2, (int)GameControl.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();

            NativeFunction.CallByName <uint>("DISABLE_ALL_CONTROL_ACTIONS", 0);
            NativeFunction.CallByName <uint>("ENABLE_CONTROL_ACTION", 0, (int)GameControl.FrontendAccept);

            if (Game.IsControlJustPressed(0, GameControl.FrontendAccept))
            {
                HasPressedContinue = true;
                NativeFunction.CallByHash <uint>(0xB4EDDC19532BFB85);
            }
        }
        private void DrawInstructionalButtonsScaleform()
        {
            var instructButts = new Scaleform();

            instructButts.Load("instructional_buttons");
            instructButts.CallFunction("CLEAR_ALL");
            instructButts.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            instructButts.CallFunction("CREATE_CONTAINER");
            instructButts.CallFunction("SET_DATA_SLOT", 0, Util.GetControlButtonId(GameControl.Attack), "Place Waypoint");
            instructButts.CallFunction("SET_DATA_SLOT", 1, Util.GetControlButtonId(GameControl.Attack), "Waypoint Properties");
            instructButts.CallFunction("SET_DATA_SLOT", 2, Util.GetControlButtonId(GameControl.CreatorDelete), "Remove Waypoint");
            instructButts.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
        }
Beispiel #19
0
        private void DrawInstructionalButtonsScaleform()
        {
            var instructButts = new Scaleform();

            instructButts.Load("instructional_buttons");
            instructButts.CallFunction("CLEAR_ALL");
            instructButts.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            instructButts.CallFunction("CREATE_CONTAINER");
            instructButts.CallFunction("SET_DATA_SLOT", 0, Util.GetControlButtonId(GameControl.CellphoneRight), "");
            instructButts.CallFunction("SET_DATA_SLOT", 1, Util.GetControlButtonId(GameControl.CellphoneLeft), "Navigate");

            instructButts.CallFunction("SET_DATA_SLOT", 2, Util.GetControlButtonId(GameControl.FrontendRb), "");
            instructButts.CallFunction("SET_DATA_SLOT", 3, Util.GetControlButtonId(GameControl.FrontendLb), "Jump to Markers");


            instructButts.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
        }
Beispiel #20
0
        public static void AtmDisplayCashOptions(Scaleform atmScaleform)
        {
            atmScaleform.CallFunction("SET_DATA_SLOT", 0);
            BeginTextCommand("MPATM_WITMT");

            int balance = 10000;

            atmScaleform.CallFunction("SET_DATA_SLOT", 1);

            RAGE.Game.Graphics.BeginTextCommandScaleformString("ESDOLLA");
            RAGE.Game.Ui.AddTextComponentFormattedInteger(balance, true);
            RAGE.Game.Graphics.EndTextCommandScaleformString();
            Graphics.PopScaleformMovieFunctionVoid();

            atmScaleform.CallFunction("SET_DATA_SLOT", 4);
            BeginTextCommand("MPATM_BACK");

            atmScaleform.CallFunction("SET_DATA_SLOT", 5);
            RAGE.Game.Graphics.BeginTextCommandScaleformString("ESDOLLA");
            RAGE.Game.Ui.AddTextComponentFormattedInteger(balance, true);
            Graphics.PopScaleformMovieFunctionVoid();

            atmScaleform.CallFunction("DISPLAY_CASH_OPTIONS", 0);
        }
 public static async Task AddVehicle(VehicleCard vehicle, Scaleform scaleformHandle, int gridIndex)
 {
     if (vehicle.TextureDict != "" && vehicle.TextureName != "" && !HasStreamedTextureDictLoaded(vehicle.TextureDict))
     {
         Debug.WriteLine("Loading: " + vehicle.TextureDict + " : " + vehicle.TextureName);
         RequestStreamedTextureDict(vehicle.TextureDict, false);
         while (!HasStreamedTextureDictLoaded(vehicle.TextureDict))
         {
             await BaseScript.Delay(0);
         }
         Debug.Write("Done!");
     }
     scaleformHandle.CallFunction("SET_GRID_ITEM", gridIndex, GetVehicleName(vehicle.ModelName), vehicle.TextureDict,
                                  vehicle.TextureName, 0, 0, -1, false, 0.0, 0.0, false, 0);
     Debug.WriteLine(GetVehicleName(vehicle.ModelName) + "has been loaded and added.");
 }
        public static async Task DrawCenterBar(string message, string subMessage, int colId = 5, int duration = 1000 * 10)
        {
            var scaleform = new Scaleform("MP_BIG_MESSAGE_FREEMODE");

            while (!scaleform.IsLoaded)
            {
                await Delay(100);
            }
            var now = API.GetGameTimer();

            scaleform.CallFunction("SHOW_SHARD_WASTED_MP_MESSAGE", message, subMessage, colId);
            while (API.GetGameTimer() - now <= duration)
            {
                scaleform.Render2D();
                await Delay(0);
            }
            scaleform.Dispose();
        }
        private void RenderIntructionalButtons()
        {
            _instructionalButtons.CallFunction("CLEAR_ALL");
            _instructionalButtons.CallFunction("TOGGLE_MOUSE_BUTTONS", false);
            string str = Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, 24, 0);

            _instructionalButtons.CallFunction("SET_DATA_SLOT", 4, str, "Select Position");
            str = Function.Call <string>(Hash._0x0499D7B09FC9B407, 3, 17, 0);
            _instructionalButtons.CallFunction("SET_DATA_SLOT", 3, str, "Increase Duration");
            str = Function.Call <string>(Hash._0x0499D7B09FC9B407, 1, 16, 0);
            _instructionalButtons.CallFunction("SET_DATA_SLOT", 2, str, "Decrease Duration");
            str = Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, 25, 0);
            _instructionalButtons.CallFunction("SET_DATA_SLOT", 1, str, "Exit");
            string[] args = new string[] {
                Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, 32, 0),
                Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, 34, 0),
                Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, 33, 0),
                Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, 35, 0)
            };
            _instructionalButtons.CallFunction("SET_DATA_SLOT", 0, args[3], args[2], args[1], args[0], "Move");
            _instructionalButtons.CallFunction("SET_BACKGROUND_COLOUR", 0, 0, 0, 80);
            _instructionalButtons.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", 0);
            _instructionalButtons.Render2D();
        }
Beispiel #24
0
        private async Task OnIsDead()
        {
            await Task.FromResult(0);

            if (_isDead)
            {
                _deadMessage.CallFunction("SHOW_SHARD_WASTED_MP_MESSAGE", "~r~Wasted", "Press ~INPUT_CONTEXT~ to respawn", -1, true, true);
                _deadMessage.Render2D();

                if (Game.IsControlJustReleased(0, Control.Context))
                {
                    var playerPed = Game.PlayerPed;
                    SetEntityVisible(playerPed.Handle, true, true);
                    FreezeEntityPosition(playerPed.Handle, false);
                    Screen.Fading.FadeOut(500);
                    playerPed.Position = PlayerHousePosition;
                    playerPed.Resurrect();
                    Screen.Effects.Stop(ScreenEffect.DeathFailMpIn);
                    _isDead = false;
                    _deadMessage.Dispose();
                }
            }
        }
Beispiel #25
0
        public void OnActivate()
        {
            camera = new Camera(true);
            camera.SetRotationYaw(Game.LocalPlayer.Character.CurrentVehicle.Heading);
            camera.AttachToEntity(Game.LocalPlayer.Character.CurrentVehicle, HeliCamOffsetsDictionary.Instance[Game.LocalPlayer.Character.CurrentVehicle.Model], true);

            hudScaleform = new Scaleform();
            hudScaleform.Load("heli_cam");

            NativeFunction.Natives.RequestStreamedTextureDict("helicopterhud", true);

            hudScaleform.CallFunction("SET_CAM_LOGO", lsCountyLogoEnabled);

            backgroundSound    = new Sound();
            turnSound          = new Sound();
            zoomSound          = new Sound();
            searchLoopSound    = new Sound();
            searchSuccessSound = new Sound();

            Sound.RequestAmbientAudioBank("SCRIPT\\POLICE_CHOPPER_CAM");

            NativeFunction.Natives.SetNoiseoveride(true);
            NativeFunction.Natives.SetNoisinessoveride(0.15f);
        }
Beispiel #26
0
        public static void AtmDisplayBalance(Scaleform atmScaleform, int balance = 10000)
        {
            atmScaleform.CallFunction("CLEAR_ALL");
            atmScaleform.CallFunction("SET_DATA_SLOT", 0);

            //Comma seperate cash
            RAGE.Game.Graphics.BeginTextCommandScaleformString("MPATM_XDOL");
            RAGE.Game.Ui.AddTextComponentFormattedInteger(balance, true);
            RAGE.Game.Graphics.EndTextCommandScaleformString();
            Graphics.PopScaleformMovieFunctionVoid();

            atmScaleform.CallFunction("SET_DATA_SLOT", 1);
            BeginTextCommand("MO_YES");

            atmScaleform.CallFunction("SET_DATA_SLOT", 2);
            BeginTextCommand("MO_NO");

            atmScaleform.CallFunction("DISPLAY_MESSAGE");
            atmScaleform.CallFunction("DISPLAY_BALANCE");
            Graphics.PopScaleformMovieFunctionVoid();
        }
Beispiel #27
0
		static private async void UpdateTasti()
		{
			if (!Scaleform)
			{
				Buttons = new Scaleform("instructional_buttons");
				while (!HasScaleformMovieLoaded(Buttons.Handle)) await BaseScript.Delay(0);

				Buttons.CallFunction("CLEAR_ALL");
				Buttons.CallFunction("TOGGLE_MOUSE_BUTTONS", false);


				Buttons.CallFunction("CLEAR_ALL");

				Buttons.CallFunction("SET_DATA_SLOT", 0, GetControlInstructionalButton(2, 236, 1), "Change Visual");
				Buttons.CallFunction("SET_DATA_SLOT", 1, GetControlInstructionalButton(2, 204, 1), "Get off the Wheel");

				Buttons.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
				Scaleform = true;
			}
			if (Scaleform)
				Buttons.Render2D();
		}
Beispiel #28
0
        public static void Init()
        {
            scaleform = new Scaleform("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL", new object[0]);
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);

            // Movement/Rotation
            scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.MoveLeftRight, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 1, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.MoveUpDown, 0), "Move");
            scaleform.CallFunction("SET_DATA_SLOT", 2, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.LookLeftRight, 0), "Look");
            scaleform.CallFunction("SET_DATA_SLOT", 3, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.Pickup, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 4, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.Cover, 0), "Roll");

            // Misc
            scaleform.CallFunction("SET_DATA_SLOT", 5, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendDown, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 6, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendUp, 0), "FOV");
            scaleform.CallFunction("SET_DATA_SLOT", 7, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendRight, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 8, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendLeft, 0), $"Filter: [{Config.Filters[FilterIndex]}]");
            scaleform.CallFunction("SET_DATA_SLOT", 9, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.Reload, 0), $"Reset");
            scaleform.CallFunction("SET_DATA_SLOT", 10, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.Detonate, 0), "Slow Motion");
            scaleform.CallFunction("SET_DATA_SLOT", 11, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.VehicleExit, 0), "Freeze");
            scaleform.CallFunction("SET_DATA_SLOT", 11, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendAccept, 0), "Control Lock");
            if (!Attached)
            {
                scaleform.CallFunction("SET_DATA_SLOT", 12, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.CursorAccept, 0), "Attach");
            }
            else
            {
                scaleform.CallFunction("SET_DATA_SLOT", 12, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.CursorCancel, 0), "Detach");
            }
            // HUD Toggle
            scaleform.CallFunction("SET_DATA_SLOT", 13, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, 74, 0), "Toggle HUD");
        }
Beispiel #29
0
        static int FilterIndex = 0; // 0 == None

        public static void Tick()
        {
            // Check if the camera is enabled or not
            if (FCamera == null || !FCamera.Equals(World.RenderingCamera) || Game.IsPaused)
            {
                return;
            }

            Function.Call(Hash._DISABLE_FIRST_PERSON_CAM_THIS_FRAME);
            if (!Lock)
            {
                Game.DisableAllControlsThisFrame();
            }

            if (HUD)
            {
                scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
                scaleform.Render2D();
            }

            Vector3 CamCoord = FCamera.Position;
            Vector3 NewPos   = ProcessNewPos(CamCoord);

            if (!Function.Call <bool>(Hash.IS_RADAR_HIDDEN))
            {
                Function.Call(Hash.DISPLAY_RADAR, false);
            }

            FCamera.Position = NewPos;
            FCamera.Rotation = new Vector3(OffsetRotX, OffsetRotY, OffsetRotZ);
            Function.Call(Hash._SET_FOCUS_AREA, NewPos.X, NewPos.Y, NewPos.Z, 0.0f, 0.0f, 0.0f);

            #region Misc Controls
            if (!Lock)
            {
                // Misc controls
                if (Attached && Game.IsControlJustPressed(Control.CursorCancel))
                {
                    // Attachment cleanup
                    FCamera.Detach();
                    AttachedEntity = null;
                    Attached       = false;
                    scaleform.CallFunction("SET_DATA_SLOT", 12, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.CursorAccept, 0), "Attach");
                    scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
                }
                else if (Game.IsControlJustPressed(Control.CursorAccept))
                {
                    Entity AttachEnt = GetEntityInFrontOfCam(FCamera);
                    if (AttachEnt != null)
                    {
                        AttachedEntity = AttachEnt;
                        OffsetCoords   = Function.Call <Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, AttachedEntity, FCamera.Position.X, FCamera.Position.Y, FCamera.Position.Z);
                        FCamera.AttachTo(AttachedEntity, new Vector3(OffsetCoords.X, OffsetCoords.Y, OffsetCoords.Z));
                        Attached = true;
                        scaleform.CallFunction("SET_DATA_SLOT", 12, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.CursorCancel, 0), "Detach");
                        scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
                    }
                }

                if (Game.IsControlJustPressed(Control.VehicleHeadlight))
                {
                    HUD = !HUD;
                }
                if (Game.IsControlPressed(Control.FrontendUp))
                {
                    FCamera.FieldOfView -= 1;
                }
                else if (Game.IsControlPressed(Control.FrontendDown))
                {
                    FCamera.FieldOfView += 1;
                }
                if (Game.IsControlJustPressed(Control.FrontendLeft))
                {
                    if (FilterIndex == 0)
                    {
                        FilterIndex = Config.Filters.Count - 1;
                    }
                    else
                    {
                        FilterIndex--;
                    }
                    Function.Call(Hash.SET_TIMECYCLE_MODIFIER, Config.Filters[FilterIndex]);
                    Function.Call(Hash.SET_TIMECYCLE_MODIFIER_STRENGTH, Config.FilterIntensity);
                    scaleform.CallFunction("SET_DATA_SLOT", 8, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendLeft, 0), $"Filter: [{Config.Filters[FilterIndex]}]");
                    scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
                }
                else if (Game.IsControlJustPressed(Control.FrontendRight))
                {
                    if (FilterIndex == Config.Filters.Count - 1)
                    {
                        FilterIndex = 0;
                    }
                    else
                    {
                        FilterIndex++;
                    }
                    Function.Call(Hash.SET_TIMECYCLE_MODIFIER, Config.Filters[FilterIndex]);
                    Function.Call(Hash.SET_TIMECYCLE_MODIFIER_STRENGTH, Config.FilterIntensity);
                    scaleform.CallFunction("SET_DATA_SLOT", 8, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendLeft, 0), $"Filter: [{Config.Filters[FilterIndex]}]");
                    scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
                }
                else if (Game.IsControlJustPressed(Control.Reload))
                {
                    Disable();
                    Enable();
                    FilterIndex = 0;
                    Function.Call(Hash.SET_TIMECYCLE_MODIFIER, "None");
                    scaleform.CallFunction("SET_DATA_SLOT", 8, Function.Call <string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTON, 2, Control.FrontendLeft, 0), $"Filter: [{Config.Filters[FilterIndex]}]");
                    scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
                }
                if (Game.IsControlJustPressed(Control.Detonate))
                {
                    if (!SlowMode)
                    {
                        Game.TimeScale /= Config.SlowMotionMultiplier;
                    }
                    else
                    {
                        Game.TimeScale = 1;
                    }
                    SlowMode = !SlowMode;
                }
                if (Game.IsControlJustPressed(Control.VehicleExit))
                {
                    SlowMode = !SlowMode;
                    Frozen   = !Frozen;
                    Game.Pause(Frozen);
                }
            }
            if (Game.IsControlJustPressed(Control.FrontendAccept))
            {
                Lock = !Lock;

                if (Lock)
                {
                    Game.Pause(false);
                    HUD = false;
                }
                else
                {
                    HUD = true;
                }
            }
            #endregion
        }
        public async Task OnTick()
        {
            await Task.FromResult(0);

            int slot = 0;

            if (inSubMenu)
            {
                phoneScaleform.CallFunction("SET_DATA_SLOT", 2, slot++, -1, Strings.PHONE_APP_PLAYERLIST_SEND);
            }
            else
            {
                Player[] players = new PlayerList().Where(player => player != Game.Player).ToArray();
                playersInGame = players.Length == 0 ? false : true;
                if (!playersInGame)
                {
                    phoneScaleform.CallFunction("SET_DATA_SLOT", 13, slot++, -1, Strings.PHONE_APP_PLAYERLIST_NO_PLAYERS);
                }
                else
                {
                    foreach (Player player in players)
                    {
                        phoneScaleform.CallFunction("SET_DATA_SLOT", 13, slot++, -1, player.Name);
                    }
                }
            }
            phoneScaleform.CallFunction("SET_HEADER", inSubMenu ? selectedPlayer.Name : Strings.PHONE_APP_PLAYERLIST);
            phoneScaleform.CallFunction("DISPLAY_VIEW", inSubMenu ? 2 : 13, selected);

            phoneScaleform.CallFunction("SET_SOFT_KEYS", (int)PhoneSelectSlot.SLOT_RIGHT, true, (int)PhoneSelectIcon.ICON_BACK);
            phoneScaleform.CallFunction("SET_SOFT_KEYS", (int)PhoneSelectSlot.SLOT_LEFT, true,
                                        slot > 0 ? (int)PhoneSelectIcon.ICON_SELECT : (int)PhoneSelectIcon.ICON_BLANK);

            bool pressed = false;

            if (Game.IsControlJustPressed(0, Control.PhoneUp) && slot > 0)
            {
                if (--selected < 0)
                {
                    selected = slot - 1;
                }
                pressed = true;
            }
            else if (Game.IsControlJustPressed(0, Control.PhoneDown) && slot > 0)
            {
                if (++selected > slot - 1)
                {
                    selected = 0;
                }
                pressed = true;
            }
            else if (Game.IsControlJustPressed(0, Control.PhoneSelect) && slot > 0)
            {
                if (playersInGame)
                {
                    if (!inSubMenu)
                    {
                        inSubMenu = true;
                        int selectedTemp = selected;
                        if (selected == Game.Player.Handle)
                        {
                            selectedTemp++;
                        }
                        selectedPlayer = new Player(selectedTemp);
                    }
                    else
                    {
                        string message = await Game.GetUserInput(60);

                        if (message != null)
                        {
                            message = message.Trim();
                            if (message.Length == 0)
                            {
                                Screen.ShowNotification(Strings.PHONE_APP_PLAYERLIST_SEND_NO_MSG);
                            }
                            else
                            {
                                BaseScript.TriggerServerEvent(Events.MESSAGE_FORWARD_PLAYER, selectedPlayer.ServerId, message);
                                Screen.ShowNotification(Strings.PHONE_APP_PLAYERLIST_SENT);
                            }
                        }
                    }
                }
                selected = 0;
                pressed  = true;
            }
            else if (Game.IsControlJustPressed(0, Control.PhoneCancel))
            {
                if (!inSubMenu)
                {
                    PhoneAppStarter.MainApp();
                }
                else
                {
                    Audio.ReleaseSound(Audio.PlaySoundFrontend("Hang_Up", "Phone_SoundSet_Michael"));
                    inSubMenu = false;
                }
            }

            if (pressed)
            {
                Audio.ReleaseSound(Audio.PlaySoundFrontend("Menu_Navigate", "Phone_SoundSet_Default"));
            }
        }
 public void Init(Scaleform phoneScaleform)
 {
     this.phoneScaleform = phoneScaleform;
     phoneScaleform.CallFunction("SET_DATA_SLOT_EMPTY", 13);
 }
Beispiel #32
0
        public void ConnectToServer(string ip, int port = 0, bool passProtected = false, string myPass = "")
        {
            try
            {
                if (IsOnServer())
                {
                    Client.Disconnect("Switching servers");
                    Wait(1000);
                }

                JavascriptHook.StopAllScripts();
                JavascriptHook.TextElements.Clear();

                ShowLoadingPrompt("Loading");
                Function.Call(Hash.DISPLAY_RADAR, false);

                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

                if (!_minimapSet)
                {
                    var scal = new Scaleform("minimap");
                    scal.CallFunction("MULTIPLAYER_IS_ACTIVE", true, false);

                    Function.Call(Hash._SET_RADAR_BIGMAP_ENABLED, true, false);
                    Function.Call(Hash._SET_RADAR_BIGMAP_ENABLED, false, false);

                    _minimapSet = true;
                }

                Chat.Init();

                Client.Shutdown("Shutdown");
                Wait(1000);
                var cport = GetOpenUdpPort();
                if (cport == 0)
                {
                    Util.Util.SafeNotify("No available UDP port was found.");
                    return;
                }
                _config.Port = cport;
                Client       = new NetClient(_config);
                Client.Start();

                lock (Npcs) Npcs = new Dictionary <string, SyncPed>();
                lock (_tickNatives) _tickNatives = new Dictionary <string, NativeData>();

                var msg = Client.CreateMessage();

                var obj = new ConnectionRequest();
                obj.SocialClubName = string.IsNullOrWhiteSpace(Game.Player.Name) ? GetMacAddress() : Game.Player.Name; // To be used as identifiers in server files
                obj.DisplayName    = string.IsNullOrWhiteSpace(PlayerSettings.DisplayName) ? obj.SocialClubName : PlayerSettings.DisplayName.Trim();
                obj.ScriptVersion  = CurrentVersion.ToString();
                obj.CEF            = !CefUtil.DISABLE_CEF;
                obj.CEFDevtool     = EnableDevTool;
                obj.GameVersion    = (byte)Game.Version;
                obj.MediaStream    = EnableMediaStream;

                if (passProtected)
                {
                    if (!string.IsNullOrWhiteSpace(myPass))
                    {
                        obj.Password = myPass;
                    }
                    else
                    {
                        MainMenu.TemporarilyHidden = true;
                        obj.Password = Game.GetUserInput("");
                        MainMenu.TemporarilyHidden = false;
                    }
                }

                var bin = SerializeBinary(obj);

                msg.Write((byte)PacketType.ConnectionRequest);
                msg.Write(bin.Length);
                msg.Write(bin);

                try
                {
                    Client.Connect(ip, port == 0 ? Port : port, msg);
                }
                catch (NetException ex)
                {
                    GTA.UI.Notification.Show("~b~~h~AMP~h~~w~~n~" + ex.Message);
                    OnLocalDisconnect();
                    return;
                }

                var pos = Game.Player.Character.Position;
                Function.Call(Hash.CLEAR_AREA_OF_PEDS, pos.X, pos.Y, pos.Z, 100f, 0);
                Function.Call(Hash.CLEAR_AREA_OF_VEHICLES, pos.X, pos.Y, pos.Z, 100f, 0);

                Function.Call(Hash.SET_GARBAGE_TRUCKS, 0);
                Function.Call(Hash.SET_RANDOM_BOATS, 0);
                Function.Call(Hash.SET_RANDOM_TRAINS, 0);

                Function.Call(Hash.CLEAR_ALL_BROKEN_GLASS);

                DisableSlowMo();

                Game.TimeScale = 1;

                ResetPlayer();

                _currentServerIp   = ip;
                _currentServerPort = port == 0 ? Port : port;
            }
            catch (AccessViolationException ex)
            {
                LogManager.LogException(ex, "OnPlayerDisconnect");
            }
        }
Beispiel #33
0
        public void Draw()
        {
            if (!Visible) return;

            SizeF res = UIMenu.GetScreenResolutionMantainRatio();
            int middle = Convert.ToInt32(res.Width/2);

            new Sprite("mpentry", "mp_modenotselected_gradient", new Point(0, 10), new Size(Convert.ToInt32(res.Width), 450 + (_items.Count*40)),
                0f, Color.FromArgb(200, 255, 255, 255)).Draw();

            new UIResText("mission passed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Title, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw();

            new UIResRectangle(new Point(middle - 300, 290), new Size(600, 2), Color.White).Draw();

            for (int i = 0; i < _items.Count; i++)
            {
                new UIResText(_items[i].Item1, new Point(middle - 230, 300 + (40*i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Left).Draw();
                new UIResText(_items[i].Item2, new Point(_items[i].Item3 == TickboxState.None ? middle + 265 : middle + 230, 300 + (40*i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                if (_items[i].Item3 == TickboxState.None) continue;
                string spriteName = "shop_box_blank";
                switch (_items[i].Item3)
                {
                    case TickboxState.Tick:
                        spriteName = "shop_box_tick";
                        break;
                    case TickboxState.Cross:
                        spriteName = "shop_box_cross";
                        break;
                }
                new Sprite("commonmenu", spriteName, new Point(middle + 230, 290 + (40*i)), new Size(48, 48)).Draw();
            }
            new UIResRectangle(new Point(middle - 300, 300 + (40 * _items.Count)), new Size(600, 2), Color.White).Draw();

            new UIResText("Completion", new Point(middle - 150, 320 + (40 * _items.Count)), 0.4f).Draw();
            new UIResText(_completionRate + "%", new Point(middle + 150, 320 + (40 * _items.Count)), 0.4f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();

            string medalSprite = "bronzemedal";
            switch (_medal)
            {
                case Medal.Silver:
                    medalSprite = "silvermedal";
                    break;
                case Medal.Gold:
                    medalSprite = "goldmedal";
                    break;
            }

            new Sprite("mpmissionend", medalSprite, new Point(middle + 150, 320 + (40 * _items.Count)), new Size(32, 32)).Draw();

            var scaleform = new Scaleform(0);
            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
            if (Game.IsControlJustPressed(0, Control.FrontendAccept))
            {
                Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                ContinueHit();
            }
        }
	    public void OnTick(object sender, EventArgs e)
	    {
		    if (DateTime.Now.Second != _lasttime.Second)
		    {
			    _seconds++;
			    _lasttime = DateTime.Now;
			    if (_isInRace && _countdown > 0)
			    {
				    var screen = UIMenu.GetScreenResolutionMantainRatio();
				    var w = Convert.ToInt32(screen.Width/2);
				    _countdown--;
					if(_countdown > 3) return;
				    _fadeoutSprite = new Sprite("mpinventory", "in_world_circle", new Point(w - 125, 200), new Size(250, 250), 0f, _countdown == 0 ? Color.FromArgb(49, 235, 126) : Color.FromArgb(241, 247, 57));
					Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
					Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
					if (_countdown == 0)
				    {
					    _participants.ForEach(car => car.FreezePosition = false);
					    _missionStart = _seconds;
				    }
			    }
				else if (_isInRace && _countdown == 0)
				{
					_countdown = -1;
				}
		    }

			GUI.MainMenu.ProcessControl();
			GUI.MainMenu.ProcessMouse();
			GUI.MainMenu.Draw();

			_quitMenu.ProcessControl();
			_quitMenu.ProcessMouse();
			_quitMenu.Draw();

			GUI.DrawSettings(_previewRace, _previewVehicle);

			_passed?.Draw();

			if (_countdown > -1 && _countdown <= 3)
		    {
				var screen = UIMenu.GetScreenResolutionMantainRatio();
				var w = Convert.ToInt32(screen.Width / 2);
				new UIResText(_countdown == 0 ? "GO" : _countdown.ToString(), new Point(w, 260), 2f, Color.White, Font.Pricedown, UIResText.Alignment.Centered).Draw();
		    }

		    if (_fadeoutSprite?.Color.A > 5)
		    {
			    _fadeoutSprite.Color = Color.FromArgb(_fadeoutSprite.Color.A - 5, _fadeoutSprite.Color.R, _fadeoutSprite.Color.G,
				    _fadeoutSprite.Color.B);
				_fadeoutSprite.Draw();
		    }


            /* COURIER */
            GUICourier.Init();
            GUICourier.MainMenu.ProcessControl();
            GUICourier.MainMenu.ProcessMouse();
            var safe = UIMenu.GetSafezoneBounds();
            var res = UIMenu.GetScreenResolutionMantainRatio();

            new UIResRectangle(new Point(((int)res.Width-200), 0), new Size(200, 400), Color.FromArgb(200,0,0,0)).Draw();

            GUICourier.MainMenu.Draw();

            if (activeDeliveries.Count == 0 || (_seconds - lastSpawn > 60 && activeDeliveries.Count < 3))
            {
                Delivery d = Delivery.CreateDelivery();
                d.activate();
                activeDeliveries.Add(d);
                lastSpawn = _seconds;
                UI.Notify("New delivery available");
            }

            int pick = 0,drop = 0;
            Vector3 me = Game.Player.Character.Position;
            String posStr = String.Format("{0} {1} {2}", me.X.ToString("F02"), me.Y.ToString("F02"), me.Z.ToString("F02"));


            new UIResText("Pickup", new Point(Convert.ToInt32(res.Width) - 190, 20), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left) { DropShadow = true }.Draw();
            new UIResText("Dropoff", new Point(Convert.ToInt32(res.Width) - 190, 210), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left) { DropShadow = true }.Draw();
            foreach (Delivery d in activeDeliveries.GetRange(0,activeDeliveries.Count)) {
                d.tick();
                if (d.isActive == false)
                {
                    activeDeliveries.Remove(d);
                    continue;
                }

 
                if (d._isStarted)
                {
                    float dist = me.DistanceTo(d.end);
                    String posStr2 = String.Format("{0} {1} {2}", d.end.X.ToString("F02"), d.end.Y.ToString("F02"), d.end.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.end_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (drop + 2) + 210), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

                    drop++;
                }
                else {
                    float dist = me.DistanceTo(d.start);
                    String posStr2 = String.Format("{0} {1} {2}", d.start.X.ToString("F02"), d.start.Y.ToString("F02"), d.start.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.start_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (pick + 2)), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

                    pick++;
                }
                //new UIResText("WORLD", new Point(Convert.ToInt32(res.Width) - 190, 40), .35f, Color.DodgerBlue, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

            }
            /* COURIER */

            if (!_isInRace)
		    {
				if(GUI.IsInMenu) return;
			    foreach (var race in _races)
			    {
				    World.DrawMarker(MarkerType.VerticalCylinder, race.Trigger, new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(5f, 5f, 1f), Color.FromArgb(200, 255, 255, 255));
					if(!Game.Player.Character.IsInRangeOf(race.Trigger, 50f)) continue;
				    var tmpSF = new Scaleform(0);
				    tmpSF.Load("PLAYER_NAME_01");
					tmpSF.CallFunction("SET_PLAYER_NAME", race.Name);
				    
					tmpSF.Render3D(race.Trigger + new Vector3(0f, 0f, 2f), new Vector3(0f, 0f, _oldAngle), new Vector3(12, 6, 2));

					var tmpT = new Scaleform(0);
					tmpT.Load("PLAYER_NAME_02");
					tmpT.CallFunction("SET_PLAYER_NAME", "Community Race");

					tmpT.Render3D(race.Trigger + new Vector3(0f, 0f, 1.5f), new Vector3(0f, 0f, _oldAngle), new Vector3(6, 3, 1));

					_oldAngle += 2f;

                    if (!Game.Player.Character.IsInRangeOf(race.Trigger, 5f)) continue;

                    Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
                    Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, "Press ~INPUT_CONTEXT~ to participate in this Community Race.");
                    Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);

                    if (Game.IsControlJustPressed(0, GTA.Control.Context))
				    {
					    Game.Player.CanControlCharacter = false;
					    Game.Player.Character.Position = race.Trigger + new Vector3(4f, 0f, -1f);
					    _previewRace = race;
						BuildMenu(race);
					    GUI.MainMenu.Visible = true;
					    GUI.IsInMenu = true;
					    break;
				    }
			    }
				
		    }
		    else if(_isInRace)
		    {
				if(!_raceSettings["Wanted"])
					Function.Call(Hash.SET_MAX_WANTED_LEVEL, 0);
				//if(Game.Player.Character.IsInVehicle())
				Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.VehicleExit);
			    if ((Game.IsControlJustPressed(0, GTA.Control.VehicleExit) && Game.Player.Character.IsInVehicle()) || (!Game.Player.Character.IsInVehicle() && !Game.Player.Character.IsGettingIntoAVehicle && Game.IsControlJustPressed(0, GTA.Control.Enter)))
			    {
					_quitMenu.RefreshIndex();
				    _quitMenu.Visible = !_quitMenu.Visible;
			    }
				
			    if (!Convert.ToBoolean(_raceSettings["Traffic"]))
			    {
				    Vehicle[] close = World.GetNearbyVehicles(Game.Player.Character, 10000f);
				    foreach (Vehicle vehicle in close)
				    {
					    if (_currentRivals.Any(riv => riv.Vehicle.Handle == vehicle.Handle) ||
					        Game.Player.Character.IsInVehicle(vehicle)) continue;
						vehicle.GetPedOnSeat(VehicleSeat.Driver)?.Delete();
						vehicle?.Delete();
				    }
			    }

			//    var res = UIMenu.GetScreenResolutionMantainRatio();
			//    var safe = UIMenu.GetSafezoneBounds();
			    const int interval = 45;
			    if (_countdown <= 0)
			    {
				    new UIResText("TIME",new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (1*interval))),0.3f, Color.White).Draw();
				    new UIResText(FormatTime((int) unchecked(_seconds - _missionStart)),new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (1*interval))),0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
				    new Sprite("timerbars", "all_black_bg",new Point(Convert.ToInt32(res.Width) - safe.X - 248,Convert.ToInt32(res.Height) - safe.Y - (100 + (1*interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

					new UIResText("POSITION", new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (2 * interval))), 0.3f, Color.White).Draw();
					new UIResText((CalculatePlayerPositionInRace() + 1) + "/" + (_currentRivals.Count + 1), new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (2 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
					new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - 248, Convert.ToInt32(res.Height) - safe.Y - (100 + (2 * interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

				    if (_raceSettings["Laps"] > 1)
				    {
						int playerCheckpoint = _currentRace.Checkpoints.Length - _checkpoints.Count;
					    int currentLap = Convert.ToInt32(Math.Floor(playerCheckpoint/(decimal)_totalLaps)) + 1;

						new UIResText("LAP",new Point(Convert.ToInt32(res.Width) - safe.X - 180,Convert.ToInt32(res.Height) - safe.Y - (90 + (3*interval))), 0.3f, Color.White).Draw();
					    new UIResText(currentLap + "/" + _raceSettings["Laps"], new Point(Convert.ToInt32(res.Width) - safe.X - 20,Convert.ToInt32(res.Height) - safe.Y - (102 + (3*interval))), 0.5f, Color.White, Font.ChaletLondon,UIResText.Alignment.Right).Draw();
					    new Sprite("timerbars", "all_black_bg",new Point(Convert.ToInt32(res.Width) - safe.X - 248,Convert.ToInt32(res.Height) - safe.Y - (100 + (3*interval))), new Size(250, 37), 0f,Color.FromArgb(200, 255, 255, 255)).Draw();
				    }
			    }


			    for (int i = 0; i < _rivalCheckpointStatus.Count; i++)
			    {
				    Tuple<Rival, int> tuple = _rivalCheckpointStatus[i];
				    if (tuple.Item1.Vehicle.IsInRangeOf(_currentRace.Checkpoints[tuple.Item2], 10f))
				    {
					    tuple.Item1.Character.Task.ClearAll();
					    if (_currentRace.Checkpoints.Length <= tuple.Item2 + 1)
					    {
						    if (!_finishedParticipants.Contains(tuple.Item1))
							    _finishedParticipants.Add(tuple.Item1);
						    tuple.Item1.Vehicle.HandbrakeOn = true;
						    continue;
					    }
					    _rivalCheckpointStatus[i] = new Tuple<Rival, int>(tuple.Item1,tuple.Item2 + 1);
					    Function.Call(Hash.TASK_VEHICLE_MISSION_COORS_TARGET, tuple.Item1.Character.Handle, tuple.Item1.Vehicle.Handle,
						    _currentRace.Checkpoints[tuple.Item2 + 1].X, _currentRace.Checkpoints[tuple.Item2 + 1].Y,
						    _currentRace.Checkpoints[tuple.Item2 + 1].Z, Mode, 200f, Rival.MainDrivingStyle, 5f, 0f, 0); // TODO: Debuggin // old - 6
				    }
			    }


			    World.DrawMarker(MarkerType.VerticalCylinder, _checkpoints[0], new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(10f, 10f, 2f), Color.FromArgb(100, 241, 247, 57));
			    if (_nextBlip == null)
				    _nextBlip = World.CreateBlip(_checkpoints[0]);
			    if (_checkpoints.Count >= 2)
			    {
				    if (_secondBlip == null)
				    {
					    _secondBlip = World.CreateBlip(_checkpoints[1]);
					    _secondBlip.Scale = 0.5f;
						if(_checkpoints.Count == 2)
							_secondBlip.Sprite = BlipSprite.RaceFinish;
				    }
				    Vector3 dir = _checkpoints[1] - _checkpoints[0];
					dir.Normalize();
					World.DrawMarker(MarkerType.ChevronUpx1, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(60f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
			    }
			    else
			    {
					Vector3 dir = Game.Player.Character.Position - _checkpoints[0];
					dir.Normalize();
				    World.DrawMarker(MarkerType.CheckeredFlagRect, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(0f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
					_nextBlip.Sprite = BlipSprite.RaceFinish;
			    }

			    if (Game.Player.Character.IsInVehicle() && Game.Player.Character.IsInRangeOf(_checkpoints[0], 10f))
			    {
					Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
					Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
					_checkpoints.RemoveAt(0);
					_nextBlip?.Remove();
					_secondBlip?.Remove();
				    _nextBlip = null;
				    _secondBlip = null;
				    if (_checkpoints.Count == 0)
				    {
					    Game.Player.CanControlCharacter = false;
						Function.Call(Hash._START_SCREEN_EFFECT, "HeistCelebPass", 0, true);
						if(Game.Player.Character.IsInVehicle())
							Game.Player.Character.CurrentVehicle.HandbrakeOn = true;
						World.DestroyAllCameras();
					    World.RenderingCamera = World.CreateCamera(GameplayCamera.Position, GameplayCamera.Rotation, 60f);
						Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_UNDER_THE_BRIDGE", "HUD_MINI_GAME_SOUNDSET");
						int position = _finishedParticipants.Count + 1;
					    int peoplecount = _currentRivals.Count + 1;
					    int score = 100 - ((position - 1)*10);
					    if (score < 0)
						    score = 0;
						_passed = new MissionPassedScreen(_currentRace.Name, score, score > 50 ? score > 90 ? MissionPassedScreen.Medal.Gold : MissionPassedScreen.Medal.Silver : MissionPassedScreen.Medal.Bronze);
						_passed.AddItem("Time Elapsed", FormatTime((int)unchecked(_seconds - _missionStart)), MissionPassedScreen.TickboxState.None);
						_passed.AddItem("Position", position + "/" + peoplecount, position == 1 ? MissionPassedScreen.TickboxState.Tick : MissionPassedScreen.TickboxState.Empty);
					    _passed.OnContinueHit += () =>
					    {
							Game.FadeScreenOut(1000);
							Wait(1000);
							Function.Call(Hash._STOP_SCREEN_EFFECT, "HeistCelebPass");
						    Game.Player.Character.Position = _currentRace.Trigger;
						    Game.Player.CanControlCharacter = true;
						    World.RenderingCamera = null;
							EndRace();
						    _passed = null;
							Game.FadeScreenIn(1500);
					    };
						_passed.Show();
						_isInRace = false;
				    }
			    }
			}
	    }
Beispiel #35
0
        public void Manager()
        {
            if (Game.LocalPlayer.Character.IsInHelicopter)
            {
                if (_showHelpText)
                {
                    Game.DisplayHelp("~g~Wilderness Callouts:~s~ Press ~b~" + Controls.ToggleHeliCam.ToUserFriendlyName() + "~s~ to activate the helicopter camera", 6500);
                    _showHelpText = false;
                }

                if (Controls.ToggleHeliCam.IsJustPressed() && (Camera == null || !Camera.Exists()))
                {
                    Camera = new Camera(true);
                    Camera.SetRotationYaw(Game.LocalPlayer.Character.CurrentVehicle.Heading);
                    Scaleform = new Scaleform();
                    Scaleform.Load("heli_cam");
                    NativeFunction.Natives.REQUEST_STREAMED_TEXTURE_DICT("helicopterhud", true);
                    Scaleform.CallFunction("SET_CAM_LOGO", 1);//TODO check this for updated Native invocation??
                    Camera.AttachToEntity(Game.LocalPlayer.Character.CurrentVehicle, GetCameraPositionOffsetForModel(Game.LocalPlayer.Character.CurrentVehicle.Model), true);
                    Sound.RequestAmbientAudioBank("SCRIPT\\POLICE_CHOPPER_CAM");
                    NativeFunction.Natives.SET_NOISEOVERIDE(true);
                    NativeFunction.Natives.SET_NOISINESSOVERIDE(0.15f);
                }
                else if ((Controls.ToggleHeliCam.IsJustPressed() || !Game.LocalPlayer.Character.IsInHelicopter || Game.LocalPlayer.Character.CurrentVehicle.IsDead || Game.LocalPlayer.Character.IsDead) && (Camera != null && Camera.Exists()))
                {
                    NativeFunction.Natives.SET_NOISEOVERIDE(false);
                    NativeFunction.Natives.SET_NOISINESSOVERIDE(0.0f);
                    Camera.Delete();
                    Camera    = null;
                    Scaleform = null;
                    if (WildernessCallouts.Common.IsNightVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetNightVision(false);
                    }
                    if (WildernessCallouts.Common.IsThermalVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetThermalVision(false);
                    }
                }



                if (Camera != null && Camera.Exists() && Scaleform != null)
                {
                    if (BackgroundSound.HasFinished())
                    {
                        BackgroundSound.PlayFrontend("COP_HELI_CAM_BACKGROUND", null);
                    }

                    NativeFunction.Natives.HIDE_HUD_AND_RADAR_THIS_FRAME();
                    WildernessCallouts.Common.DisEnableGameControls(false, GameControl.Enter, GameControl.VehicleExit, GameControl.VehicleAim, GameControl.VehicleAttack, GameControl.VehicleAttack2, GameControl.VehicleDropProjectile, GameControl.VehicleDuck /*, GameControl.VehicleFlyAttack, GameControl.VehicleFlyAttack2*/, GameControl.VehicleFlyAttackCamera, GameControl.VehicleFlyDuck, GameControl.VehicleFlySelectNextWeapon, GameControl.VehicleFlySelectPrevWeapon, GameControl.VehicleHandbrake, GameControl.VehicleJump, GameControl.LookLeftRight, GameControl.LookUpDown, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext);

                    float FOVpercentage = -((Camera.FOV - 70 /*max FOV*/)) / 35 /*min FOV*/;
                    if (FOVpercentage > 1f)
                    {
                        FOVpercentage = 1f;
                    }
                    else if (FOVpercentage < 0f)
                    {
                        FOVpercentage = 0f;
                    }
                    Scaleform.CallFunction("SET_ALT_FOV_HEADING", Camera.Position.Z, FOVpercentage, Camera.Rotation.Yaw);
                    WildernessCallouts.Common.DrawScaleformMovieFullscreen(Scaleform, Color.FromArgb(0, 255, 255, 255));

                    float moveSpeed = (Camera.FOV / 100) * (WildernessCallouts.Common.IsUsingController() ? 3.5f : 5.25f);

                    //float upDown = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookUpDown) * moveSpeed;
                    //float leftRight = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookLeftRight) * moveSpeed;

                    //Camera.Rotation = new Rotator(Camera.Rotation.Pitch - upDown, Camera.Rotation.Roll, Camera.Rotation.Yaw - leftRight);

                    float yRotMagnitude = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.LookUpDown) * moveSpeed;
                    float xRotMagnitude = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.LookLeftRight) * moveSpeed;

                    float newPitch = Camera.Rotation.Pitch - yRotMagnitude;
                    float newYaw   = Camera.Rotation.Yaw - xRotMagnitude;
                    Camera.Rotation = new Rotator((newPitch >= 25f || newPitch <= -70f) ? Camera.Rotation.Pitch : newPitch, /*_cam.Rotation.Roll*/ 0f, newYaw);


                    if (yRotMagnitude != 0f || xRotMagnitude != 0)
                    {
                        if (TurnSound.HasFinished())
                        {
                            TurnSound.PlayFrontend("COP_HELI_CAM_TURN", null);
                        }
                    }
                    else if (!TurnSound.HasFinished())
                    {
                        TurnSound.Stop();
                    }

                    //if (Camera.Rotation.Pitch <= -70f) Camera.SetRotationPitch(-69.99f);
                    //else if (Camera.Rotation.Pitch >= 25f) Camera.SetRotationPitch(24.99f);

                    if (!WildernessCallouts.Common.IsUsingController())
                    {
                        WildernessCallouts.Common.DisEnableGameControls(false, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext);
                        float wheelForwards  = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.WeaponWheelPrev) * 1.725f;
                        float wheelBackwards = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.WeaponWheelNext) * 1.725f;

                        Camera.FOV -= wheelForwards - wheelBackwards;
                        if (Camera.FOV > 70f)
                        {
                            Camera.FOV = 70f;
                        }
                        else if (Camera.FOV < 1f)
                        {
                            Camera.FOV = 1f;
                        }
                    }
                    if (Game.IsControllerButtonDownRightNow(ControllerButtons.A) /* || Game.IsKeyDownRightNow(Keys.LShiftKey)*/)
                    {
                        if (ZoomSound.HasFinished())
                        {
                            ZoomSound.PlayFrontend("COP_HELI_CAM_ZOOM", null);
                        }
                        WildernessCallouts.Common.DisEnableGameControls(false, GameControl.VehicleFlyThrottleUp, GameControl.VehicleFlyThrottleDown);
                        float up   = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.VehicleFlyThrottleUp);
                        float down = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.VehicleFlyThrottleDown);

                        Camera.FOV -= up - down;
                        if (Camera.FOV > 70f)
                        {
                            Camera.FOV = 70f;
                        }
                        else if (Camera.FOV < 5f)
                        {
                            Camera.FOV = 5f;
                        }
                    }
                    else
                    {
                        if (!ZoomSound.HasFinished())
                        {
                            ZoomSound.Stop();
                        }
                    }

                    if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && !WildernessCallouts.Common.IsNightVisionActive() && !WildernessCallouts.Common.IsThermalVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_ON_MASTER", null);
                        WildernessCallouts.Common.SetNightVision(true);
                    }
                    else if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && WildernessCallouts.Common.IsNightVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetNightVision(false);
                    }

                    if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && !WildernessCallouts.Common.IsThermalVisionActive() && !WildernessCallouts.Common.IsNightVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_ON_MASTER", null);
                        WildernessCallouts.Common.SetThermalVision(true);
                    }
                    else if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && WildernessCallouts.Common.IsThermalVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetThermalVision(false);
                    }

#if DEBUG
                    Game.DisplayHelp(Camera.Direction.ToString());
#endif

                    Entity raycastedEntity = WildernessCallouts.Common.RaycastEntity2(Camera.Position, Camera.Direction, 2000.0f, Game.LocalPlayer.Character, Game.LocalPlayer.Character.CurrentVehicle);

                    if (_searchCounter != 0)
                    {
                        SizeF res = RAGENativeUI.UIMenu.GetScreenResolutionMantainRatio();
                        new Sprite("helicopterhud", "hud_line", new Point(((int)res.Width / 2) - ((int)res.Width / 8) /*- ((int)res.Width / 32)*/, ((int)res.Height / 2) + ((int)res.Height / 4)), new Size(5 + _searchCounter * 2, 30)).Draw();
                    }

                    if (raycastedEntity != null && raycastedEntity.Exists())
                    {
                        if (Controls.HeliCamScan.IsPressed() && (raycastedEntity.IsPed() || raycastedEntity.IsVehicle()))
                        {
                            _searchCounter++;
                            if (SearchLoopSound.HasFinished())
                            {
                                SearchLoopSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_LOOP", null);
                            }
                            Vector2 v2  = World.ConvertWorldPositionToScreenPosition(raycastedEntity.Position);
                            SizeF   res = RAGENativeUI.UIMenu.GetScreenResolutionMantainRatio();//fix: work with all res
                            new Sprite("helicopterhud", "hud_target", new Point((int)v2.X + (125 / (int)res.Width) /*- ((int)res.Width / 125)*/, (int)v2.Y + (125 / (int)res.Height) /*- ((int)res.Height / 125)*/), new Size(125, 125)).Draw();


                            if (_searchCounter > 240)
                            {
                                if (raycastedEntity.IsPed())
                                {
                                    //Game.DisplayNotification("Ped detected");
                                    if (SearchSuccessSound.HasFinished())
                                    {
                                        SearchSuccessSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_SUCCESS", null);
                                    }
                                    _canOverrideDrawInfo = true;
                                    GameFiber.StartNew(delegate { DrawPedInfo((Ped)raycastedEntity, 13000); }, "DrawPedInfo Fiber");
                                }
                                else if (raycastedEntity.IsVehicle())
                                {
                                    //Game.DisplayNotification("Vehicle detected");
                                    if (SearchSuccessSound.HasFinished())
                                    {
                                        SearchSuccessSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_SUCCESS", null);
                                    }
                                    _canOverrideDrawInfo = true;
                                    GameFiber.StartNew(delegate { DrawVehicleInfo((Vehicle)raycastedEntity, 13000); }, "DrawVehicleInfo Fiber");
                                }
                                if (!SearchLoopSound.HasFinished())
                                {
                                    SearchLoopSound.Stop();
                                }

                                _searchCounter = 0;
                            }
                        }

                        if (raycastedEntity.IsVehicle())
                        {
                            DrawVehicleSpeed((Vehicle)raycastedEntity);
                        }
                    }
                    else if (_searchCounter > 0)
                    {
                        _searchCounter--;
                    }


                    if (!SearchLoopSound.HasFinished())
                    {
                        SearchLoopSound.Stop();
                    }
                }
                else
                {
                    if (!BackgroundSound.HasFinished())
                    {
                        BackgroundSound.Stop();
                    }
                    if (!ZoomSound.HasFinished())
                    {
                        ZoomSound.Stop();
                    }
                    if (!TurnSound.HasFinished())
                    {
                        TurnSound.Stop();
                    }
                    if (!SearchLoopSound.HasFinished())
                    {
                        SearchLoopSound.Stop();
                    }
                    if (!SearchSuccessSound.HasFinished())
                    {
                        SearchLoopSound.Stop();
                    }
                }
            }
            else if (!_showHelpText)
            {
                _showHelpText = true;
            }
        }
Beispiel #36
0
Datei: GUI.cs Projekt: Guad/NOOSE
        public static void DrawScaleform()
        {
            var scaleform = new Scaleform(0);
            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.Jump, 0), "Begin Assault");
            scaleform.CallFunction("SET_DATA_SLOT", 1, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendCancel, 0), "Cancel");
            scaleform.CallFunction("SET_DATA_SLOT", 2, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneRight, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 3, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneLeft, 0), "Change Mission");
            scaleform.CallFunction("SET_DATA_SLOT", 4, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendRb, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 5, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendLb, 0), "Change Entry Point");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
        }