예제 #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();
                    }
                }
            }
        }
예제 #2
0
        public async void Main()
        {
            FixedANPR lastTriggeredANPRCamera     = null;
            DateTime  timeLastTriggeredANPRCamera = DateTime.Now;
            string    lastTriggeredDir            = "";

            FixedANPR LastBlockedFixedANPR = null;
            DateTime  timeLastBlockedANPR  = DateTime.Now;

            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 (BlipsCreated && !ANPRModels.Contains(playerVeh.Model))
                    {
                        RemoveANPRBlips();
                    }
                    else if (FixedANPRAlertsToggle && !BlipsCreated && ANPRModels.Contains(playerVeh.Model))
                    {
                        CreateFixedANPRBlips();
                    }

                    if (RouteBlip != null && RouteBlip.Exists() && Vector3.Distance(playerVeh.Position, RouteBlip.Position) < 140)
                    {
                        RouteBlip.ShowRoute = false;
                        RouteBlip           = null;
                    }

                    //Fixed ANPR Detection
                    if (playerVeh.Driver == Game.Player.Character && playerVeh.Speed > 0.2f)
                    {
                        string plate = API.GetVehicleNumberPlateText(playerVeh.Handle).Replace(" ", string.Empty);

                        if (PlateInfo.ContainsKey(plate))
                        {
                            FixedANPR anpr = FixedANPRCameras.OrderBy(x => Vector3.Distance(x.Location, playerVeh.Position)).FirstOrDefault();

                            if (anpr != null)
                            {
                                float  ZDiff = Math.Abs(anpr.Z - playerVeh.Position.Z);
                                string dir   = DegreesToCardinal(playerVeh.Heading);
                                if (Vector3.Distance(anpr.Location, playerVeh.Position) <= FixedANPRRadius && ZDiff < 3.5f && (lastTriggeredANPRCamera != anpr || (DateTime.Now - timeLastTriggeredANPRCamera).Seconds > 20 || lastTriggeredDir != dir))
                                {
                                    if ((anpr != LastBlockedFixedANPR || (DateTime.Now - timeLastTriggeredANPRCamera).Seconds > 120) && API.GetRandomIntInRange(0, 100) < ANPRHitChance)
                                    {
                                        //alert hit
                                        await Delay(1800);

                                        dir = DegreesToCardinal(playerVeh.Heading);
                                        string modelName = API.GetDisplayNameFromVehicleModel((uint)API.GetEntityModel(playerVeh.Handle));

                                        string colour = VehicleColour.GetVehicleColour(playerVeh.Handle).PrimarySimpleColourName;
                                        TriggerServerEvent("CameraTech:FixedANPRAlert", colour, modelName, anpr.Name, dir, plate);
                                        lastTriggeredANPRCamera     = anpr;
                                        timeLastTriggeredANPRCamera = DateTime.Now;
                                        lastTriggeredDir            = dir;
                                        LastBlockedFixedANPR        = null;
                                    }
                                    else
                                    {
                                        if (LastBlockedFixedANPR != anpr)
                                        {
                                            timeLastBlockedANPR = DateTime.Now;
                                        }
                                        LastBlockedFixedANPR = anpr;
                                    }
                                }
                            }
                        }
                    }
                }
                else if (BlipsCreated)
                {
                    RemoveANPRBlips();
                }
            }
        }