Exemple #1
0
        private void OnDeleteVehicle(bool impound)
        {
            var closeVeh = GTAHelpers.GetClosestVehicle();

            if (closeVeh != null)
            {
                if (closeVeh.HasDecor("Vehicle.ID") /*&& JobHandler.OnDutyAsJob(JobType.Police)*/)
                {
                    var vehId = closeVeh.GetDecor <int>("Vehicle.ID");
                    if (vehId < 1000000 && JobHandler.OnDutyAsJob(JobType.Police))
                    {
                        if (impound)
                        {
                            Client.TriggerServerEvent("Vehicle.ImpoundVehicle", vehId);
                        }
                        closeVeh.Delete();
                    }
                    else if (vehId > 1000000)
                    {
                        closeVeh.Delete();
                    }
                }
                else
                {
                    closeVeh.Delete();
                }
            }
        }
Exemple #2
0
        private void OnGiveVehCommand(Command cmd)
        {
            var closeOwnedVeh = GetClosestOwnedVehicle();

            if (closeOwnedVeh != null)
            {
                var targetId = cmd.GetArgAs(0, 0);
                if (targetId == 0)
                {
                    var closestPlayer = GTAHelpers.GetClosestPlayer();
                    if (closestPlayer != null)
                    {
                        targetId = closestPlayer.ServerId;
                    }
                }
                else
                {
                    var closestPlayer = GTAHelpers.GetClosestPlayer();
                    if (closestPlayer.ServerId != targetId)
                    {
                        Log.ToChat("", "This person is not close enough to recieve the vehicle");
                        return;
                    }
                }

                if (targetId != 0 && targetId != Game.Player.ServerId)
                {
                    Client.TriggerServerEvent("Vehicle.GiveVehicleOwnership", closeOwnedVeh.GetDecor <int>("Vehicle.ID"), targetId);
                }
            }
        }
        private async Task onShooting()
        {
            if (rand.NextBool() && !checkingAlertStatus) // 50% chance
            {
                checkingAlertStatus = true;

                var closePed = GTAHelpers.GetCloestPed(512.0f, customFindFunc: o => !o.IsPlayer && !o.IsDead && o.IsHuman);
                if (closePed == null)
                {
                    return;
                }
                Log.Verbose("Found a close ped sending alert");

                var gender          = CitizenFX.Core.Native.API.IsPedMale(Cache.PlayerPed.Handle) ? "Male" : "Female";
                var currentLocation = GTAHelpers.GetLocationString();

                if (previousFireLocation == currentLocation)
                {
                    timesAlerted += 1;
                }

                previousFireLocation = currentLocation;

                if (timesAlerted >= 4)
                {
                    return;
                }

                Client.Instance.TriggerServerEvent("Alerts.SendCADAlert", $"10-32", $"{gender} firing a weapon", currentLocation);

                await BaseScript.Delay(rand.Next(2000, 10000));

                checkingAlertStatus = false;
            }
        }
        private async void StartVehicleLockpick(int lockpickType)
        {
            try
            {
                if (!isLockpicking)
                {
                    isLockpicking = true;
                    var targetVeh     = GTAHelpers.GetVehicleInFrontOfPlayer(3.0f);
                    var closeRegister = GTAHelpers.GetObjectInRange(ObjectHash.prop_till_01);
                    if (targetVeh != null)
                    {
                        Log.ToChat("", "You begin lockpicking the vehicle");
                        var chosenLockpick = (LockpickTypes)lockpickType;
                        await Game.PlayerPed.Task.PlayAnimation("missheistfbisetup1", "unlock_loop_janitor", 2.0f, 2.0f, -1, (AnimationFlags)49, 0);

                        await BaseScript.Delay(chosenLockpick == LockpickTypes.BobbyPin? 6250 : 5000);

                        var checkVeh = GTAHelpers.GetVehicleInFrontOfPlayer(3.0f);
                        if (targetVeh == checkVeh)
                        {
                            var shouldUnlock = chosenLockpick == LockpickTypes.BobbyPin ? rand.NextBool(30) : rand.NextBool(40) || chosenLockpick == LockpickTypes.SlimJim;
                            if (shouldUnlock)
                            {
                                Log.ToChat("[Robbery]", "You successfully lockpicked the vehicle", ConstantColours.Blue);
                                targetVeh.SetDecor("Vehicle.ID", -1);
                                targetVeh.LockStatus = VehicleLockStatus.Unlocked;
                                Client.TriggerServerEvent("Vehicle.CreateExternalVehicle", VehicleDataPacker.PackVehicleData(targetVeh));
                            }
                            else
                            {
                                Log.ToChat("[Robbery]", "You failed to lockpick the vehicle", ConstantColours.Blue);
                                setVehicleAlarm(targetVeh);
                                var breakPick = chosenLockpick == LockpickTypes.BobbyPin ? rand.NextBool(40) : rand.NextBool(20);
                                if (breakPick)
                                {
                                    string lockpickName = chosenLockpick == LockpickTypes.BobbyPin ? "bobby pin" : "lockpick";
                                    Log.ToChat("[Robbery]", $"Your {lockpickName} broke while trying to get into the vehicle", ConstantColours.Blue);
                                    //BaseScript.TriggerEvent("addInvItem", lockpickName.RemoveSpaces(), -1);
                                    Client.TriggerServerEvent("Inventory.AddInvItem", JsonConvert.SerializeObject(InventoryItems.GetInvItemData(lockpickName.RemoveSpaces())), -1);
                                }
                            }
                        }
                        else
                        {
                            Log.ToChat("", "You moved too far away from the vehicle");
                        }
                    }
                    else if (closeRegister != 0)
                    {
                        Client.Instances.RobberyHandler.AttemptRegisterRobbery();
                    }
                    else
                    {
                        Log.ToChat("", "There is nothing near you that can be lockpicked");
                    }
                    isLockpicking = false;
                    Game.PlayerPed.Task.ClearAll();
                }
            } catch (Exception e) { Log.Error(e); }
        }
        public async void AttemptRegisterRobbery()
        {
            var closeRegister = GTAHelpers.GetObjectInRange(ObjectHash.prop_till_01);
            var closeVault    = GetStoreInRange(20.0f);

            if (closeVault.Key != null && closeRegister != 0)
            {
                var robbalbe = await awaitRobResult("Robbery.CheckCanRobRegister", closeVault.Key);

                if (robbalbe)
                {
                    Log.ToChat("[Robbery]", "You begin lockpicking the cash register", ConstantColours.Blue);
                    await Game.PlayerPed.Task.PlayAnimation("missheistfbisetup1", "unlock_loop_janitor", 2.0f, 2.0f, -1, (AnimationFlags)49, 0);

                    await BaseScript.Delay(15000);

                    Log.ToChat("", "Hit the register to get the money from it");
                    Game.PlayerPed.Task.ClearAll();
                    while (!API.HasEntityBeenDamagedByAnyPed(closeRegister))
                    {
                        await BaseScript.Delay(0);
                    }
                    Client.TriggerServerEvent("Robbery.RequestRegisterPayment", closeVault.Key);
                }
            }
        }
