Exemplo n.º 1
0
        private static void MainLogic()
        {
            GameFiber.StartNew(() =>
            {
                while (true)
                {
                    GameFiber.Yield();

                    if ((ExtensionMethods.IsKeyDownRightNowComputerCheck(EntryPoint.SceneManagementModifierKey) || (EntryPoint.SceneManagementModifierKey == Keys.None)) && ExtensionMethods.IsKeyDownComputerCheck(EntryPoint.SceneManagementKey))
                    {
                        ManagementMenu.Visible = !ManagementMenu.Visible;
                    }

                    if (_menuPool.AreAnyVisible)
                    {
                        NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0);
                    }
                    else if ((ExtensionMethods.IsKeyDownRightNowComputerCheck(GrabPedModifierKey) || GrabPedModifierKey == Keys.None) && ExtensionMethods.IsKeyDownComputerCheck(GrabPedKey))
                    {
                        if (!IsGrabEnabled)
                        {
                            GrabPed();
                        }
                        else
                        {
                            IsGrabEnabled = false;
                        }
                    }

                    if (Game.LocalPlayer.Character.SubmersionLevel < 0.2 && (ExtensionMethods.IsKeyDownComputerCheck(TackleKey) || Game.IsControllerButtonDown(TackleButton)) && Game.LocalPlayer.Character.Speed >= 5.3f)
                    {
                        var nearestPed = GetNearestValidPed(2f, true, false, false, -1);
                        if (nearestPed && !Functions.IsPedArrested(nearestPed) && !Functions.IsPedGettingArrested(nearestPed))
                        {
                            Game.LocalPlayer.Character.IsRagdoll = true;
                            nearestPed.IsRagdoll = true;
                            GameFiber.Sleep(500);
                            Game.LocalPlayer.Character.IsRagdoll = false;
                            GameFiber.Wait(2000);
                            nearestPed.IsRagdoll = false;
                        }
                    }

                    if (CallCoronerTime)
                    {
                        Coroner.Main();
                        CallCoronerTime = false;
                    }
                }
            });
        }
Exemplo n.º 2
0
        private static void MainLogic()
        {
            GameFiber.StartNew(delegate
            {
                while (true)
                {
                    GameFiber.Yield();

                    if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownRightNowComputerCheck(EntryPoint.SceneManagementModifierKey) || (EntryPoint.SceneManagementModifierKey == Keys.None))
                    {
                        if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(EntryPoint.SceneManagementKey))
                        {
                            if (ActiveMenu != null)
                            {
                                ActiveMenu.Visible = !ActiveMenu.Visible;
                            }
                            else
                            {
                                PedManagementMenu.Visible = !PedManagementMenu.Visible;
                            }
                        }
                    }
                    if (_menuPool.IsAnyMenuOpen())
                    {
                        Rage.Native.NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0);
                    }
                    else if ((Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownRightNowComputerCheck(GrabPedModifierKey) || GrabPedModifierKey == Keys.None) && Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(GrabPedKey))
                    {
                        if (!EnableGrab)
                        {
                            PedManager.GrabPed();
                        }
                        else
                        {
                            EnableGrab = false;
                        }
                    }


                    //if ped is in water offer proper arresting mechanism

                    else if (Game.LocalPlayer.Character.SubmersionLevel > 0.2 && Game.IsControlPressed(2, GameControl.Context) && (nearestWaterPed = PedManager.GetNearestValidPed(6f, true, -1)).Exists() && !Functions.IsPedArrested(nearestWaterPed) && nearestWaterPed.SubmersionLevel > 0.2)
                    {
                        arrestBarDisplayTime = true;
                        Functions.SetPedCantBeArrestedByPlayer(nearestWaterPed, true);
                        arrestBar.Percentage += 0.03f;
                        if (arrestBar.Percentage > 0.99)
                        {
                            nearestWaterPed.Tasks.ClearImmediately();
                            ArrestPed(nearestWaterPed);
                            arrestBarDisplayTime = false;
                            arrestBar.Percentage = 0;
                        }
                    }
                    else
                    {
                        arrestBarDisplayTime = false;
                        arrestBar.Percentage = 0;
                        if (nearestWaterPed && !Functions.IsPedArrested(nearestWaterPed))
                        {
                            Functions.SetPedCantBeArrestedByPlayer(nearestWaterPed, false);
                        }
                    }

                    if (Game.LocalPlayer.Character.SubmersionLevel < 0.2 && (ExtensionMethods.IsKeyDownComputerCheck(PedManager.TackleKey) || Game.IsControllerButtonDown(TackleButton)) && Game.LocalPlayer.Character.Speed >= 5.3f)
                    {
                        nearestPed = PedManager.GetNearestValidPed(2f, true, -1);
                        if (nearestPed && !Functions.IsPedArrested(nearestPed) && !Functions.IsPedGettingArrested(nearestPed))
                        {
                            Game.LocalPlayer.Character.IsRagdoll = true;
                            nearestPed.IsRagdoll = true;
                            GameFiber.Sleep(500);
                            Game.LocalPlayer.Character.IsRagdoll = false;
                            GameFiber.Wait(2000);
                            nearestPed.IsRagdoll = false;
                        }
                    }

                    foreach (Ped suspect in SuspectsManuallyArrested.ToArray())
                    {
                        if (suspect.Exists())
                        {
                            if (!NativeFunction.Natives.IS_ENTITY_PLAYING_ANIM <bool>(suspect, "mp_arresting", "idle", 3))
                            {
                                suspect.Tasks.PlayAnimation("mp_arresting", "idle", 8f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                            }
                        }
                        else
                        {
                            SuspectsManuallyArrested.Remove(suspect);
                        }
                    }

                    if (callCoronerTime)
                    {
                        Coroner.Main();
                        callCoronerTime = false;
                    }
                }
            });
        }