Exemple #1
0
        /// <summary>
        ///     Gate Control tick
        /// </summary>
        private static async Task GateControlTick()
        {
            try {
                if (!Session.HasJoinedRP)
                {
                    await BaseScript.Delay(5000);

                    return;
                }
                //Initialize gate locks
                if (!_initializedLocks)
                {
                    BaseScript.TriggerServerEvent("Gate.InitializeLocks");
                    _initializedLocks = true;
                }

                var playerPos = Cache.PlayerPos;
                //Active nearby gate
                if (_gateEntity != null)
                {
                    if (playerPos.DistanceToSquared2D(_gateEntity.Position) > 800f)
                    {
                        _gateEntity = null;
                        _gateTarget = Vector3.One;
                        return;
                    }

                    if (!PlayerHasPermission(_currentGate) && !_currentGate.IsBreached)
                    {
                        return;
                    }

                    var gateControlOffsetPosition =
                        new Vector3(_gateEntity.Position.X - 4f, _gateEntity.Position.Y - 1f, _gateEntity.Position.Z);
                    if (_gateEntity == null ||
                        !(playerPos.DistanceToSquared2D(gateControlOffsetPosition) < _currentGate.AccessRange))
                    {
                        return;
                    }

                    Screen.DisplayHelpTextThisFrame(
                        $"Press ~INPUT_THROW_GRENADE~ to {(_currentGate.IsLocked ? "~r~Unlock" : "~g~Lock")} Gate");
                    if (!Game.IsControlPressed(0, Control.ThrowGrenade))
                    {
                        return;
                    }

                    ToggleGateLock();
                }
                else
                {
                    SearchForNearbyGates(playerPos);
                }

                await BaseScript.Delay(1500);
            }
            catch (Exception ex) {
                Log.Error(ex);
            }
        }
Exemple #2
0
        public async Task MonitorSession(Session session, Client client)
        {
            while (session.IsConnected && !this.threads[session].Item2.Token.IsCancellationRequested)
            {
                await BaseScript.Delay(100);

                if (API.GetPlayerLastMsg(client.Handle.ToString()) <= this.Configuration.ConnectionTimeout)
                {
                    continue;
                }
                await this.Events.RaiseAsync(SessionEvents.SessionTimedOut, client, session);

                session.Disconnected = DateTime.UtcNow;
                Disconnecting(client, "Session Timed Out");
            }

            this.Logger.Debug("Starting reconnect grace checks");

            while (DateTime.UtcNow.Subtract(session.Disconnected ?? DateTime.UtcNow).TotalMilliseconds < this.Configuration.ReconnectGrace && !this.threads[session].Item2.Token.IsCancellationRequested)
            {
                await BaseScript.Delay(100);
            }

            this.sessions.TryTake(out session);
        }
        private async Task AFKCheckTick()
        {
            await BaseScript.Delay(60000);

            var currentLocation = Cache.PlayerPed.Position;

            if (currentLocation == previousLocation)
            {
                AFKTimer--;

                if (AFKTimer <= 5)
                {
                    Log.ToChat($"You will be kicked for AFK in {AFKTimer} minutes");
                }

                if (AFKTimer <= 0)
                {
                    Client.TriggerServerEvent("AFK.RequestKick");
                }
            }
            else
            {
                AFKTimer = 30;
            }

            previousLocation = currentLocation;
        }
