Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Setting Ped as Drunk? [SOLVED]

Featured Replies

What am I doing wrong here? I'm trying to make it so if someone breathalyze's a suspect in this callout with TrafficPolicer then it reads off they're drunk. In the following code from PublicIntoxication.cs it says "IsLSPDFRPluginRunning" and the error in VS says that the name does not exist in its current context. How can I fix this?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rage;
using Rage.Native;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Engine.Scripting.Entities;
using Traffic_Policer;
using Traffic_Policer.Impairment_Tests;

namespace ToastyCallouts.Callouts
{
    [CalloutInfo("PublicIntoxication", CalloutProbability.Medium)]

    public class PublicIntoxication : Callout
    {
        public EVehicleBlockingTrafficState state;
        public Vector3 SpawnPoint;
        public Blip myBlip;
        public Ped mySuspect;

        public override bool OnBeforeCalloutDisplayed()
        {
            SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(1000f));
            Game.LogTrivial("Create SpawnPoint.");

            mySuspect = new Ped(SpawnPoint);
            mySuspect.IsPersistent = true;
            mySuspect.BlockPermanentEvents = true;
            mySuspect.Armor = 69;
            if (IsLSPDFRPluginRunning("Traffic Policer", new Version("6.8.0.0")))
            {
                TrafficPolicerFunctions.SetPedDrugsLevels(mySuspect, true, true); //Wrapper Method
            }

 

Main.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Rage;
using Rage.Native;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Engine.Scripting.Entities;
using ToastyCallouts.Callouts;
using ToastyCallouts;
using Traffic_Policer;
using System.Reflection;
using System.Drawing;

public class Main : Plugin
{
    public override void Initialize()
    {
        Functions.OnOnDutyStateChanged += OnOnDutyStateChangedHandler;
        Game.LogTrivial("Plugin Unlimited Callouts " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " has been initialised.");
        Game.LogTrivial("Go on duty to fully load Unlimited Callouts.");
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LSPDFRResolveEventHandler);
        Settings.LoadSettings();
    }
    public static Assembly LSPDFRResolveEventHandler(object sender, ResolveEventArgs args)
    {
        foreach (Assembly assembly in Functions.GetAllUserPlugins())
        {
            if (args.Name.ToLower().Contains(assembly.GetName().Name.ToLower()))
            {
                return assembly;
            }
        }
        return null;
    }
    public static bool IsLSPDFRPluginRunning(string Plugin, Version minversion = null)
    {
        foreach (Assembly assembly in Functions.GetAllUserPlugins())
        {
            AssemblyName an = assembly.GetName();
            if (an.Name.ToLower() == Plugin.ToLower())
            {
                if (minversion == null || an.Version.CompareTo(minversion) >= 0)
                {
                    return true;
                }
            }
        }

 

TrafficPolicerAPIFunctions.cs:

using Traffic_Policer;
using Traffic_Policer.API;
using Rage;
using System;
using Traffic_Policer.Impairment_Tests;

static class TrafficPolicerFunctions
{
    public static bool IsVehicleInsured(Vehicle veh)
    {
        return Traffic_Policer.API.Functions.IsVehicleInsured(veh);
    }
    public static void DisplayInsuranceStatusForVehicle(Vehicle veh)
    {
        bool insurancestatus = IsVehicleInsured(veh);
        switch (insurancestatus)
        {
            case true:
                Game.DisplayNotification("~b~Mors Mutual Insurance Status: ~g~INSURED");
        break;
            case false:
                Game.DisplayNotification("~b~Mors Mutual Insurance Status: ~r~UNINSURED");
        break;

        }
    }
    public static void SetPedDrugsLevels(Ped ped, bool Cannabis, bool Cocaine)
    {

        Traffic_Policer.API.Functions.SetPedDrugsLevels(ped, Cannabis, Cocaine);
    }
    public static void SetPedAsDrunk(Ped ped)
    {
        SetPedAsDrunk(ped);
        SetPedAlcoholLevel(ped, Functions.GetRandomOverTheLimitAlcoholLevel());
    }
    private static void SetPedAlcoholLevel(Ped ped, AlcoholLevels alcoholLevels)
    {
        Functions.GetRandomOverTheLimitAlcoholLevel();
    }
}

 

 

Thank you for any and all help! <3

Edited by ToastinYou

I could be wrong, but I think you might just need to add a using ToastyCallouts; to your callout script so that it can see the function from Main.cs

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

9 hours ago, ToastinYou said:

private static void SetPedAlcoholLevel(Ped ped, AlcoholLevels alcoholLevels) { Functions.GetRandomOverTheLimitAlcoholLevel(); }

Delete this method, it's useless and can cause issues due to taking a custom enum.

Edited by Albo1125

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

  • Author
3 hours ago, Darkmyre said:

I could be wrong, but I think you might just need to add a using ToastyCallouts; to your callout script so that it can see the function from Main.cs

Still doesn't work :/

 

2 hours ago, Albo1125 said:

Delete this method, it's useless and can cause issues due to taking a custom enum.

Now SetPedAlcoholLevel says it doesn't exist in current context..

    public static void SetPedAsDrunk(Ped ped)
    {
        SetPedAsDrunk(ped);
        SetPedAlcoholLevel(ped, Functions.GetRandomOverTheLimitAlcoholLevel());
    }

 

2 hours ago, ToastinYou said:

Now SetPedAlcoholLevel says it doesn't exist in current context..

You need to call the Traffic Policer function directly..

public static void SetPedAsDrunk(Ped ped)
    {
        
        Functions.SetPedAlcoholLevel(ped, Functions.GetRandomOverTheLimitAlcoholLevel());
    }

 

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

  • Author
On 6/8/2016 at 11:19 AM, Albo1125 said:

You need to call the Traffic Policer function directly..


public static void SetPedAsDrunk(Ped ped)
    {
        
        Functions.SetPedAlcoholLevel(ped, Functions.GetRandomOverTheLimitAlcoholLevel());
    }

 

Sorry for the late reply, been working on other things. This did work, but I'm still getting the same error for IsLSPDFRPluginRunning (doesn't exist in current context). Shouldn't it be using the method created in Main.cs or do I have to create one in the callout.cs itself? Because the one from Main.cs doesn't seem to be connecting. Thank you by the way.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rage;
using Rage.Native;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Engine.Scripting.Entities;
using Traffic_Policer;
using Traffic_Policer.Impairment_Tests;
using ToastyCallouts;

namespace ToastyCallouts.Callouts
{
    [CalloutInfo("PublicIntoxication", CalloutProbability.Medium)]

