private void OnAlprVanillaMessage(object sender, ALPR_Arguments e) { if (e.Vehicle == null || !e.Vehicle.Exists()) { return; } var data = ComputerVehicleController.LookupVehicle(e.Vehicle); if (data == null) { return; } if (!data.IsPersistent) { data.IsPersistent = true; } var vehiclePersona = data.VehiclePersona; vehiclePersona.Alert = e.Message; data.VehiclePersona = vehiclePersona; if (list_collected_tags.RowCount >= 6) { var entry = list_collected_tags[0]; var first = entry.UserData as ComputerPlusEntity; if (first != null && first.Validate() && first.IsPersistent) { first.IsPersistent = false; } while (list_collected_tags.RowCount >= 6) { list_collected_tags.RemoveRow(0); } } list_collected_tags.AddVehicle(data); }
private static void ALPRPlusFunctions_OnAlprPlusMessage(object sender, ALPR_Arguments e) { ComputerVehicleController.AddAlprScan(e); }
/* * public static void RunVanillaAlpr() * { * Function.LogDebug("RunVanillaAlpr"); * if (VanillaAlprGameFiber.IsHibernating) * { * Function.LogDebug("Wake RunVanillaAlpr"); * EventHandler handler = (EventHandler)OnStopAlprVanilla; * if (handler != null) * { * handler(null, null); * } * * VanillaAlprGameFiber.Wake(); * } * else if (!VanillaAlprGameFiber.IsAlive && !VanillaAlprGameFiber.IsSleeping) * { * Function.LogDebug("Start RunVanillaAlpr"); * VanillaAlprGameFiber.Start(); * } * } * * public static void StopVanillaAlpr() * { * Function.LogDebug("StopVanillaAlpr"); * if (!VanillaAlprGameFiber.IsHibernating && VanillaAlprGameFiber.IsAlive) * { * EventHandler handler = (EventHandler)OnStopAlprVanilla; * if(handler != null) * { * Function.LogDebug("StopVanillaAlpr handler"); * handler(null, null); * } * else * { * Function.LogDebug("StopVanillaAlpr no handler"); * } * } * } */ public static void AddAlprScan(ALPR_Arguments args) { ALPR_Detected.Add(args); }
private static void VanillaALPR() { Function.LogDebug("Executing VanillaALPR"); bool shouldRun = true; OnStopAlprVanilla += (sender, args) => { shouldRun = !shouldRun; }; while (true) { while (shouldRun) { var vehicle = Game.LocalPlayer.LastVehicle; if (vehicle != null && vehicle.Exists() && vehicle.HasDriver && vehicle.Driver == Game.LocalPlayer.Character) { Vector3 front = Game.LocalPlayer.Character.GetOffsetPositionFront(ReadDistanceThreshold); Vector3 rear = Game.LocalPlayer.Character.GetOffsetPositionFront((0 - vehicle.Width) - ReadDistanceThreshold); Vector3 driver = Game.LocalPlayer.Character.GetOffsetPositionRight((0 - vehicle.Length) - ReadDistanceThreshold); Vector3 passenger = Game.LocalPlayer.Character.GetOffsetPositionRight(ReadDistanceThreshold); var nearVehicles = World.EnumerateVehicles() .Where(x => x != vehicle && !ALPR_Detected.Exists(y => y.Vehicle == x) && x.IsOnScreen) .Where(x => x.DistanceTo(Game.LocalPlayer.Character.Position) <= ReadDistanceThreshold * 3) .Where(x => x.IsCar && x.ShouldVehiclesYieldToThisVehicle) .Select(x => { Function.LogDebug(String.Format("Detected plate: {0}", x.LicensePlate)); return(x); }); if (nearVehicles != null) { var handler = (EventHandler <ALPR_Arguments>)OnAlprVanillaMessage; foreach (var x in nearVehicles) { ALPR_Arguments entry = null; if (x.Position.DistanceTo(front) <= ReadDistanceThreshold) { Function.LogDebug("Vehicle detected FRONT"); entry = new ALPR_Arguments(x, ALPR_Position.FRONT); } else if (x.Position.DistanceTo(rear) <= ReadDistanceThreshold) { Function.LogDebug("Vehicle detected REAR"); entry = new ALPR_Arguments(x, ALPR_Position.REAR); } else if (x.Position.DistanceTo(driver) <= ReadDistanceThreshold) { Function.LogDebug("Vehicle detected DRIVER"); entry = new ALPR_Arguments(x, ALPR_Position.DRIVER); } else if (x.Position.DistanceTo(passenger) <= ReadDistanceThreshold) { Function.LogDebug("Vehicle detected PASSENGER"); entry = new ALPR_Arguments(x, ALPR_Position.PASSENGER); } if (entry != null) { AddAlprScan(entry); var data = LookupVehicle(entry.Vehicle); if (data != null && data.PedPersona.Wanted) { var msg = String.Format("~r~Wanted Owner:~w~ {0} {1} {2}", data.Vehicle.Model.Name, data.Vehicle.LicensePlate, data.PedPersona.FullName); Game.DisplayNotification(msg); Function.Log(msg); } if (handler != null) { handler(null, entry); } } } } } GameFiber.Yield(); } GameFiber.Hibernate(); } }