public void Mission_Aborted(object sender, EventArgs e) { Stop(MissionFailReason.ScriptExit); _missionTimeBar = null; _missionBarPool = null; }
private async void StartMoneyTruckEvent(dynamic truckNative, dynamic driverNative, dynamic guardNative) { RandomEvents.SetGameRunning(true); timerBarPool = new TimerBarPool(); TextTimerBar timer = new TextTimerBar("Time Left", "7:00"); timerBarPool.Add(timer); truck = new Vehicle(truckNative); driver = new Ped(driverNative); guard = new Ped(guardNative); truckBlip = truck.AttachBlip(); truckBlip.Sprite = (BlipSprite)67; truckBlip.Color = BlipColor.Blue; Function.Call(Hash.FLASH_MINIMAP_DISPLAY); Tick += onTickTask; for (int i = 0; i < 1000; i++) { await Delay(1); Screen.DisplayHelpTextThisFrame("A money truck has been exposed to the Minimap System. " + "Capture it for money."); } }
private void CreateTimerBars() { tbPool = new TimerBarPool(); text = new TextTimerBar("LABEL", "TEXT"); progressBar = new BarTimerBar("PROGRESS"); checkpoints = new CheckpointsTimerBar("CHECKPOINTS", 4); icons = new IconsTimerBar("ICONS"); }
public SprintGui() { timerBarPool = new TimerBarPool(); timeBar = new TextTimerBar("Time", "0:00"); timerBarPool.Add(timeBar); positionBar = new TextTimerBar("Position", ""); timerBarPool.Add(positionBar); }
public DistanceRaceGui() { timerBarPool = new TimerBarPool(); timeBar = new TextTimerBar("Time", "0:00"); timerBarPool.Add(timeBar); positionBar = new TextTimerBar("Position", ""); timerBarPool.Add(positionBar); distanceBar = new BarTimerBar("Distance"); distanceBar.BackgroundColor = Color.Black; distanceBar.ForegroundColor = Color.White; timerBarPool.Add(distanceBar); }
public static void Main() { Game.FrameRender += Process; timerBarPool = new TimerBarPool(); barTimerBar = new BarTimerBar("BAR"); textTimerBar = new TextTimerBar("TIME", "00:00"); textTimerBar2 = new TextTimerBar("SPEED", "0 km/h"); timerBarPool.Add(barTimerBar); timerBarPool.Add(textTimerBar); timerBarPool.Add(textTimerBar2); while (true) GameFiber.Yield(); }
public static void Start(MissionType type, int labIndex, List <Vector3> coords, float vehicleHeading, int timeMs, int productAmount = 0) { if (!IsActive) { IsActive = true; _missionType = type; _missionEndTime = Game.GameTime + timeMs; _missionModel = Game.Player.Character.Model.Hash; _missionLabIdx = labIndex; _productAmount = productAmount; _objectiveCoords = coords; if (_missionBarPool == null) { _missionBarPool = new TimerBarPool(); _missionTimeBar = new TextTimerBar("TIME LEFT", "00:00"); _missionBarPool.Add(_missionTimeBar); } foreach (Vector3 pos in _objectiveCoords) { Function.Call(Hash.CLEAR_AREA, pos.X, pos.Y, pos.Z, 5f, true, false, false, false); } // spaghetti switch (_missionType) { case MissionType.Setup: { _missionVehicle = World.CreateVehicle(VehicleHash.Pounder, _objectiveCoords[0], vehicleHeading); _missionVehicle.PrimaryColor = VehicleColor.MetallicBlack; _missionVehicle.SecondaryColor = VehicleColor.MetallicBlack; _missionVehicle.IsPersistent = true; Blip vehicleBlip = _missionVehicle.AddBlip(); vehicleBlip.Sprite = BlipSprite.Package2; vehicleBlip.Color = BlipColor.Blue; vehicleBlip.IsShortRange = false; vehicleBlip.Name = "Supply Truck"; Blip deliveryBlip = World.CreateBlip(_objectiveCoords[1]); deliveryBlip.Sprite = BlipSprite.Standard; deliveryBlip.Color = BlipColor.Yellow; deliveryBlip.IsShortRange = false; deliveryBlip.Alpha = 0; deliveryBlip.Name = "Meth Lab"; _missionBlips.Add("vehicle", vehicleBlip); _missionBlips.Add("deliveryPoint", deliveryBlip); NotificationQueue.Add("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, a gang member posted about their supply truck online. Go to {World.GetZoneName(_objectiveCoords[0])} and take it, they won't even know!", "CHAR_LJT", 1); break; } case MissionType.Delivery: { _missionVehicle = World.CreateVehicle(Constants.DeliveryVehicles[Constants.RandomGenerator.Next(0, Constants.DeliveryVehicles.Length)], _objectiveCoords[0], vehicleHeading); _missionVehicle.IsPersistent = true; Blip vehicleBlip = _missionVehicle.AddBlip(); vehicleBlip.Sprite = BlipSprite.Package2; vehicleBlip.Color = BlipColor.Blue; vehicleBlip.IsShortRange = false; vehicleBlip.Name = "Delivery Vehicle"; Blip deliveryBlip = World.CreateBlip(_objectiveCoords[1]); deliveryBlip.Sprite = BlipSprite.Standard; deliveryBlip.Color = BlipColor.Yellow; deliveryBlip.IsShortRange = false; deliveryBlip.Alpha = 0; deliveryBlip.Name = "Delivery Point"; _missionBlips.Add("vehicle", vehicleBlip); _missionBlips.Add("deliveryPoint", deliveryBlip); NotificationQueue.Add("LJT", $"{Util.GetCharacterFromModel(_missionModel)}, the buyer wants the product to be delivered to {World.GetZoneName(_objectiveCoords[1])}.", "CHAR_LJT", 1); break; } } foreach (Lab lab in Main.MethLabs) { lab.SetBlipVisible(false); } SetStage(MissionStage.GetInVehicle); } }
public void SetupLapHud(string lap) { this.lapHud = new TextTimerBar("Lap:", lap); this.hudPool.Add(this.lapHud); }
public void SetupFastestLapTimeHud() { this.fastestLapTimeHud = new TextTimerBar("Fastest Lap Time:", "00:00"); this.hudPool.Add(this.fastestLapTimeHud); }
public void SetupLapTimeHud() { this.lapTimeHud = new TextTimerBar("Current Lap Time:", "00:00"); this.hudPool.Add(this.lapTimeHud); }
public void SetupTimeHud() { this.timeHud = new TextTimerBar("Time:", "00:00"); this.hudPool.Add(this.timeHud); }
private static void Main() { // create the pool that handles drawing the timer bars pool = new TimerBarPool(); // timer bar that shows the player health as a progress bar and is highlighted in red when the player is damaged BarTimerBar healthTB = new BarTimerBar("HEALTH"); // timer bar that shows the player speed TextTimerBar speedTB = new TextTimerBar("SPEED", "0 km/h"); // timer bar that shows the time of day TextTimerBar clockTB = new TextTimerBar("CLOCK", "00:00:00"); // use monospace font for the time text clockTB.TextStyle = clockTB.TextStyle.With(font: TextFont.ChaletLondonFixedWidthNumbers); // timer bar that shows the player equipped weapon as an icon IconsTimerBar weaponTB = new IconsTimerBar("WEAPON"); weaponTB.Icons.Add(new TimerBarIcon("commonmenu", "arrowleft") { Size = new SizeF(TimerBarIcon.DefaultSize.Width * 0.825f, TimerBarIcon.DefaultSize.Height * 0.825f), Spacing = TimerBarIcon.DefaultSpacing * 2.75f }); weaponTB.Icons.Add(new TimerBarIcon("mpkillquota", "weapon_unarmed")); // timer bar that shows the wanted level as checkpoints Color checkpointsColor = HudColor.Gold.GetColor(); CheckpointsTimerBar wantedLevelTB = new CheckpointsTimerBar("WANTED", 5) { Accent = checkpointsColor }; foreach (TimerBarCheckpoint cp in wantedLevelTB.Checkpoints) { cp.Color = checkpointsColor; } // add all the timer bars to the pool pool.Add(healthTB, speedTB, clockTB, weaponTB, wantedLevelTB); // start the fiber which will handle drawing the timer bars GameFiber.StartNew(ProcessTimerBars); // continue with the plugin... Game.Console.Print($" {healthTB.Label}: shows the player health."); Game.Console.Print($" {speedTB.Label}: shows the player speed in kilometers per hour"); Game.Console.Print($" {clockTB.Label}: shows the current time of day"); Game.Console.Print($" {weaponTB.Label}: shows the type of the weapon currently equipped"); Game.Console.Print($" {wantedLevelTB.Label}: shows the player wanted level."); float lastHealth = 0.0f; float healthDamage = 0.0f; const float HealthDamageIndicatorDuration = 2.0f; // seconds while (true) { GameFiber.Yield(); Ped playerPed = Game.LocalPlayer.Character; // update speedometer timer bar { int speed = MathHelper.ConvertMetersPerSecondToKilometersPerHourRounded(playerPed.Speed); speedTB.Text = $"{speed} km/h"; } // update clock timer bar { clockTB.Text = World.TimeOfDay.ToString(); } // update health timer bar { float health = (float)(playerPed.Health - 100) / (playerPed.MaxHealth - 100); bool hasReceivedDamaged = health < lastHealth; lastHealth = health; healthTB.Percentage = health; healthTB.ForegroundColor = (health < 0.25 ? HudColor.RadarDamage : HudColor.RadarHealth).GetColor(); healthTB.BackgroundColor = Color.FromArgb(120, healthTB.ForegroundColor); if (healthDamage > 0.0f) { // set highlight and fade it out healthTB.Highlight = Color.FromArgb((int)(healthDamage * 255), HudColor.RadarDamage.GetColor()); healthDamage -= (1.0f / HealthDamageIndicatorDuration) * Game.FrameTime; } else { healthTB.Highlight = null; if (hasReceivedDamaged) { healthDamage = 1.0f; } } } // update weapon timer bar { // choose a new texture based on the equipped weapon var tex = playerPed.CurrentVehicle.Exists() ? ("mpcarhud", "transport_car_icon", 1.1f, 1.1f) : playerPed.Inventory.EquippedWeapon switch { null => ("mpkillquota", "weapon_unarmed", 2.75f, 1.25f), var w => NativeFunction.Natives.GetWeapontypeGroup <uint>(w.Asset.Hash) switch { 0x18D5FA97u /* group_pistol */ => ("mpkillquota", "weapon_pistol", 2.75f, 1.25f), 0x33431399u /* group_shotgun */ => ("mpkillquota", "weapon_shotgun_pump", 2.7f, 1.3f), _ => ("mpkillquota", "weapon_rifle_carbine", 2.75f, 1.25f) } }; var icon = weaponTB.Icons[1]; icon.TextureDictionary = tex.Item1; icon.TextureName = tex.Item2; var s = TimerBarIcon.DefaultSize; icon.Size = new SizeF(s.Width * tex.Item3, s.Height * tex.Item4); } // update wanted level timer bar { int level = Game.LocalPlayer.WantedLevel; for (int i = 0; i < wantedLevelTB.Checkpoints.Count; i++) { wantedLevelTB.Checkpoints[i].State = i < level ? TimerBarCheckpointState.Completed : TimerBarCheckpointState.InProgress; wantedLevelTB.Checkpoints[i].IsCrossedOut = i < level - 1; } } } }
public Counter(string label, string text) { counter = new TextTimerBar(label, text); }
private static int GetNumberOfVehicleDoors(Vehicle veh) => NativeFunction.Natives.x92922A607497B14D <int>(veh); // _GET_NUMBER_OF_VEHICLE_DOORS private void SpeedBombRoutine() { var veh = CurrentVehicle; if (!veh) { return; } float maxSpeed = MathHelper.ConvertMetersPerSecondToKilometersPerHour(veh.TopSpeed - 5.0f); // kmph float minSpeed = maxSpeed - 50.0f; // kmph var timerBars = new TimerBarPool(); var speedTB = new BarTimerBar("SPEED"); speedTB.Markers.Add(new TimerBarMarker(minSpeed / maxSpeed)); var detonationTB = new BarTimerBar("DETONATION"); var timeTB = new TextTimerBar("TIME TO DISARM", "00:00"); timeTB.TextStyle = timeTB.TextStyle.With(font: TextFont.ChaletLondonFixedWidthNumbers); timerBars.Add(speedTB, timeTB); const uint DisarmTime = 120_000; // ms const float DetonationTime = 10.0f; // s bool hasEnoughSpeed = false; bool isDetonationTBAdded = false; float detonation = 0.0f; uint endTime = Game.GameTime + DisarmTime; while (veh) { float speed = MathHelper.ConvertMetersPerSecondToKilometersPerHour(veh.Speed); if (speed >= minSpeed) { if (!hasEnoughSpeed) { speedTB.ForegroundColor = HudColor.Green.GetColor(); speedTB.BackgroundColor = Color.FromArgb(120, speedTB.ForegroundColor); hasEnoughSpeed = true; } detonation -= (1.0f / DetonationTime * 1.5f) * Game.FrameTime; } else { if (hasEnoughSpeed) { speedTB.ForegroundColor = HudColor.Red.GetColor(); speedTB.BackgroundColor = Color.FromArgb(120, speedTB.ForegroundColor); if (detonation < 0.0f) { detonation = 0.0f; } hasEnoughSpeed = false; } detonation += (1.0f / DetonationTime) * Game.FrameTime; if (detonation >= 1.0f) { veh.Explode(makeExplosion: true); break; } } detonationTB.Percentage = detonation; if (isDetonationTBAdded) { if (detonation <= 0.0f) { timerBars.Remove(detonationTB); isDetonationTBAdded = false; } } else { if (detonation > 0.0f) { timerBars.Clear(); // note, there is no Insert at index timerBars.Add(speedTB, detonationTB, timeTB); isDetonationTBAdded = true; } } speedTB.Percentage = speed / maxSpeed; uint currTime = Game.GameTime; if (currTime >= endTime) { break; } else { uint remaining = endTime - currTime; timeTB.Text = TimeSpan.FromMilliseconds(remaining).ToString("mm\\:ss"); } timerBars.Draw(); GameFiber.Yield(); } speedBomb.Enabled = CurrentVehicle; speedBombFiber = null; }