Exemple #1
0
        private async Task OnMissionScaleFormTick()
        {
            try
            {
                if (!_isNear)
                {
                    if (_dropOffMarkerScaleform.IsLoaded)
                    {
                        _dropOffMarkerScaleform.Dispose();
                    }
                    return;
                }

                var playerPed = Game.PlayerPed;

                _dropOffMarkerScaleform.CallFunction("SET_MISSION_INFO", "Drop Off", "Action", "Player Info", "", "", true, 1,
                                                     999, 9999, "");
                _dropOffMarkerScaleform.Render3D(playerPed.GetOffsetPosition(new Vector3(0, 2f, 0)), -playerPed.Rotation, Vector3.One);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            await Task.FromResult(0);
        }
Exemple #2
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);
        }
        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
            }
        }
	    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;
				    }
			    }
			}
	    }
Exemple #5
0
        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;
                    }
                }
            }
        }
Exemple #6
0
        void OnTick(object sender, EventArgs e)
        {
            config = ScriptSettings.Load("scripts\\3dMarker.ini");
            Blip[] blips = World.GetActiveBlips();

            // there are a finite number of scaleforms avail
            // queue them all up
            // if we use one, dequeue
            Queue <string> scaleform_queue = CreateScaleformQueue();

            // keep track of current markers already in world
            // replace if marker already exists but new one is closer
            Dictionary <string, Marker> current_markers = new Dictionary <string, Marker>();

            foreach (Blip b in blips)
            {
                // get blip name
                string marker_name = b.Sprite.ToString().ToUpper();

                // read ini file
                string enable_disable = config.GetValue <string>("options", marker_name, "disabled");

                // begin spaghetti code :(
                // if blip is "enabled" in ini file
                if (enable_disable == "enabled")
                {
                    // distance from player to blip
                    float distance = World.GetDistance(b.Position, GameplayCamera.Position);

                    // create coordinates, scale, and rotation for scaleform
                    // height and scale based on distance from player
                    Vector3 camrot      = Function.Call <Vector3>(Hash.GET_GAMEPLAY_CAM_ROT, 0);
                    Vector3 label_pos   = CreateLabelCoordinates(distance);
                    Vector3 label_scale = CreateLabelScale(distance);

                    // if there are still scaleforms available
                    if (scaleform_queue.Count > 0)
                    {
                        string scaleform_name = scaleform_queue.Dequeue();

                        // if blip has already been rendered in game world this tick
                        // this is for duplicates like Ammunation, Clothes, etc
                        if (current_markers.ContainsKey(marker_name))
                        {
                            Marker tmp_marker = current_markers[marker_name];

                            // if proposed blip is closer than blip that's already been placed in world
                            // replace it in world, replace it in current_markers
                            if (tmp_marker.distance > distance)
                            {
                                Marker new_marker;
                                new_marker.distance          = distance;
                                new_marker.scaleform_name    = tmp_marker.scaleform_name;
                                current_markers[marker_name] = new_marker;

                                var tmpSFs = new Scaleform(tmp_marker.scaleform_name);
                                tmpSFs.CallFunction("SET_PLAYER_NAME", b.Sprite.ToString());
                                tmpSFs.Render3D(b.Position + label_pos, new Vector3(0f, (0 - camrot.Z), 0), label_scale);
                            }

                            // requeue scaleform because we aren't using it
                            scaleform_queue.Enqueue(scaleform_name);
                        }
                        else
                        {
                            // if this is a new blip, add it to world and current_markers list
                            Marker new_marker;
                            new_marker.distance       = distance;
                            new_marker.scaleform_name = scaleform_name;
                            current_markers.Add(marker_name, new_marker);

                            var tmpSFs = new Scaleform(scaleform_name);
                            tmpSFs.CallFunction("SET_PLAYER_NAME", b.Sprite.ToString());
                            tmpSFs.Render3D(b.Position + label_pos, new Vector3(0f, (0 - camrot.Z), 0), label_scale);
                        }
                    }
                }
            }
        }