Exemple #4
0
        private void CheckCanRobRegister([FromSource] Player source, string location)
        {
            var robberyModel = GetRobberyModel(location);
            List <Session.Session> copsOnDuty = Server.Instances.Jobs.GetPlayersOnJob(JobType.Police);

            Log.Verbose($"Checking if location {location} registers are robbable");
            if (robberyModel.TimesRobbed < 2 && copsOnDuty.Count >= robberyModel.RequiredPolice)
            {
                source.TriggerEvent("Robbery.StartRegisterRobbery", true);
                var nameSplit = robberyModel.LocationName.AddSpacesToCamelCase().Split(' ').ToList();
                nameSplit.Remove(nameSplit.Last());
                Server.Instances.Jobs.SendJobAlert(JobType.Police | JobType.EMS, "[Dispatch]", $"Silent Alarm | {string.Join(" ", nameSplit)} general store registers", ConstantColours.Dispatch);
                robberyModel.TimesRobbed += 1;
                Log.Verbose($"Location {location} registers are robbable new TimesRobbed count: {robberyModel.TimesRobbed}");
            }
            else
            {
                source.TriggerEvent("Robbery.StartRegisterRobbery", false);
                Log.ToClient("[Robbery]", "This register is unable to be robbed at this time", ConstantColours.Blue, source);
            }

            if (robberyModel.TimesRobbed >= 2)
            {
                //startRobberyCooldown(robberyModel);
                robberyModel.InRegisterCooldown = true;
                Task.Factory.StartNew(async() =>
                {
                    await BaseScript.Delay(robberyModel.CooldownTime);
                    robberyModel.TimesRobbed        = 0;
                    robberyModel.InRegisterCooldown = false;
                });
            }
        }
        public static async Task Speedrun()
        {
            Logger.Log("Executed SpeedCheck.", Logger.LogLevel.DEBUG);
            await BaseScript.Delay(0);

            int handle = Game.PlayerPed.Handle;

            if (Game.PlayerPed.ParachuteState != ParachuteState.None || API.GetPedParachuteState(handle) >= 0 || (Game.PlayerPed.IsFalling || Game.PlayerPed.IsInParachuteFreeFall) || API.IsPedFalling(handle))
            {
                API.SetEntityMaxSpeed(handle, 80f);
                if ((double)API.GetEntitySpeed(handle) > 80.0)
                {
                    //ViolationManager.SendViolation(ViolationType.PLAYER_SPEEDHACK);
                    Logger.Log("Detected Speed.", Logger.LogLevel.DEBUG);
                }
            }
            else
            {
                API.SetEntityMaxSpeed(handle, 7.1f);
                if ((double)API.GetEntitySpeed(handle) > 15.0 && !API.IsPedInAnyVehicle(handle, false))
                {
                    // ViolationManager.SendViolation(ViolationType.PLAYER_SPEEDHACK);
                    Logger.Log("Detected Speed.", Logger.LogLevel.DEBUG);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Equips this loadout with the specified options.
        /// </summary>
        /// <param name="taser">Whether or not to equip a TASER.</param>
        /// <param name="options">IPedCustomisables to set for the player.</param>
        public async void Equip(bool taser, IEnumerable <IPedCustomisable> options)
        {
            Model model = new Model(PedModelName);
            await model.Request(2000);

            if (model.IsLoaded)
            {
                await Game.Player.ChangeModel(model);

                foreach (IPedCustomisable pc in DefaultCustomisables)
                {
                    pc.SetPedCustomisable(Game.PlayerPed);
                    await BaseScript.Delay(50);
                }
                foreach (IPedCustomisable pc in options)
                {
                    pc.SetPedCustomisable(Game.PlayerPed);
                    await BaseScript.Delay(50);
                }

                Game.PlayerPed.Weapons.RemoveAll();
                foreach (WeaponHash hash in WeaponHashes)
                {
                    Game.PlayerPed.Weapons.Give(hash, -1, false, true);
                    await BaseScript.Delay(50);
                }
                if (taser)
                {
                    Game.PlayerPed.Weapons.Give(WeaponHash.StunGun, -1, false, true);
                }
            }
        }
Exemple #7
0
        private void makenetworked(Vehicle veh)
        {
            //////////
            ///
            ///  THANKS to Antivirus-chan in the FiveM community for supplying this code
            ///
            //////////
            //if (!veh.Model.IsLoaded) veh.Model.Request(-1);
            var net1     = API.VehToNet(veh.Handle);
            var attempts = 0;

            do
            {
                BaseScript.Delay(500);
                var netid = API.NetworkGetNetworkIdFromEntity(veh.Handle);
                API.NetworkRegisterEntityAsNetworked(veh.Handle);
                API.SetEntityAsMissionEntity(veh.Handle, false, false);
                API.SetNetworkIdCanMigrate(netid, true);
                API.SetNetworkIdExistsOnAllMachines(netid, true);
                API.NetworkRequestControlOfEntity(veh.Handle);
                attempts++;
            }while (!API.NetworkDoesEntityExistWithNetworkId(veh.Handle) && attempts < 20);
            if (attempts == 20 && !notified)
            {
                CitizenFX.Core.Debug.WriteLine("Failed to register entity on net");
                notified = true;
            }
            else if (!notified)
            {
                CitizenFX.Core.Debug.WriteLine($"Registered {veh.Handle} on net as {net1}");
                ELS.TriggerEvent("ELS:VehicleEntered");
                notified = true;
            }
        }
        private async void Functions()
        {
            if (ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
            {
                if (API.IsDisabledControlPressed(0, 24))
                {
                    if (!Pressed)
                    {
                        Pressed  = true;
                        Audio.Id = API.GetSoundId();
                        API.PlaySoundFrontend(Audio.Id, Audio.Slider, Audio.Library, true);
                        while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
                        {
                            await BaseScript.Delay(0);

                            var   res    = ScreenTools.ResolutionMaintainRatio;
                            float mouseX = API.GetDisabledControlNormal(0, 239) * res.Width;
                            mouseX         -= (Circle.Size.Width / 2);
                            Circle.Position = new PointF(mouseX > (Grid.Position.X + 10 + Grid.Size.Width - 40) ? (Grid.Position.X + 10 + Grid.Size.Width - 40) : ((mouseX < (Grid.Position.X + 20 - (Circle.Size.Width / 2))) ? (Grid.Position.X + 20 - (Circle.Size.Width / 2)) : mouseX), 0.5f);
                            var resultX = (float)Math.Round((Circle.Position.X - (Grid.Position.X + 20) + (Circle.Size.Width + 20)) / (Grid.Size.Width - 40), 2);
                            UpdateParent(((resultX >= 0.0f && resultX <= 1.0f) ? resultX : ((resultX <= 0f) ? 0.0f : 1.0f) * 2f) - 1f);
                        }
                        API.StopSound(Audio.Id);
                        API.ReleaseSoundId(Audio.Id);
                        Pressed = false;
                    }
                }
            }
        }
        // Async task to spawn the ped, so the menu thread is not blocked during loading
        // Make sure to wait for the ped to be in the memory. Custom peds may take a while to download, so the timeout (maxretries) is a bit longer
        // But it should eventually time out if ped cannot be loaded at all
        internal async Task ChangePlayerPed(string name)
        {
            uint model = (uint)GetHashKey(name);

            RequestModel(model);

            int maxretries = 0;

            while (!HasModelLoaded(model) && maxretries < 100)
            {
                await BaseScript.Delay(100);

                maxretries++;
            }

            if (HasModelLoaded(model))
            {
                SetPlayerModel(Game.Player.Handle, model);
                SetPedRandomComponentVariation(PlayerPedId(), false);
                SetPedRandomProps(PlayerPedId());
                Game.PlayerPed.Health = Game.PlayerPed.MaxHealth;
                Game.PlayerPed.Armor  = Game.Player.MaxArmor;
            }
            else
            {
                Common.DisplayNotification("Ped could not be loaded in time. Try again!");
            }
        }
Exemple #10
0
        private async Task <CallbackDelegate> OnAnimate(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Ped playerPed = Game.PlayerPed;

            API.RequestAnimDict("random");
            API.RequestAnimDict("random@arrests");
            API.RequestAnimDict("random@arrests@busted");

            DateTime timeout = DateTime.Now.AddSeconds(2);

            while (!API.HasAnimDictLoaded("random@arrests@busted") && DateTime.Now < timeout)
            {
                Trainer.DebugLine("Waiting for animation to load");
                await BaseScript.Delay(1);
            }

            Trainer.DebugLine(API.DoesAnimDictExist("random@arrests@busted") ? "Animation exists" : "Animation doesn't exist");

            if (!API.HasAnimDictLoaded("random@arrests@busted"))
            {
                callback("anim not found");
                return(callback);
            }

            API.TaskPlayAnim(playerPed.Handle, "random@arrests", "idle_2_hands_up", 8, -1, 10000, 0, 1, true, true, true);

            Trainer.DebugLine("Animating");

            callback("ok");
            return(callback);
        }
Exemple #11
0
        // source: https://github.com/TomGrobbe/vMenu/blob/master/vMenu/CommonFunctions.cs
        public static async Task <string> GetUserInput(string windowTitle, string defaultText, int maxInputLength)
        {
            // Create the window title string.
            var spacer = "\t";

            API.AddTextEntry($"{API.GetCurrentResourceName().ToUpper()}_WINDOW_TITLE", $"{windowTitle ?? "Enter"}:{spacer}(MAX {maxInputLength.ToString()} Characters)");

            // Display the input box.
            API.DisplayOnscreenKeyboard(1, $"{API.GetCurrentResourceName().ToUpper()}_WINDOW_TITLE", "", defaultText ?? "", "", "", "", maxInputLength);
            await BaseScript.Delay(0);

            // Wait for a result.
            while (true)
            {
                int keyboardStatus = API.UpdateOnscreenKeyboard();

                switch (keyboardStatus)
                {
                case 3:     // not displaying input field anymore somehow
                case 2:     // cancelled
                    return(null);

                case 1:     // finished editing
                    return(API.GetOnscreenKeyboardResult());

                default:
                    await BaseScript.Delay(0);

                    break;
                }
            }
        }
Exemple #12
0
        private async void spectatePlayer()
        {
            bool spectatePlayer = !isSpectating;

            CitizenFX.Core.UI.Screen.Fading.FadeOut(1500);
            while (CitizenFX.Core.UI.Screen.Fading.IsFadingOut)
            {
                await BaseScript.Delay(0);
            }

            if (spectatePlayer)
            {
                Vector3 targetCoords = _player.Character.Position;
                RequestCollisionAtCoord(targetCoords.X, targetCoords.Y, targetCoords.Z);
                NetworkSetInSpectatorMode(true, _player.Character.Handle);
                isSpectating = true;
                Log.ToChat($"Spectating {_player.Name}");
            }
            else
            {
                Vector3 targetCoords = Game.PlayerPed.Position;
                RequestCollisionAtCoord(targetCoords.X, targetCoords.Y, targetCoords.Z);
                NetworkSetInSpectatorMode(false, Game.PlayerPed.Handle);
                isSpectating = false;
                Log.ToChat($"Stopped spectating");
            }

            CitizenFX.Core.UI.Screen.Fading.FadeIn(1500);
        }
Exemple #13
0
        public async void ExecuteAsync(string query, IDictionary <string, object> parameters, CallbackDelegate callback, bool debug = false)
        {
            TResult   result    = default(TResult);
            Stopwatch stopwatch = new Stopwatch();

            try
            {
                stopwatch.Start();

                using (var connection = new NpgsqlConnection(ConnectionString))
                {
                    await connection.OpenAsync();

                    var ConnectionTime = stopwatch.ElapsedMilliseconds;
                    stopwatch.Restart();

                    using (var command = CreateCommand(query, parameters, connection))
                    {
                        var QueryTime = stopwatch.ElapsedMilliseconds;
                        stopwatch.Restart();

                        result = await ReaderAsync(command);

                        stopwatch.Stop();

                        if (debug)
                        {
                            Console.WriteLine(string.Format("[{0}] [C: {1}ms, Q: {2}ms, R: {3}ms] {4}", "Postgres", ConnectionTime, QueryTime, stopwatch.ElapsedMilliseconds, QueryToString(query, parameters)));
                        }
                        await BaseScript.Delay(0);

                        callback.Invoke(result);
                    }
                }
            }
            catch (AggregateException aggregateException)
            {
                var firstException = aggregateException.InnerExceptions.First();

                if (!(firstException is NpgsqlException))
                {
                    throw aggregateException;
                }

                CitizenFX.Core.Debug.Write(string.Format("[ERROR] [{0}] An error happens on Postgres for query \"{1}\": {2}\n", "Postgres", QueryToString(query, parameters), firstException.Message));
            }
            catch (NpgsqlException NpgsqlException)
            {
                CitizenFX.Core.Debug.Write(string.Format("[ERROR] [{0}] An error happens on Postgres for query \"{1}\": {2}\n", "Postgres", QueryToString(query, parameters), NpgsqlException.Message));
            }
            catch (ArgumentNullException)
            {
                CitizenFX.Core.Debug.Write(string.Format("[ERROR] [{0}] Check the error above, an error happens when executing the callback from the query : \"{1}\"\n", "Postgres", QueryToString(query, parameters)));
            }
            catch (Exception exception)
            {
                CitizenFX.Core.Debug.Write(string.Format("[ERROR] [{0}] An critical error happens on Postgres for query \"{1}\": {2} {3}\n", "Postgres", QueryToString(query, parameters), exception.Message, exception.StackTrace));
            }
        }
        public DevEnviroment(Client client) : base(client)
        {
            RegisterDevCommand("getmarker", cmd =>
            {
                var playerPos  = Game.PlayerPed.Position;
                var itemHeight = playerPos.Z;
                if (CitizenFX.Core.Native.API.IsValidInterior(CitizenFX.Core.Native.API.GetInteriorAtCoords(playerPos.X, playerPos.Y, playerPos.Z)))
                {
                    itemHeight -= 1.0f;
                }
                else
                {
                    itemHeight = World.GetGroundHeight(playerPos);
                }
                playerPos.Z = itemHeight + 0.04f;
                Log.ToChat($"The coordinates for this marker are {playerPos.ToObjectString()}");
                Log.Info(playerPos.ToObjectString());
                Log.ToServer(playerPos.ToObjectString());

                Task.Factory.StartNew(async() =>
                {
                    while (true)
                    {
                        await BaseScript.Delay(0);
                        World.DrawMarker(MarkerType.HorizontalCircleFat, playerPos, Vector3.Down, Vector3.Down, new Vector3(3, 3, 3), Color.FromArgb(140, ConstantColours.Yellow));
                    }
                });
            });
            RegisterDevCommand("goto", cmd =>
            {
                Game.PlayerPed.Position = new Vector3(Convert.ToSingle(cmd.GetArgAs(0, "0").Replace("f", "")), Convert.ToSingle(cmd.GetArgAs(1, "0").Replace("f", "")), Convert.ToSingle(cmd.GetArgAs(2, "0").Replace("f", "")));
            });
            RegisterDevCommand("getvehnetworkid", cmd =>
            {
                Log.ToChat(Cache.PlayerPed.CurrentVehicle.NetworkId.ToString());
            });
            RegisterDevCommand("printcoords", new Action <Command>(cmd =>
            {
                Log.Info($"new_Vector3({Game.PlayerPed.Position.ToString("0.00f")})"
                         .Replace("X", "")
                         .Replace("Y", "")
                         .Replace("Z", "")
                         .Replace(":", "")
                         .Replace(" ", ", ")
                         .Replace("_", " "));
                Log.ToServer($"new_Vector3({Game.PlayerPed.Position.ToString("0.00f")})"
                             .Replace("X", "")
                             .Replace("Y", "")
                             .Replace("Z", "")
                             .Replace(":", "")
                             .Replace(" ", ", ")
                             .Replace("_", " "));
            }));
            RegisterDevCommand("registerveh", OnRegisterVeh);
            RegisterDevCommand("listdata", OnListData);
            RegisterDevCommand("fix", OnFixVehicle);
            RegisterDevCommand("printvehid", OnPrintVehID);
            client.RegisterEventHandler("Dev.UI.SetEntityUIState", new Action <bool>(OnSetEntityUI));
        }
        static async Task RegularUpdates()
        {
            bool  currentRed = true;
            Color color;

            while (true)
            {
                try
                {
                    if (vehicle != null)
                    {
                        if (!Game.PlayerPed.IsInVehicle())
                        {
                            CivilianLights = CivilianCarSirenMode.None;
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Left, false);
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Right, false);
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Front, false);
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Back, false);
                            vehicle = null;
                            continue;
                        }

                        if (CivilianLights != CivilianCarSirenMode.None)
                        {
                            if (vehicle != Game.PlayerPed.CurrentVehicle)
                            {
                                CivilianLights = CivilianCarSirenMode.None;
                                vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Left, false);
                                vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Right, false);
                                vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Front, false);
                                vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Back, false);
                                vehicle = Game.PlayerPed.CurrentVehicle;
                                vehicle.Mods.InstallModKit();
                            }
                            if (currentRed)
                            {
                                color      = Color.FromArgb(255, 255, 0, 0);
                                currentRed = false;
                            }
                            else
                            {
                                color      = Color.FromArgb(255, 0, 0, 255);
                                currentRed = true;
                            }
                            vehicle.Mods.NeonLightsColor = color;
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Left, true);
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Right, true);
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Front, true);
                            vehicle.Mods.SetNeonLightsOn(VehicleNeonLight.Back, true);
                        }
                    }
                    await BaseScript.Delay((int)CivilianLights);
                }
                catch (Exception ex)
                {
                    Log.Error($"CivilianCarSirenLights error: {ex.Message}");
                }
            }
        }
        public async static Task DropBed(this Vehicle veh)
        {
            await Task.FromResult(0);

            if (veh.IsAlive)
            {
                if (!veh.IsEngineRunning)
                {
                    veh.IsEngineRunning = true;
                }
                veh.TurnOnIndicators();
                int soundId = Audio.PlaySoundFromEntity(veh, "Garage_Open", "CAR_STEAL_2_SOUNDSET");
                await BaseScript.Delay(500);

                float closeFloat = 0.03F;
                float openFloat  = 0.26F;

                switch ((int)veh.GetBoneCoord("engine").DistanceTo(veh.AttachDummyPos()))
                {
                case 6:
                case 7:
                case 8:
                case 9:
                {
                    float initPos = closeFloat;
                    do
                    {
                        ActivatePhysics(veh.Handle);
                        initPos += 0.0006F;
                        N_0xf8ebccc96adb9fb7(veh.Handle, initPos, false);
                        Game.DisableControlThisFrame(0, Control.VehicleMoveUpDown);
                        await BaseScript.Delay(1);
                    } while (!(initPos >= openFloat));
                    N_0xf8ebccc96adb9fb7(veh.Handle, openFloat, false);
                    break;
                }

                case 10:
                case 11:
                case 12:
                case 13:
                {
                    float initPos = openFloat;
                    do
                    {
                        ActivatePhysics(veh.Handle);
                        initPos -= 0.0006F;
                        N_0xf8ebccc96adb9fb7(veh.Handle, initPos, false);
                        Game.DisableControlThisFrame(0, Control.VehicleMoveUpDown);
                        await BaseScript.Delay(1);
                    } while (!(initPos <= closeFloat));
                    N_0xf8ebccc96adb9fb7(veh.Handle, closeFloat, false);
                    break;
                }
                }
                Audio.StopSound(soundId);
                veh.TurnOffIndicators();
            }
        }