Exemple #6
0
        private async void OnRefuelCommand(Command cmd)
        {
            var frontVeh = GTAHelpers.GetClosestVehicle();

            if (frontVeh != null)
            {
                if (!frontVeh.HasDecor("Vehicle.ID"))
                {
                    return;
                }

                var currentWeapon = Game.PlayerPed.Weapons.Current;
                if (currentWeapon.Hash == WeaponHash.PetrolCan)
                {
                    var weaponAmmo = currentWeapon.Ammo / 45;
                    var vehId      = frontVeh.GetDecor <int>("Vehicle.ID");
                    var netId      = CitizenFX.Core.Native.API.VehToNet(frontVeh.Handle);//frontVeh.NetworkId;

                    jerryCanAnimation.PlayFullAnim();
                    Client.TriggerServerEvent("Vehicle.OnManualRefuel", vehId, netId, weaponAmmo);
                }
                else
                {
                    PumpRefuel();
                }
            }
            else
            {
                Log.ToChat("[Fuel]", "You are not close enough to a vehicle to refuel it", ConstantColours.Fuel);
            }
        }
Exemple #7
0
        private void OnFindRevive()
        {
            var closestPlayer = GTAHelpers.GetClosestPlayer(4.0f);

            if (closestPlayer != null)
            {
                Client.TriggerServerEvent("Death.SendReviveTarget", closestPlayer.ServerId);
            }
        }
