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 CameraTech() { Debug.Write("CameraTech by Albo1125."); TriggerEvent("chat:addSuggestion", "/setplateinfo", "Sets markers for the specified plate", new[] { new { name = "param", help = "Type the plate, followed by semicolon (;), followed by the ANPR markers (leave markers blank to remove). Ex: AB12CDE;Stolen" }, }); TriggerEvent("chat:addSuggestion", "/setvehinfo", "Sets markers for the plate of the vehicle you're currently in", new[] { new { name = "markers", help = "The markers for this vehicle's plate, leave blank to remove from the system. Ex: Stolen" }, }); EventHandlers["CameraTech:ClUpdateVehicleInfo"] += new Action <string>((string plateinfo) => { if (Game.Player != null && Game.Player.Character != null && Game.Player.Character.Exists() && Game.Player.Character.IsInVehicle() && Game.Player.Character.CurrentVehicle.Exists()) { string plate = API.GetVehicleNumberPlateText(Game.Player.Character.CurrentVehicle.Handle).Replace(" ", string.Empty); TriggerServerEvent("CameraTech:UpdateVehicleInfo", plate, plateinfo); if (plateinfo != null) { TriggerEvent("chatMessage", "SYSTEM", new int[] { 0, 0, 0 }, "Plate: " + plate + ". Info: " + plateinfo); } else { TriggerEvent("chatMessage", "SYSTEM", new int[] { 0, 0, 0 }, "Plate: " + plate + ". No info."); } } }); EventHandlers["CameraTech:ClFixedANPRAlert"] += new Action <string, string, string, string, string>((string colour, string modelName, string anprname, string dir, string plate) => { if (FixedANPRAlertsToggle && Game.Player != null && Game.Player.Character != null && Game.Player.Character.Exists() && Game.Player.Character.IsInVehicle() && Game.Player.Character.CurrentVehicle.Exists() && ANPRModels.Contains(Game.Player.Character.CurrentVehicle.Model)) { if (FocussedPlate != null && FocussedPlate == plate) { TriggerEvent("chatMessage", "Fixed ANPR", new int[] { 0, 191, 255 }, colour + " " + modelName + ". " + plate + ". " + anprname + " (" + dir + "). ^*Markers: ^r" + PlateInfo[plate]); PlayANPRAlertSound(); if (BlipsCreated) { FixedANPR fixedanpr = FixedANPRCameras.Where(x => x.Name == anprname).FirstOrDefault(); if (fixedanpr != null && fixedanpr.blip.Exists()) { fixedanpr.blip.ShowRoute = true; RouteBlip = fixedanpr.blip; } } ANPRInterface.FixedANPRHeaderString = anprname + " (" + dir + ")"; ANPRInterface.FixedANPRInfo = colour + " " + modelName + ". " + plate + "."; ANPRInterface.FixedANPRMarkers = "~r~" + PlateInfo[plate]; ANPRInterface.FlashFixedANPR(); } else if (FocussedPlate == null) { TriggerEvent("chatMessage", "Fixed ANPR", new int[] { 0, 191, 255 }, colour + " " + modelName + ". " + plate + ". " + anprname + " (" + dir + "). ^*Markers: ^r" + PlateInfo[plate]); PlayANPRAlertSound(); ANPRInterface.FixedANPRHeaderString = anprname + " (" + dir + ")"; ANPRInterface.FixedANPRInfo = colour + " " + modelName + ". " + plate + "."; ANPRInterface.FixedANPRMarkers = "~r~" + PlateInfo[plate]; ANPRInterface.FlashFixedANPR(); } } }); EventHandlers["CameraTech:FixedANPRToggle"] += new Action <dynamic>((dynamic) => { if (FixedANPRAlertsToggle) { FixedANPRAlertsToggle = false; Screen.ShowNotification("Fixed ANPR alerts " + (FixedANPRAlertsToggle ? "activated." : "deactivated.")); RemoveANPRBlips(); } else if (Game.Player != null && Game.Player.Character != null && Game.Player.Character.Exists() && Game.Player.Character.IsInVehicle() && Game.Player.Character.CurrentVehicle.Exists()) { if (ANPRModels.Contains(Game.Player.Character.CurrentVehicle.Model)) { FixedANPRAlertsToggle = true; Screen.ShowNotification("Fixed ANPR alerts " + (FixedANPRAlertsToggle ? "activated." : "deactivated.")); CreateFixedANPRBlips(); } else { Screen.ShowNotification("This vehicle does not have ANPR technology."); } } }); EventHandlers["CameraTech:SyncPlateInfo"] += new Action <dynamic>((dynamic plateinfo) => { PlateInfo.Clear(); if (plateinfo != null) { foreach (KeyValuePair <string, dynamic> item in plateinfo) { PlateInfo[item.Key] = item.Value.ToString(); } } }); EventHandlers["CameraTech:FocusANPR"] += new Action <string>((string plate) => { if (FixedANPRAlertsToggle && Game.Player != null && Game.Player.Character != null && Game.Player.Character.Exists() && Game.Player.Character.IsInVehicle() && Game.Player.Character.CurrentVehicle.Exists() && ANPRModels.Contains(Game.Player.Character.CurrentVehicle.Model)) { FocussedPlate = plate; if (FocussedPlate == null) { TriggerEvent("chatMessage", "Fixed ANPR", new int[] { 0, 191, 255 }, "Removed fixed ANPR plate focus."); if (RouteBlip != null && RouteBlip.Exists()) { RouteBlip.ShowRoute = false; RouteBlip = null; } } else { TriggerEvent("chatMessage", "Fixed ANPR", new int[] { 0, 191, 255 }, "Fixed ANPR plate focus: " + plate); } } }); string resourceName = API.GetCurrentResourceName(); string anprvehs = API.LoadResourceFile(resourceName, "anprvehicles.txt"); ANPRModels = anprvehs.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None).Select(x => new Model(x)).ToArray(); string fixedanprjson = API.LoadResourceFile(resourceName, "fixedanprcameras.json"); FixedANPRCameras = JsonConvert.DeserializeObject <FixedANPR[]>(fixedanprjson); Main(); }