void OnTick(object sender, EventArgs e) { //Util.GetRoadFlags(Game.Player.Character.Position); if (WasCheatStringJustEntered("st")) { BaseDrivingStyle = int.Parse(Game.GetUserInput(10)); } //Util.DisplayHelpTextThisFrame(Util.IsPotentiallySliding(Game.Player.Character.CurrentVehicle, 0.3f).ToString()); //Test /* * Vector3 posit = Game.Player.Character.Position + (Game.Player.Character.ForwardVector * 10); * RaycastResult raycast = World.Raycast(Game.Player.Character.Position , posit, IntersectOptions.Everything); * if(raycast.DitHitAnything) * { * Util.DisplayHelpTextThisFrame(Math.Round(raycast.SurfaceNormal.Z,3).ToString()); * * World.DrawMarker(MarkerType.ThinChevronUp, raycast.HitCoords, raycast.SurfaceNormal, new Vector3(0, 0, 0), new Vector3(2, 2, 2), Color.Red); * * Util.DrawLine(Game.Player.Character.Position, raycast.HitCoords); * }*/ HandleHeli(); //Util.HandleAISpinoutHelp(Game.Player.Character.CurrentVehicle); //DisplayHelpTextThisFrame(Game.Player.Character.CurrentVehicle.Acceleration.ToString()); _menuPool.ProcessMenus(); switch (RaceStatus) { case RacePhase.NotRacing: { DrawTriggers(); break; } case RacePhase.RaceSetup: { break; } case RacePhase.RacePreps: { if (!Traffic.Checked) { Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0f); Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); Function.Call(Hash.SET_PARKED_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); } if (HandleRacePreps()) { if (!Util.IsPlayerParticipating()) { Util.DisplayHelpTextThisFrame("Bet on any of the drivers approaching their car."); foreach (Racer racer in Racers) { if (Game.Player.Character.Position.DistanceTo(racer.car.Position) < 3f) { Util.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to bet " + Bet + "~g~$~w~ on the " + racer.Name + "."); if (Game.IsControlJustReleased(2, GTA.Control.Context)) { Game.Player.Character.Task.EnterVehicle(racer.car, VehicleSeat.Passenger, 3000); BetFromPlayer = racer; RaceStatus = RacePhase.RaceCountDown; break; } } } } else { RaceStatus = RacePhase.RaceCountDown; } } break; } case RacePhase.RaceCountDown: { if (!Traffic.Checked) { Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0f); Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); Function.Call(Hash.SET_PARKED_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); } if (Util.Countdown()) { if (Util.IsPlayerParticipating()) { if (CanWeUse(Game.Player.Character.CurrentVehicle)) { Game.Player.Character.CurrentVehicle.HandbrakeOn = false; } if (Prize > 0) { Util.AddNotification("CHAR_LAMAR", "~b~Lamar", "THE PRIZE", "The winner leaves with ~g~$" + Prize + "~w~ in his pocket, guys!"); } else { Util.AddNotification("CHAR_LAMAR", "~b~Lamar", "FRIENDLY RACE", "There's no prize for winning this race, so lets keep it clean!"); } //Util.AddNotification("CHAR_LAMAR", "~b~Lamar", "#", "Lets RACE."); //Util.AddNotification("","","","The prize for this race is~g~ $"+Prize+"~w~."); } if (ImmersiveCheckpoints.Checked) { foreach (Vector3 pos in RaceWaypoints) { //prop_basejump_target_01 prop_parking_wand_01 prop_air_lights_03a Prop light = World.CreateProp("prop_air_lights_03a", pos, new Vector3(0, 0, 0), true, false); Props.Add(light); } } if (RacersFinishedTreshold > Racers.Count) { RacersFinishedTreshold = Racers.Count; } RaceStatus = RacePhase.RaceInProgress; } else { if (Util.IsPlayerParticipating() && CanWeUse(Game.Player.Character.CurrentVehicle)) { Game.Player.Character.CurrentVehicle.HandbrakeOn = true; } } break; } case RacePhase.RaceInProgress: { if (RacersFinished > 0 && FirstRacerFinishTime == 0) { FirstRacerFinishTime = Game.GameTime + FinishRaceCountdown; Util.AddNotification("CHAR_LAMAR", "~b~Lamar", "First racer finished", FinishRaceCountdown / 1000 + " seconds until the race ends!"); } if (Winner != null && RacersFinished > 0 && FirstRacerFinishTime < Game.GameTime) { if (Prize > 0) { Util.AddNotification("CHAR_LAMAR", "~b~Lamar", "Race ended", "~b~" + Winner.Name + "~w~ gets the " + Prize + "~g~$~w~ prize!"); } if (Winner.driver.IsPlayer) { Game.Player.Money += Prize; //UI.Notify("You have won!"); } else { Winner.driver.Money = Winner.driver.Money + Prize; if (Winner.car.FriendlyName == Winner.Name) { UI.Notify("The ~b~" + Winner.car.FriendlyName + "~w~ has won."); } else { UI.Notify("~b~" + Winner.Name + "~w~ has won."); } if (BetFromPlayer != null && BetFromPlayer == Winner) { UI.Notify("~g~The car you betted on has won! You have won " + Bet + "~g~$~w~."); Game.Player.Money += Bet; } } CleanRace(); } if (ImmersiveCheckpoints.Checked) { foreach (Prop prop in Props) { if (prop.HeightAboveGround > 0.3f) { prop.ApplyForce(new Vector3(0, 0, -1)); } } } DrawWaypoints(); HandlePositions(); if (!Traffic.Checked) { Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0f); Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); Function.Call(Hash.SET_PARKED_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0f); } if (Game.Player.IsDead) { RaceStatus = RacePhase.NotRacing; //UI.Notify(""); DisplayHelpTextThisFrame("~r~Race Cancelled."); CleanRace(); } if (Util.IsPlayerParticipating()) { if (Game.Player.Character.IsOnFoot && RacersFinished == 0) { DisplayHelpTextThisFrame("Get back to your car."); if (Game.Player.Character.Position.DistanceTo(Util.GetPlayerRacer().car.Position) > 15f) { RaceStatus = RacePhase.NotRacing; //UI.Notify(""); DisplayHelpTextThisFrame("~r~Race Cancelled."); CleanRace(); } } } break; } case RacePhase.RaceEnded: { UI.Notify("~g~Race finished."); break; } } //Process Racer AI int QuickRaceTime = 0;//Game.GameTime + 300; if (1 == 1) { foreach (Racer racer in Racers) { racer.Tick(); } if (MainGameTimeRef < Game.GameTime) { foreach (Racer racer in Racers) { racer.ProcessRace(); } MainGameTimeRef = Game.GameTime + 100; } } Util.HandleNotifications(); if (Game.IsControlJustPressed(2, GTA.Control.Context)) { switch (RaceStatus) { case RacePhase.NotRacing: { if (IsPlayerNearAnyRace()) { if (!_menuPool.IsAnyMenuOpen()) { LoadRaceInfo(); List <VehicleHash> Models = new List <VehicleHash>(); //RaceStatus = RacePhase.RaceSetup; RaceSetupMenu.Visible = true; } } else { //if (Game.Player.Character.Velocity.Length() == 0) { LoadRaceTriggers(); } } break; } case RacePhase.RaceSetup: { break; } case RacePhase.RaceCountDown: { break; } case RacePhase.RaceInProgress: { /*RaceStatus = RacePhase.NotRacing; * UI.Notify("Race ended by player input."); * CleanRace(); */ //Game.Player.Character.SetIntoVehicle(Racers[Util.GetRandomInt(0,Racers.Count)].car, VehicleSeat.Passenger); break; } } } }