Пример #1
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;
				    }
			    }
			}
	    }
Пример #2
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;
                    }
                }
            }
        }