Exemplo n.º 1
0
        public static void MakePedFollowPlayer()
        {
            Blip PedBlip;

            GameFiber.StartNew(delegate
            {
                FollowingPed = GetNearestValidPed();
                if (!FollowingPed)
                {
                    return;
                }
                PedBlip       = FollowingPed.AttachBlip();
                PedBlip.Color = System.Drawing.Color.Yellow;

                PedBlip.Flash(400, -1);
                IsFollowingEnabled   = true;
                itemFollow.Title     = "Ask to Stop Following";
                itemCallTaxi.Enabled = false;
                itemGrab.Enabled     = false;

                if (EntryPoint.IsLSPDFRPlusRunning)
                {
                    API.LspdfrPlusFunctions.AddCountToStatistic(Main.PluginName, "People made to follow you");
                }
                while (FollowingPed.Exists())
                {
                    GameFiber.Yield();
                    if (!FollowingPed.Exists())
                    {
                        break;
                    }
                    if (IsFollowingEnabled)
                    {
                        if (Vector3.Distance(Game.LocalPlayer.Character.Position, FollowingPed.Position) > 2.3f)
                        {
                            var follow = FollowingPed.Tasks.FollowNavigationMeshToPosition(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeBack * 1.5f), FollowingPed.Heading, 1.6f);
                            follow.WaitForCompletion(600);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (FollowingPed.Exists())
                {
                    FollowingPed.Tasks.StandStill(7000);
                }
                IsFollowingEnabled = false;
                itemFollow.Title   = "Ask to Follow";
                if (PedBlip.Exists())
                {
                    PedBlip.Delete();
                }
                itemCallTaxi.Enabled = true;
                itemGrab.Enabled     = true;
            });
        }
Exemplo n.º 2
0
        public static void GrabPed()
        {
            Blip PedBlip;

            GameFiber.StartNew(delegate
            {
                pedfollowing = GetNearestValidPed();
                if (!pedfollowing)
                {
                    return;
                }

                EnableGrab           = true;
                GrabItem.Text        = "Let go";
                CallTaxiItem.Enabled = false;
                FollowItem.Enabled   = false;
                PedBlip                  = pedfollowing.AttachBlip();
                PedBlip.Color            = System.Drawing.Color.Yellow;
                GrabShortcutMessageShown = true;
                PedBlip.Flash(400, -1);
                pedfollowing.Rotation = Game.LocalPlayer.Character.Rotation;
                Game.LocalPlayer.Character.Tasks.PlayAnimation("doors@", "door_sweep_r_hand_medium", 9f, AnimationFlags.StayInEndFrame | AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly).WaitForCompletion(2000);

                if (EntryPoint.IsLSPDFRPlusRunning)
                {
                    API.LSPDFRPlusFuncs.AddCountToStatistic(EntryPoint.LSPDFRPlusSecurityGuid, "People grabbed");
                }
                pedfollowing.Tasks.ClearImmediately();

                NativeFunction.Natives.ATTACH_ENTITY_TO_ENTITY(pedfollowing, Game.LocalPlayer.Character, (int)PedBoneId.RightHand, 0.2f, 0.4f, 0f, 0f, 0f, 0f, true, true, false, false, 2, true);
                API.Functions.OnPlayerGrabbedPed(pedfollowing);
                while (true)
                {
                    GameFiber.Yield();
                    if (!pedfollowing.Exists())
                    {
                        break;
                    }
                    NativeFunction.Natives.ATTACH_ENTITY_TO_ENTITY(pedfollowing, Game.LocalPlayer.Character, (int)PedBoneId.RightHand, 0.2f, 0.4f, 0f, 0f, 0f, 0f, true, true, false, false, 2, true);
                    if (Game.LocalPlayer.Character.GetNearbyVehicles(1).Length > 0 && Functions.IsPedArrested(pedfollowing))
                    {
                        Vehicle nearestveh = Game.LocalPlayer.Character.GetNearbyVehicles(1)[0];

                        if (Game.LocalPlayer.Character.DistanceTo(nearestveh.Position) < 3.9f && nearestveh.PassengerCapacity >= 3)
                        {
                            int SeatToPutInto = 1;
                            if (Game.LocalPlayer.Character.DistanceTo(nearestveh.GetOffsetPosition(Vector3.RelativeLeft * 1.5f)) > Game.LocalPlayer.Character.DistanceTo(nearestveh.GetOffsetPosition(Vector3.RelativeRight * 1.5f)))
                            {
                                SeatToPutInto = 2;
                            }
                            if (nearestveh.IsSeatFree(SeatToPutInto))
                            {
                                Game.DisplayHelp("Press ~b~" + EntryPoint.kc.ConvertToString(PlacePedInVehicleKey) + "~s~ to place the suspect in the vehicle.");
                                if (Game.IsKeyDown(PlacePedInVehicleKey))
                                {
                                    if (nearestveh.GetDoors().Length > SeatToPutInto + 1)
                                    {
                                        NativeFunction.Natives.TASK_OPEN_VEHICLE_DOOR(Game.LocalPlayer.Character, nearestveh, 6000f, SeatToPutInto, 1.47f);
                                        int waitCount = 0;
                                        while (true)
                                        {
                                            GameFiber.Wait(1000);
                                            waitCount++;

                                            if (nearestveh.Doors[SeatToPutInto + 1].IsOpen || waitCount >= 6 || pedfollowing.IsInVehicle(nearestveh, false))
                                            {
                                                pedfollowing.Detach();
                                                GameFiber.Sleep(500);
                                                break;
                                            }
                                            if (pedfollowing.Exists())
                                            {
                                                if (!pedfollowing.IsDead)
                                                {
                                                    NativeFunction.Natives.TASK_OPEN_VEHICLE_DOOR(Game.LocalPlayer.Character, nearestveh, 6000f, SeatToPutInto, 1.47f);
                                                }
                                            }
                                        }
                                    }

                                    pedfollowing.Detach();
                                    pedfollowing.Tasks.EnterVehicle(nearestveh, 4000, SeatToPutInto).WaitForCompletion();
                                    if (!pedfollowing.IsInVehicle(nearestveh, false))
                                    {
                                        if (Game.LocalPlayer.Character.IsInVehicle(nearestveh, false) && Game.LocalPlayer.Character.SeatIndex == SeatToPutInto)
                                        {
                                            Game.LocalPlayer.Character.Tasks.ClearImmediately();
                                        }
                                        pedfollowing.WarpIntoVehicle(nearestveh, SeatToPutInto);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    //NativeFunction.Natives<uint>("SET_PLAYER_SPRINT", Game.LocalPlayer, false);
                    if (!NativeFunction.Natives.IS_ENTITY_PLAYING_ANIM <bool>(Game.LocalPlayer.Character, "doors@", "door_sweep_r_hand_medium", 3))
                    {
                        Game.LocalPlayer.Character.Tasks.PlayAnimation("doors@", "door_sweep_r_hand_medium", 9f, AnimationFlags.StayInEndFrame | AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly);
                    }
                    if (!EnableGrab || Game.LocalPlayer.Character.IsInAnyVehicle(false) || pedfollowing.IsInAnyVehicle(true) || Game.LocalPlayer.Character.DistanceTo(pedfollowing) > 4f)
                    {
                        break;
                    }
                }
                if (pedfollowing.Exists())
                {
                    if (!pedfollowing.IsInAnyVehicle(false))
                    {
                        pedfollowing.Detach();
                        pedfollowing.Tasks.StandStill(7000);
                    }
                }

                Game.LocalPlayer.Character.Tasks.ClearSecondary();
                EnableGrab    = false;
                GrabItem.Text = "Grab";
                if (PedBlip.Exists())
                {
                    PedBlip.Delete();
                }
                CallTaxiItem.Enabled = true;
                FollowItem.Enabled   = true;
            });
        }
Exemplo n.º 3
0
        public static void MakePedFollowPlayer()
        {
            Blip PedBlip;

            GameFiber.StartNew(delegate
            {
                pedfollowing = GetNearestValidPed();
                if (!pedfollowing)
                {
                    return;
                }
                PedBlip       = pedfollowing.AttachBlip();
                PedBlip.Color = System.Drawing.Color.Yellow;

                PedBlip.Flash(400, -1);
                EnableFollow         = true;
                FollowItem.Text      = "Stop follow";
                CallTaxiItem.Enabled = false;
                GrabItem.Enabled     = false;
                if (TransportToHospitalItem != null)
                {
                    TransportToHospitalItem.Enabled = false;
                }
                if (EntryPoint.IsLSPDFRPlusRunning)
                {
                    API.LSPDFRPlusFuncs.AddCountToStatistic(EntryPoint.LSPDFRPlusSecurityGuid, "People made to follow you");
                }
                while (pedfollowing.Exists())
                {
                    GameFiber.Yield();
                    if (!pedfollowing.Exists())
                    {
                        break;
                    }
                    if (EnableFollow)
                    {
                        if (Vector3.Distance(Game.LocalPlayer.Character.Position, pedfollowing.Position) > 2.3f)
                        {
                            FollowTask = pedfollowing.Tasks.FollowNavigationMeshToPosition(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeBack * 1.5f), pedfollowing.Heading, 1.6f);
                            FollowTask.WaitForCompletion(600);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (pedfollowing.Exists())
                {
                    pedfollowing.Tasks.StandStill(7000);
                }
                EnableFollow    = false;
                FollowItem.Text = "Follow";
                if (PedBlip.Exists())
                {
                    PedBlip.Delete();
                }
                CallTaxiItem.Enabled = true;
                GrabItem.Enabled     = true;
                if (TransportToHospitalItem != null)
                {
                    TransportToHospitalItem.Enabled = true;
                }
            });
        }