Exemple #8
0
        private void OnTowRequest()
        {
            var closeVeh = GTAHelpers.GetClosestVehicle(6.0f);

            if (closeVeh != null)
            {
                Client.TriggerServerEvent("Job.SendTowVehicle", $"{closeVeh.Mods.PrimaryColor.ToString().AddSpacesToCamelCase()} {closeVeh.LocalizedName} with plate {closeVeh.Mods.LicensePlate}");
            }
        }
Exemple #9
0
        private void OnFixVehicle()
        {
            var closeVeh = GTAHelpers.GetClosestVehicle();

            if (closeVeh != null)
            {
                closeVeh.Repair();

                Log.ToChat("[Job]", "Fixed vehicle", ConstantColours.Job);
            }
        }
Exemple #10
0
        public async void SetVehicleVehId(int vehId)
        {
            var closeVeh = GTAHelpers.GetClosestVehicle();

            while (closeVeh == null)
            {
                closeVeh = GTAHelpers.GetClosestVehicle();
                await BaseScript.Delay(0);
            }
            closeVeh.SetDecor("Vehicle.ID", vehId);
        }
Exemple #11
0
        private async void SetBoughtVehId(int vehId)
        {
            var closeVeh = GTAHelpers.GetClosestVehicle();

            while (closeVeh == null || closeVeh.HasDecor("Vehicle.IsPreviewVehicle"))
            {
                closeVeh = GTAHelpers.GetClosestVehicle();
                await BaseScript.Delay(0);
            }
            closeVeh.SetDecor("Vehicle.ID", vehId);
        }
Exemple #12
0
        private void OnSeizeVehItems(Command cmd)
        {
            if (JobHandler.OnDutyAsJob(JobType.Police))
            {
                var closeVeh = GTAHelpers.GetClosestVehicle(3.0f, o => o.HasDecor("Vehicle.ID"));

                if (closeVeh != null)
                {
                    Client.TriggerServerEvent("Items.SeizeVehicleItems", closeVeh.GetDecor <int>("Vehicle.ID"), string.Join(" ", cmd.Args));
                }
            }
        }
