Exemplo n.º 1
0
        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();
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void ReadPlateFront()
 {
     if (Game.Player != null && Game.Player.Character != null && Game.Player.Character.Exists() && Game.Player.Character.IsInVehicle() && Game.Player.Character.CurrentVehicle.Exists())
     {
         Vehicle   playerVeh   = Game.Player.Character.CurrentVehicle;
         Vector3   frontCoordA = playerVeh.GetOffsetPosition(new Vector3(0, 1, 0));
         Vector3   frontCoordB = playerVeh.GetOffsetPosition(new Vector3(0, 30, 0));
         ShapeTest stest       = ShapeTest.StartShapeTest(frontCoordA, frontCoordB, 7, playerVeh);
         if (stest.hit && API.IsEntityAVehicle(stest.hitEntity))
         {
             TriggerEvent("chatMessage", "Read Plate (Front)", new int[] { 0, 191, 255 }, API.GetVehicleNumberPlateText(stest.hitEntity).Trim() + ".");
         }
     }
 }
Exemplo n.º 3
0
        public async void RunChecks()
        {
            while (true)
            {
                await Delay(5);

                if (Game.Player != null && Game.Player.Character != null && Game.Player.Character.Exists() && Game.Player.Character.IsInVehicle() && Game.Player.Character.CurrentVehicle.Exists())
                {
                    Vehicle playerVeh = Game.Player.Character.CurrentVehicle;
                    if (!Active && ANPRvehicle != null && playerVeh == ANPRvehicle)
                    {
                        Active = true;
                        Screen.ShowNotification("Vehicle ANPR " + (Active ? "activated." : "deactivated."));
                    }

                    if (Active)
                    {
                        Vector3 frontCoord = playerVeh.GetOffsetPosition(new Vector3(0, raycastRadius - 0.5f, 0));

                        Vector3 frontCoordC = playerVeh.GetOffsetPosition(new Vector3(-raycastRadius + 0.1f, frontRange, 0));
                        CheckANPRShapeTest("Front ANPR (L)", ShapeTest.StartShapeTest(frontCoord, frontCoordC, raycastRadius, playerVeh), playerVeh, true);

                        Vector3 frontCoordD = playerVeh.GetOffsetPosition(new Vector3(raycastRadius - 0.1f, frontRange, 0));
                        CheckANPRShapeTest("Front ANPR (R)", ShapeTest.StartShapeTest(frontCoord, frontCoordD, raycastRadius, playerVeh), playerVeh, false);

                        Vector3 backCoord = playerVeh.GetOffsetPosition(new Vector3(0, -raycastRadius + 0.5f, 0));

                        Vector3 backCoordA = playerVeh.GetOffsetPosition(new Vector3(-raycastRadius + 0.1f, backRange, 0));
                        CheckANPRShapeTest("Rear ANPR (L)", ShapeTest.StartShapeTest(backCoord, backCoordA, raycastRadius, playerVeh), playerVeh, true);

                        Vector3 backCoordB = playerVeh.GetOffsetPosition(new Vector3(raycastRadius - 0.1f, backRange, 0));
                        CheckANPRShapeTest("Rear ANPR (R)", ShapeTest.StartShapeTest(backCoord, backCoordB, raycastRadius, playerVeh), playerVeh, false);
                    }
                }
                else if (Active)
                {
                    Active = false;
                    Screen.ShowNotification("Vehicle ANPR " + (Active ? "activated." : "deactivated."));
                }
            }
        }