Beispiel #1
0
        public void OutOfVehicle(OccupantSelector occupantselect)
        {
            GameFiber.StartNew(delegate
            {
                try
                {
                    Vehicle veh = Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).CurrentVehicle;
                    if (occupantselect == OccupantSelector.Driver)
                    {
                        if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).IsInAnyVehicle(false))
                        {
                            if (veh.IsBoat)
                            {
                                Functions.ForceEndCurrentPullover();
                                Vector3 pos = Suspect.GetBonePosition(0);
                                Suspect.Tasks.Clear();
                                Suspect.Position = pos;
                            }
                            else
                            {
                                Suspect.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(5000);
                                PedBackIntoVehicleLogic(Suspect, SuspectVehicle);
                            }
                            NativeFunction.Natives.RESET_PED_LAST_VEHICLE(Suspect);
                            API.Functions.OnPedOrderedOutOfVehicle(Suspect);

                            GameFiber.Wait(100);
                            Suspect.Tasks.StandStill(30000);
                            Functions.SetPedCantBeArrestedByPlayer(Suspect, true);
                            GameFiber.Yield();
                            Functions.SetPedCantBeArrestedByPlayer(Suspect, false);
                        }
                    }
                    else if (occupantselect == OccupantSelector.Passengers)
                    {
                        foreach (Ped pas in veh.Passengers)
                        {
                            if (veh.IsBoat)
                            {
                                Functions.ForceEndCurrentPullover();
                                Vector3 pos = pas.GetBonePosition(0);
                                pas.Tasks.Clear();
                                pas.Position = pos;
                            }
                            else
                            {
                                pas.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(6000);
                                PedBackIntoVehicleLogic(pas, SuspectVehicle);
                            }
                            NativeFunction.Natives.RESET_PED_LAST_VEHICLE(pas);
                            API.Functions.OnPedOrderedOutOfVehicle(pas);
                            GameFiber.Wait(100);
                            pas.Tasks.StandStill(30000);
                            Functions.SetPedCantBeArrestedByPlayer(pas, true);
                            GameFiber.Yield();
                            Functions.SetPedCantBeArrestedByPlayer(pas, false);
                        }
                    }
                    else if (occupantselect == OccupantSelector.AllOccupants)
                    {
                        foreach (Ped occ in veh.Occupants)
                        {
                            if (veh.IsBoat)
                            {
                                Functions.ForceEndCurrentPullover();
                                Vector3 pos = occ.GetBonePosition(0);
                                occ.Tasks.Clear();
                                occ.Position = pos;
                            }
                            else
                            {
                                occ.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(6000);
                                PedBackIntoVehicleLogic(occ, SuspectVehicle);
                            }
                            NativeFunction.Natives.RESET_PED_LAST_VEHICLE(occ);
                            API.Functions.OnPedOrderedOutOfVehicle(occ);
                            GameFiber.Wait(100);
                            occ.Tasks.StandStill(30000);
                            Functions.SetPedCantBeArrestedByPlayer(occ, true);
                            GameFiber.Yield();
                            Functions.SetPedCantBeArrestedByPlayer(occ, false);
                        }
                    }
                }
                catch (Exception e)
                {
                    Game.LogTrivial(e.ToString());
                    Game.LogTrivial("Error in getout handled - LSPDFR+");
                }
            });
        }