Exemple #17
0
 public async Task DisableWanted()
 {
     if (Game.Player.WantedLevel > 0)
     {
         Game.Player.WantedLevel = 0;
     }
     await BaseScript.Delay(500);
 }
Exemple #18
0
        static internal async void CreateObjectAtPosition(ObjectHash objectHash, Vector3 position, Vector3 rotation)
        {
            CurrentObject = await World.CreatePropNoOffset(new Model((int)objectHash ), position, rotation, false);

            Function.Call(Hash.SET_ENTITY_DYNAMIC, CurrentObject.Handle, false);
            CurrentObject = null;
            Task.Factory.StartNew(async() => { await BaseScript.Delay(2000); FamilyRP.Roleplay.Client.UI.disableEntityUI = false; });
        }
Exemple #19
0
 internal async Task ClearScenarioGroups()
 {
     foreach (string scenarioGroup in this._scenarioGroups)
     {
         API.SetScenarioGroupEnabled(scenarioGroup, false);
     }
     await BaseScript.Delay(3000);
 }
Exemple #20
0
 internal async Task ClearScenarioTypes()
 {
     foreach (string scenarioType in this._scenarioTypes)
     {
         API.SetScenarioTypeEnabled(scenarioType, false);
     }
     await BaseScript.Delay(3000);
 }