Exemple #13
0
        private async void OnInteraciton()
        {
            if (Cache.PlayerPed.IsInVehicle())
            {
                return;
            }

            if (!isInteracting || (DateTime.Now - lastInteraction).TotalSeconds > 15)
            {
                isInteracting = true;
                var closePed = GTAHelpers.GetCloestPed(customFindFunc: o => !o.IsPlayer && !o.IsDead && o.IsHuman && !o.IsInVehicle() && o.Position.DistanceToSquared(Game.PlayerPed.Position) < 3.0f);

                if (closePed != null && !interactedPeds.Contains(closePed))
                {
                    interactedPeds.Add(closePed);
                    var hasDrug   = false;
                    var drugName  = "";
                    var playerInv = await Client.LocalSession.GetInventory(false);

                    await drugInstance.currentDrugs.ForEachAsync(o =>
                    {
                        if (hasDrug)
                        {
                            return(Task.FromResult(0));
                        }

                        //Log.ToChat(o.ProcessDrugName);
                        if (playerInv.HasItem(o.ProcessDrugName))
                        {
                            hasDrug  = true;
                            drugName = o.ProcessDrugName;
                        }

                        return(Task.FromResult(0));
                    });

                    if (hasDrug)
                    {
                        closePed.Task.ClearAllImmediately();
                        closePed.Task.TurnTo(Cache.PlayerPed);
                        await BaseScript.Delay(1000);

                        closePed.Task.ClearAllImmediately();
                        closePed.Task.TurnTo(Cache.PlayerPed);
                        startDrugSell(closePed, drugName);
                        return;
                    }
                }

                isInteracting = false;
            }
        }
        private void FindVehTarget(string vehState)
        {
            var closestPlayer = GTAHelpers.GetClosestPlayer(6.0f);

            Log.ToChat($"You are going to do something with {closestPlayer?.Name}");

            if (closestPlayer == null || Game.PlayerPed.IsInVehicle() || CurrentCuffState != CuffState.None || CurrentDragState != DragState.None)
            {
                return;
            }

            Client.TriggerServerEvent("PutInVeh.SendVehPlayer", closestPlayer.ServerId, vehState);
        }
        private void FindCuffTarget(string cuffType)
        {
            var onDutyAsPolice = JobHandler.OnDutyAsJob(JobType.Police);

            var cloestPlayer = GTAHelpers.GetClosestPlayer(maxPickupRadius);;

            if (cloestPlayer == null || !onDutyAsPolice && (!IsEntityPlayingAnim(cloestPlayer.Character.Handle, "busted", "idle_a", 3) && cuffType != "EndCuff"))
            {
                return;
            }

            Log.ToChat("", $"Found cuff target for {cuffType}", Color.FromArgb(255, 255, 255));
            Client.TriggerServerEvent($"Cuff.{cuffType}", cloestPlayer.ServerId);
        }
        private void FindSearchTarget()
        {
            var onDutyAsPolice = JobHandler.OnDutyAsJob(JobType.Police);

            var cloestPlayer  = GTAHelpers.GetClosestPlayer(maxPickupRadius);
            var playerSession = Client.Instances.Session.GetPlayer(cloestPlayer);

            if (cloestPlayer == null || !onDutyAsPolice && (!IsEntityPlayingAnim(cloestPlayer.Character.Handle, "busted", "idle_a", 3) || GetCuffState(playerSession) < CuffState.SoftCuffed))
            {
                return;
            }

            Log.ToChat("", $"Found search target", Color.FromArgb(255, 255, 255));
            Client.TriggerServerEvent($"Search.SearchPlayer", cloestPlayer.ServerId);
        }
Exemple #17
0
        public Vehicle GetClosestVehicleWithKeys(float distance = 3.0f)
        {
            var closeVeh = GTAHelpers.GetClosestVehicle(distance);

            if (closeVeh != null && closeVeh.HasDecor("Vehicle.ID"))
            {
                var currentVehKeys = GetVehiclesWithKeys();
                if (currentVehKeys.Contains(closeVeh.GetDecor <int>("Vehicle.ID")))
                {
                    return(closeVeh);
                }
            }

            return(null);
        }
        private void FindDragTarget()
        {
            //if (!JobHandler.OnDutyAsJob(JobType.Police) && !JobHandler.OnDutyAsJob(JobType.EMS)) return;

            var cloestPlayer = GTAHelpers.GetClosestPlayer(maxPickupRadius);

            Log.Info(cloestPlayer?.Name);
            if (cloestPlayer == null)
            {
                return;
            }

            Log.ToChat("", $"Found drag target", Color.FromArgb(255, 255, 255));
            Magicallity.Client.Client.Instance.TriggerServerEvent($"Drag.StartDrag", cloestPlayer.ServerId);
        }
