Jump to content
Sixforty

Method to get suspect LVehicle reference during traffic stop?

Recommended Posts

I'd like to make a plugin that lets you call in peds' IDs during a traffic stop from inside your car, with more detailed information that just number of citations and active warrants. Some basic randomly chosen charges is the plan for now.

 

I've been looking through the API reference and I've found IsPlayerPerformingPullover, but I haven't found anything to get the currently stopped vehicle or ped. Is there any way to get a reference to either one of those?

Share this post


Link to post
Share on other sites

The current API does not allow you to explicitly retrieve the vehicle being pulled over, but the way alexslx suggested should work out. Let me know if you want the functionality being incorporated into the next release.


Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Share this post


Link to post
Share on other sites

alexslx, is right. I'd use GetOffsetPosition(), set it to 1,5 of length of a car to the front and search for a car in a radius of length of a car. You could also add some kind of maker which would tell the player if the car is detected or not.

Share this post


Link to post
Share on other sites

Thanks for the replies, I'll go ahead and do it that way then. Would the Vehicle returned by SHDN cast to LVehicle and reference the same instance the pullover script is using? I want to be sure I will have the correct instance so the ID my script uses is the same ID the ped gives the player.

 

LMS, what would be the possibility of getting a traffic stop/on foot ID check to fire an event that provides the PersonaData in a list? I could just hook a handler to it and not worry about the vehicle, and use it as a way to know if the player has actually checked for IDs or not.

Share this post


Link to post
Share on other sites

Thanks for the replies, I'll go ahead and do it that way then. Would the Vehicle returned by SHDN cast to LVehicle and reference the same instance the pullover script is using? I want to be sure I will have the correct instance so the ID my script uses is the same ID the ped gives the player.

 

LMS, what would be the possibility of getting a traffic stop/on foot ID check to fire an event that provides the PersonaData in a list? I could just hook a handler to it and not worry about the vehicle, and use it as a way to know if the player has actually checked for IDs or not.

 

I'll see what I can do.

 


Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Share this post


Link to post
Share on other sites

Are you okay with something like this?

                if (Functions.IsPlayerPerformingPullover())
                {
                    LHandle pullover = Functions.GetCurrentPullover();
                    if (pullover != null)
                    {
                        LVehicle vehicle = Functions.GetPulloverVehicle(pullover);
                        if (vehicle != null && vehicle.Exists())
                        {
                            vehicle.AttachBlip().Color = BlipColor.Cyan;
                            if (vehicle.HasDriver)
                            {
                                LPed driver = vehicle.GetPedOnSeat(VehicleSeat.Driver);
                                if (driver != null && driver.Exists())
                                {
                                    string name = driver.PersonaData.FullName;
                                    Functions.PrintText("--- Pulling over: " + name + " ---", 10000);

                                    // Looking up the driver will make the vehicle explode.
                                    Functions.PedLookedUpInPoliceComputer += delegate(PersonaData data)
                                        {
                                            if (data.FullName == name)
                                            {
                                                DelayedCaller.Call(parameter => vehicle.Explode(), this, Common.GetRandomValue(5000, 10000));
                                            }
                                        };
                                }
                            }
                        }
                    }
                }

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Share this post


Link to post
Share on other sites

 

Are you okay with something like this?

                if (Functions.IsPlayerPerformingPullover())
                {
                    LHandle pullover = Functions.GetCurrentPullover();
                    if (pullover != null)
                    {
                        LVehicle vehicle = Functions.GetPulloverVehicle(pullover);
                        if (vehicle != null && vehicle.Exists())
                        {
                            vehicle.AttachBlip().Color = BlipColor.Cyan;
                            if (vehicle.HasDriver)
                            {
                                LPed driver = vehicle.GetPedOnSeat(VehicleSeat.Driver);
                                if (driver != null && driver.Exists())
                                {
                                    string name = driver.PersonaData.FullName;
                                    Functions.PrintText("--- Pulling over: " + name + " ---", 10000);

                                    // Looking up the driver will make the vehicle explode.
                                    Functions.PedLookedUpInPoliceComputer += delegate(PersonaData data)
                                        {
                                            if (data.FullName == name)
                                            {
                                                DelayedCaller.Call(parameter => vehicle.Explode(), this, Common.GetRandomValue(5000, 10000));
                                            }
                                        };
                                }
                            }
                        }
                    }
                }

 

Yes that would work perfectly, thank you!

 

Share this post


Link to post
Share on other sites

 

Are you okay with something like this?

                if (Functions.IsPlayerPerformingPullover())
                {
                    LHandle pullover = Functions.GetCurrentPullover();
                    if (pullover != null)
                    {
                        LVehicle vehicle = Functions.GetPulloverVehicle(pullover);
                        if (vehicle != null && vehicle.Exists())
                        {
                            vehicle.AttachBlip().Color = BlipColor.Cyan;
                            if (vehicle.HasDriver)
                            {
                                LPed driver = vehicle.GetPedOnSeat(VehicleSeat.Driver);
                                if (driver != null && driver.Exists())
                                {
                                    string name = driver.PersonaData.FullName;
                                    Functions.PrintText("--- Pulling over: " + name + " ---", 10000);

                                    // Looking up the driver will make the vehicle explode.
                                    Functions.PedLookedUpInPoliceComputer += delegate(PersonaData data)
                                        {
                                            if (data.FullName == name)
                                            {
                                                DelayedCaller.Call(parameter => vehicle.Explode(), this, Common.GetRandomValue(5000, 10000));
                                            }
                                        };
                                }
                            }
                        }
                    }
                }

 

Looks good, my suggestions:

1) Make possible to modify the information before the player check the ID? so we can integrate other plugins with pullovers?

2) Make possible to disable pullovers (Functions.PlayerTogglePullovers(true/false)) -> I'm very bad with functions names.


[sharedmedia=downloads:files:6360]

Share this post


Link to post
Share on other sites

2) Make possible to disable pullovers (Functions.PlayerTogglePullovers(true/false)) -> I'm very bad with functions names.

 

I have no idea how reliable it would be, but could you use something like this in the script's Process()?

if(Functions.IsPlayerPerformingPullover() && bArePulloversDisabled)
    Functions.ForceEndPullover();

Setting bArePulloversDisabled = true whenever you'd want to "disable" them, and false otherwise?

Share this post


Link to post
Share on other sites

I have no idea how reliable it would be, but could you use something like this in the script's Process()?

if(Functions.IsPlayerPerformingPullover() && bArePulloversDisabled)
    Functions.ForceEndPullover();

Setting bArePulloversDisabled = true whenever you'd want to "disable" them, and false otherwise?

 

A global setting will be good, but I really think disabling pullover in a specific vehicle sounds good. For example, having a friend's (with a friendly ped) vehicle or something like that. Maybe checking if the vehicle driver have the group cop or the group special with the relationship "friendly" with cops solve that problem.


[sharedmedia=downloads:files:6360]

Share this post


Link to post
Share on other sites

Looks good, my suggestions:

1) Make possible to modify the information before the player check the ID? so we can integrate other plugins with pullovers?

2) Make possible to disable pullovers (Functions.PlayerTogglePullovers(true/false)) -> I'm very bad with functions names.

 

Sure.


Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...