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);
            }
        }
예제 #2
0
        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); }
        }
예제 #3
0
        private async Task SaveVehicleTick()
        {
            await BaseScript.Delay(saveInterval);

            await ownedVehicles.ForEachAsync(async o =>
            {
                if (!o.IsDead)
                {
                    Client.TriggerServerEvent("Vehicles.UpdateVehicleData", o.GetDecor <int>("Vehicle.ID"), VehicleDataPacker.PackVehicleData(o));
                }

                await BaseScript.Delay(0);
            });
        }