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."); } }
public PlayerTimer(TimerBarPool pool, BarTimerBar bar, float duration) { this.pool = pool; this.bar = bar; this.duration = duration; this.elapsed = 0f; }
public Chaos() { timers = new TimerBarPool(); menu = BuildMenu(); Tick += (o, e) => timers.Draw(); Tick += (o, e) => menu.Draw(); Tick += OnTick; KeyDown += OnKeyDown; var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.ReuseAddress, true); socket.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7291)); // Note: this is the only way to make sure we close the fricking socket. Aborted += (o, e) => { socket.Close(); }; state = new State(); Receive(socket); Rnd = new Random(); HateGroup = new HateGroup(); ShowText("ChaosMod Reloaded"); }
public void Mission_Aborted(object sender, EventArgs e) { Stop(MissionFailReason.ScriptExit); _missionTimeBar = null; _missionBarPool = null; }
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 Stats() { Tick += OnTick; hudPool = new TimerBarPool(); hungerBar = new BarTimerBar("~y~HUNGER"); thirstBar = new BarTimerBar("~b~THIRST"); energyBar = new BarTimerBar("~g~ENERGY"); hungerBar.BackgroundColor = Color.Gray; hungerBar.ForegroundColor = Color.Yellow; thirstBar.BackgroundColor = Color.Gray; thirstBar.ForegroundColor = Color.Blue; energyBar.BackgroundColor = Color.Gray; energyBar.ForegroundColor = Color.Green; hudPool.Add(energyBar); hudPool.Add(thirstBar); hudPool.Add(hungerBar); }
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 Stats() { base.Tick += new EventHandler(this.OnTick); this.hudPool = new TimerBarPool(); this.hungerBar = new BarTimerBar("~y~HUNGER"); this.thirstBar = new BarTimerBar("~b~THIRST"); this.energyBar = new BarTimerBar("~g~ENERGY"); this.hungerBar.BackgroundColor = Color.Gray; this.hungerBar.ForegroundColor = Color.Yellow; this.thirstBar.BackgroundColor = Color.Gray; this.thirstBar.ForegroundColor = Color.Blue; this.energyBar.BackgroundColor = Color.Gray; this.energyBar.ForegroundColor = Color.Green; this.hudPool.Add(this.energyBar); this.hudPool.Add(this.thirstBar); this.hudPool.Add(this.hungerBar); }
public static void Main(Vector3 loc) { "Starting TimerBar Main".AddLog(); _distance = Game.LocalPlayer.Character.TravelDistanceTo(loc); _loc = loc; _timerBarPool = new TimerBarPool(); _barTimerBar = new BarTimerBar("Distance Remaining"); _barTimerBar.ForegroundColor = Color.Yellow; _timerBarPool.Add(_barTimerBar); "Starting TimerBar Process".AddLog(); Game.FrameRender += Process; while (true) { GameFiber.Yield(); } }
public static void Init() { // Set up menus MenuPool = new MenuPool(); MainMenu = new MainMenu().GetMenu(); WeaponShop = new WeaponShopMenu().GetMenu(); WeaponPurchase = new WeaponPurchaseMenu().GetMenu(); VehicleMenu = new VehicleMenu().GetMenu(); MenuPool.Add(MainMenu); MenuPool.Add(WeaponPurchase); MenuPool.Add(WeaponShop); MenuPool.Add(VehicleMenu); MenuPool.RefreshIndex(); // Other UI TimerBarPool = new TimerBarPool(); UIElements = new Dictionary <string, UIElementController>(); VehicleController.Init(); }
private static void CreateTimerBars(string name) { TimerBarPool pool = new TimerBarPool(); pool.Add(new TextTimerBar(name + " #1", "TEXT")); pool.Add(new BarTimerBar(name + " #2") { Percentage = 0.5f }); pool.Add(new TextTimerBar(name + " #3", "") { Accent = HudColor.RedDark.GetColor() }); GameFiber.StartNew(() => { uint startTime = Game.GameTime; while ((startTime + 60_000) > Game.GameTime) { GameFiber.Yield(); pool.Draw(); } }); }
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 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 AnonymousTimer(TimerBarPool pool, float time, float duration) { this.pool = pool; this.Time = time; this.Duration = duration; }
public Gauge(TimerBarPool pool, BarTimerBar bar) { this.pool = pool; this.bar = bar; this.visible = true; }
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; }