Exemple #19
0
        private void OnGiveCash(Command cmd)
        {
            var cashAmount = cmd.GetArgAs(0, 0);

            if (cashAmount < 0)
            {
                return;
            }

            var closePlayer = GTAHelpers.GetClosestPlayer(4.0f);

            if (closePlayer != null && closePlayer != Game.Player)
            {
                Client.TriggerServerEvent("Payment.GivePlayerCash", closePlayer.ServerId, cashAmount);
            }
        }
        /*private VehicleSeat getEmtptySeat(CitizenFX.Core.Vehicle playerVeh)
         * {
         *  for (var i = GetVehicleMaxNumberOfPassengers(playerVeh.Handle); i > -1; i--)
         *  {
         *      if(IsVehicleSeatFree(player))
         *  }
         * }*/

        private async void OnUpdateVehState(int newState)
        {
            var newVehState = (VehState)newState;//GetVehState(Client.LocalSession);

            if (newVehState == VehState.InVeh)
            {
                var playerPed = Cache.PlayerPed;
                var closeVeh  = GTAHelpers.GetClosestVehicle();
                while (closeVeh == null)
                {
                    await BaseScript.Delay(0);

                    closeVeh = GTAHelpers.GetClosestVehicle();
                }

                if (playerPed.IsAttached())
                {
                    playerPed.Detach();
                }

                playerPed.Task.ClearAllImmediately();

                foreach (var seat in Enum.GetValues(typeof(VehicleSeat)).Cast <VehicleSeat>().Reverse().ToList())
                //var maxPassengers = GetVehicleMaxNumberOfPassengers(closeVeh.Handle);
                //for (var i = maxPassengers; i > maxPassengers; i--)
                {
                    //var seat = (VehicleSeat)i;
                    //Log.ToServer($"Checking seat {seat}");
                    if (seat != VehicleSeat.Driver && seat != VehicleSeat.Any && closeVeh.IsSeatFree(seat))
                    {
                        //Log.ToServer($"Seat {seat} is free!");
                        var ticks = 0;
                        while (!playerPed.IsInVehicle(closeVeh) && ticks < 10)
                        {
                            //Log.ToServer($"Attempting to enter seat {seat}");
                            playerPed.Task.WarpIntoVehicle(closeVeh, seat);
                            ticks++;
                            await BaseScript.Delay(200);
                        }
                    }
                }
            }
            else
            {
                Game.PlayerPed.Task.LeaveVehicle();
            }
        }
        private void OnPrintVehID(Command cmd)
        {
            var closeVeh = Cache.PlayerPed.CurrentVehicle;

            if (closeVeh == null)
            {
                closeVeh = GTAHelpers.GetClosestVehicle(6.0f);
            }

            if (closeVeh == null || !closeVeh.HasDecor("Vehicle.ID"))
            {
                Log.ToChat("No vehicle with a ID found nearby");
                return;
            }

            Log.ToChat(closeVeh.GetDecor <int>("Vehicle.ID").ToString());
        }
Exemple #22
0
        private async void OnVehicleRepair()
        {
            var closeVeh = GTAHelpers.GetClosestVehicle();

            if (closeVeh != null)
            {
                Log.ToChat("[Inventory]", "Repairing vehicle", ConstantColours.Inventory);
                EmoteManager.playerAnimations["mechanic"].PlayFullAnim();

                await BaseScript.Delay(new Random((int)DateTime.Now.Ticks).Next(3500, 7500));

                var playerInv = await LocalSession.GetInventory();

                if (closeVeh.Position.DistanceToSquared(Game.PlayerPed.Position) < Math.Pow(3, 2) && playerInv.HasItem("RepKit"))
                {
                    if (closeVeh.EngineHealth < 150)
                    {
                        closeVeh.EngineHealth = 150;
                    }

                    if (closeVeh.BodyHealth < 150)
                    {
                        closeVeh.BodyHealth = 150;
                    }

                    SetVehicleTyreFixed(closeVeh.Handle, 0);
                    SetVehicleTyreFixed(closeVeh.Handle, 1);
                    SetVehicleTyreFixed(closeVeh.Handle, 2);
                    SetVehicleTyreFixed(closeVeh.Handle, 3);
                    SetVehicleTyreFixed(closeVeh.Handle, 4);
                    SetVehicleTyreFixed(closeVeh.Handle, 5);

                    Log.ToChat("[Inventory]", "Vehicle repaired", ConstantColours.Inventory);

                    Client.TriggerServerEvent("Inventory.AddInvItem", JsonConvert.SerializeObject(playerInv.GetItem("RepKit")), -1);
                }
                else
                {
                    Log.ToChat("[Inventory]", "You moved to far away from the vehicle", ConstantColours.Inventory);
                }

                EmoteManager.playerAnimations["mechanic"].End(Game.PlayerPed);
            }
        }