Exemple #21
0
 internal async Task ClearDispatch()
 {
     for (int i = 0; i < 16; i++)
     {
         API.EnableDispatchService(i, false);
     }
     await BaseScript.Delay(1500);
 }
Exemple #22
0
 public static async Task RequestPtfxAsset(string name)
 {
     while (!API.HasNamedPtfxAssetLoaded(name))
     {
         API.RequestNamedPtfxAsset(name);
         await BaseScript.Delay(10);
     }
 }
Exemple #23
0
        public static async Task <bool> PlayReportAnim(Ped ped)
        {
            ped.Task.ClearAll();
            TaskStartScenarioInPlace(ped.Handle, "WORLD_HUMAN_STAND_MOBILE", 0, true);
            await BaseScript.Delay(3000);

            return(IsPedUsingScenario(ped.Handle, "WORLD_HUMAN_STAND_MOBILE"));
        }
Exemple #24
0
 static internal async void PeriodicRefresh()
 {
     while (true)
     {
         NearbyAnimals = PedList.Select(p => new Ped(p)).Where(p => HuntableModels.Contains(p.Model)).ToList();
         await BaseScript.Delay(5000);
     }
 }
Exemple #25
0
 static public async void PeriodicUpdate()
 {
     while (true)
     {
         RecalculateNearby();
         await BaseScript.Delay(5000);
     }
 }