    public class PublicIntoxication : Callout
    {
        public EVehicleBlockingTrafficState state;
        public Vector3 SpawnPoint;
        public Blip myBlip;
        public Ped mySuspect;

        public override bool OnBeforeCalloutDisplayed()
        {
            SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(1000f));
            Game.LogTrivial("Create SpawnPoint.");

            mySuspect = new Ped(SpawnPoint);
            mySuspect.IsPersistent = true;
            mySuspect.BlockPermanentEvents = true;
            mySuspect.Armor = 69;
            if (IsLSPDFRPluginRunning("Traffic Policer", new Version("6.8.0.0")))
            {
                TrafficPolicerFunctions.SetPedDrugsLevels(mySuspect, true, true);
            }

 

Edited by ToastinYou

1 minute ago, ToastinYou said:

Sorry for the late reply, been working on other things. This did work, but I'm still getting the same error for IsLSPDFRPluginRunning (doesn't exist in current context). Shouldn't it be using the method created in Main.cs or do I have to create one in the callout.cs itself? Because the one from Main.cs doesn't seem to be connecting. Thank you by the way.

 


            if (Main.IsLSPDFRPluginRunning("Traffic Policer", new Version("6.8.0.0")))
            {
                TrafficPolicerFunctions.SetPedDrugsLevels(mySuspect, true, true);
            }

 

Note the Main.IsLSPDFRPluginRunning to direct it properly.

Make sure the method is public (should be as I assume you pasted it from the guide).

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

  • Author
10 minutes ago, Albo1125 said:


            if (Main.IsLSPDFRPluginRunning("Traffic Policer", new Version("6.8.0.0")))
            {
                TrafficPolicerFunctions.SetPedDrugsLevels(mySuspect, true, true);
            }

 

Note the Main.IsLSPDFRPluginRunning to direct it properly.

Make sure the method is public (should be as I assume you pasted it from the guide).

Wow I never knew you could do that. That would've made life so much easier for a few other things. Thank you lol I always tried to add references like using ToastyCallouts.Main.cs but it only allows folders so I was confused so had to work around it lol

Thanks Albo, you're awesome :)

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...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.