Exemple #23
0
        public Vehicle GetClosestOwnedVehicle(float distance = 3.0f)
        {
            var closeVeh = Cache.PlayerPed.CurrentVehicle ?? GTAHelpers.GetClosestVehicle(distance);

            if (closeVeh != null)
            {
                if (!closeVeh.HasDecor("Vehicle.ID"))
                {
                    return(null);
                }

                var currentVehKeys = GetOwnedVehicles();
                if (currentVehKeys.Contains(closeVeh.GetDecor <int>("Vehicle.ID")))
                {
                    return(closeVeh);
                }
            }

            return(null);
        }
        private void OnRegisterVeh(Command cmd)
        {
            var closeVeh = Cache.PlayerPed.CurrentVehicle;

            if (closeVeh == null)
            {
                closeVeh = GTAHelpers.GetClosestVehicle(6.0f);
            }

            if (closeVeh == null)
            {
                Log.ToChat("No vehicle found nearby");
                return;
            }

            closeVeh.LockStatus = VehicleLockStatus.Unlocked;
            Client.TriggerServerEvent("Vehicle.CreateExternalVehicle", VehicleDataPacker.PackVehicleData(closeVeh));

            Log.ToChat("Registered and unlocked the closest vehicle to you");
        }
        private async void attemptPedReport(Vehicle veh, bool shouldUnlock)
        {
            var vehColour = veh.Mods.PrimaryColor.ToString().AddSpacesToCamelCase();
            var vehName   = veh.LocalizedName;
            var vehPlate  = veh.Mods.LicensePlate;
            var location  = GTAHelpers.GetLocationString();

            var visiblePed = getPedInRange();

            if (visiblePed == null)
            {
                return;
            }

            var sendReport = await GTAHelpers.PlayReportAnim(visiblePed);

            if (sendReport)
            {
                Client.TriggerServerEvent("Alerts.SendCADAlert", $"10-61{(shouldUnlock ? "" : "A")}", $"{vehColour} {vehName} | {vehPlate}", location);
            }
        }
Exemple #26
0
        private void handleTowCommand(Command cmd)
        {
            if (!JobHandler.OnDutyAsJob(JobType.Tow) || Cache.PlayerPed.IsInVehicle())
            {
                return;
            }

            var frontVeh = GTAHelpers.GetClosestVehicle(12.0f, veh => veh != currentTowTruck);

            if (frontVeh == null || currentTowTruck == null)
            {
                return;
            }

            if (frontVeh.ClassType == VehicleClass.Helicopters || frontVeh.ClassType == VehicleClass.Military || frontVeh.ClassType == VehicleClass.Trains || frontVeh.Occupants.Length > 0)
            {
                return;
            }

            if (towedVehicle != null && !Game.PlayerPed.IsInVehicle() && Game.PlayerPed.Position.DistanceToSquared(towedVehicle.Position) < 16.0f)
            {
                towedVehicle.AttachTo(currentTowTruck, new Vector3(-0.5f, -12, 0));
                towedVehicle.Detach();
                towedVehicle = null;
                return;
            }

            if (frontVeh.Model.Hash == (int)VehicleHash.Flatbed)
            {
                return;
            }

            if (frontVeh != currentTowTruck)
            {
                towedVehicle = frontVeh;
                towedVehicle.AttachTo(currentTowTruck, new Vector3(0, -2.5f, 0.85f));
                towedVehicle.AttachedBlips.ToList().ForEach(o => o.Delete());
            }
        }