Exemple #26
0
 public static async Task FadeScreenIn(int msec = 0)
 {
     Screen.Fading.FadeIn(msec);
     while (Screen.Fading.IsFadingIn)
     {
         await BaseScript.Delay(10);
     }
 }
Exemple #27
0
 public static async Task FadeScreenOut(int msec = 0)
 {
     Screen.Fading.FadeOut(msec);
     while (Screen.Fading.IsFadingOut)
     {
         await BaseScript.Delay(10);
     }
 }
Exemple #28
0
        private async void MechanicGetsOverWhelmedByFumes()
        {
            ShowSubtitle("[Military officer] Ooof... These fumes are not good, I do not feel well..", 10000);

            await BaseScript.Delay(2000);

            SetEntityHealth(SpawnedCivilianPeds[0].Handle, 0);
        }
Exemple #29
0
 public static async Task PerformRequest(int hash)
 {
     while (!Function.Call <bool>(Hash.HAS_MODEL_LOADED, hash))
     {
         Function.Call(Hash.REQUEST_MODEL, hash);
         await BaseScript.Delay(50);
     }
 }
        private async Task OnTick()
        {
            var date = DateTime.Now;

            API.NetworkOverrideClockTime(date.Hour, date.Minute, date.Second);

            await BaseScript.Delay(1000);
        }