private void CheckANPRShapeTest(string cameraname, ShapeTest stest, Vehicle originVeh, bool left) { if (stest.hit && API.IsEntityAVehicle(stest.hitEntity)) { Vehicle hitVeh = (Vehicle)Vehicle.FromHandle(stest.hitEntity); bool positionedRight = Vector3.Distance(originVeh.GetOffsetPosition(Vector3.Left), hitVeh.Position) > Vector3.Distance(originVeh.GetOffsetPosition(Vector3.Right), hitVeh.Position); if ((left && positionedRight) || (positionedRight && !positionedRight)) { return; } string modelName = API.GetDisplayNameFromVehicleModel((uint)API.GetEntityModel(stest.hitEntity)); string plate = API.GetVehicleNumberPlateText(stest.hitEntity).Replace(" ", string.Empty); if (!checkedPlates.Contains(plate)) { checkedPlates.Add(plate); if (CameraTech.PlateInfo != null && CameraTech.PlateInfo.ContainsKey(plate)) { float distance = Vector3.Distance(stest.from, hitVeh.Position); string colour = VehicleColour.GetVehicleColour(stest.hitEntity).PrimarySimpleColourName; TriggerEvent("chatMessage", cameraname, new int[] { 255, 128, 0 }, colour + " " + modelName + ". " + plate + ". Dist: " + (int)Math.Round(distance) + ". ^*Markers: ^r" + CameraTech.PlateInfo[plate]); CameraTech.PlayANPRAlertSound(); ANPRInterface.VehicleANPRHeaderString = cameraname; ANPRInterface.VehicleANPRInfo = colour + " " + modelName + ". " + plate + "."; ANPRInterface.VehicleANPRMarkers = "~r~" + CameraTech.PlateInfo[plate]; ANPRInterface.FlashVehicleANPR(); } else { PlayANPRScanSound(); } } } }
public VehicleANPR() { EventHandlers["CameraTech:ToggleVehicleANPR"] += new Action <dynamic>((dynamic) => { if (Active) { Active = false; CameraTech.FixedANPRAlertsToggle = false; CameraTech.RemoveANPRBlips(); ANPRvehicle = null; Screen.ShowNotification("Vehicle ANPR " + (Active ? "activated." : "deactivated.")); } else if (Game.Player != null && Game.Player.Character != null && Game.Player.Character.Exists() && Game.Player.Character.IsInVehicle() && Game.Player.Character.CurrentVehicle.Exists()) { if (CameraTech.ANPRModels.Contains(Game.Player.Character.CurrentVehicle.Model)) { Active = true; Screen.ShowNotification("Vehicle ANPR " + (Active ? "activated." : "deactivated.") + " Fixed ANPR alerts activated."); checkedPlates.Clear(); ANPRvehicle = Game.Player.Character.CurrentVehicle; CameraTech.FixedANPRAlertsToggle = true; CameraTech.CreateFixedANPRBlips(); } else { Screen.ShowNotification("This vehicle does not have ANPR technology."); } } }); EventHandlers["CameraTech:ReadPlateInFront"] += new Action <dynamic>((dynamic) => { ReadPlateFront(); }); EventHandlers["CameraTech:SyncPlateInfo"] += new Action <dynamic>((dynamic plateinfo) => { checkedPlates.Clear(); }); RunChecks(); }