Exemple #27
0
        private void ToggleVehicleDoor(VehicleDoorIndex vehDoorIndex)
        {
            var closeVeh = GTAHelpers.GetClosestVehicle();

            if (closeVeh?.LockStatus != VehicleLockStatus.Unlocked)
            {
                closeVeh = Client.Get <VehicleHandler>().GetClosestVehicleWithKeys(6.0f);
            }

            if (closeVeh != null && closeVeh.HasDecor("Vehicle.ID"))
            {
                var vehDoor = closeVeh.Doors[vehDoorIndex];

                if (vehDoor.IsOpen)
                {
                    vehDoor.Close();
                }
                else
                {
                    vehDoor.Open();
                }
            }
        }
 public override Action <MenuItemSubMenu> GetOnActivateFunction()
 {
     return(item =>
     {
         RefreshMenu("");
         var closeOwnedVeh = Client.Instance.Get <JobHandler>().OnDutyAsJob(JobType.Police) ? GTAHelpers.GetClosestVehicle(3.0f, o => o.HasDecor("Vehicle.ID")) : Client.Instance.Get <VehicleHandler>().GetClosestVehicleWithKeys();
         if (closeOwnedVeh != null)
         {
             Client.Instance.TriggerServerEvent("Inventory.RequestInventory", closeOwnedVeh.GetDecor <int>("Vehicle.ID"));
         }
     });
 }
        private void AttemptEnterVehicle(Vehicle veh)
        {
            var robAttempts = veh.HasDecor("Vehicle.RobAttempts") ? veh.GetDecor <int>("Vehicle.RobAttempts") : 0;

            if (veh.HasDecor("Vehicle.ID"))
            {
                return;
            }

            veh.LockStatus = VehicleLockStatus.Locked;

            if (robAttempts > 1)
            {
                return;
            }

            veh.SetDecor("Vehicle.RobAttempts", robAttempts + 1);

            var isCarjacking = veh.Occupants.ToList().Count > 0;

            if (isCarjacking)
            {
                var deadDriver   = veh.Driver.IsDead;
                var shouldUnlock = rand.NextBool(carJackChance);
                if (shouldUnlock)
                {
                    veh.LockStatus = VehicleLockStatus.Unlocked;
                    Client.TriggerServerEvent("Vehicle.CreateExternalVehicle", VehicleDataPacker.PackVehicleData(veh));
                }

                var vehColour = veh.Mods.PrimaryColor.ToString().AddSpacesToCamelCase();
                var vehName   = veh.LocalizedName;
                var vehPlate  = veh.Mods.LicensePlate;
                var location  = GTAHelpers.GetLocationString();

                if (veh.HasDecor("Vehicle.HasBeenAlerted"))
                {
                    return;
                }

                veh.SetDecor("Vehicle.HasBeenAlerted", true);

                if (deadDriver)
                {
                    attemptPedReport(veh, shouldUnlock);
                }
                else
                {
                    if (rand.NextBool(40))
                    {
                        return;
                    }

                    Client.TriggerServerEvent("Alerts.SendCADAlert", $"10-61{(shouldUnlock ? "" : "A")}", $"{vehColour} {vehName} | {vehPlate}", location);
                }
            }
            else
            {
                var shouldUnlock = rand.NextBool(parkedCarChance);
                if (shouldUnlock)
                {
                    veh.LockStatus = VehicleLockStatus.Unlocked;
                    Client.TriggerServerEvent("Vehicle.CreateExternalVehicle", VehicleDataPacker.PackVehicleData(veh));
                }

                attemptPedReport(veh, shouldUnlock);
            }
        }
Exemple #30
0
 private void OnUpdateLocation()
 {
     Client.Instance.TriggerServerEvent("Session.UpdateLocation", GTAHelpers.GetLocationString());
 }