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.

Coding conversation problem.

Featured Replies

I am trying to make the player have a conversation with a cop when he is in a certain distance (<=10) from the cop. the problem is that when I create a public void conversation1; and want to stop the conversation with GameFiber.Hibernate(); I can't really make anything happen after that because of the hibernate...my code:

public override void Process()
        {
			if (Game.LocalPlayer.Character.Position.DistanceTo(Cop)<= 10)
            {
                Conversation1();
            }
			
            base.Process();
        }
public void Conversation1()
        {
            Game.DisplaySubtitle("text1");
            Game.DisplaySubtitle("text2");
            Game.DisplaySubtitle("text3");
            Game.DisplaySubtitle("text4");
            GameFiber.Hibernate();
        }

if I remove the GameFiber.Hibernate(); the displayed subtitles will just continue looping over each other. hope someone can explain me how to create a conversation and not have GameFiber.Hibernate(); interfere with the code I add later,

thanks.

3 minutes ago, epicmrjuan said:

I think you are hibernating the main fiber, make a new one.

 

Here is a topic on conversations:

 

 

thanks, isn't there a way to make a conversation without keypress like mine above and still make it end without the hibernate?

GameFiber.StartNew(delegate
            {
              Game.DisplaySubtitle("text1");
              GameFiber.sleep(200);   
              Game.DisplaySubtitle("text2");         
              GameFiber.sleep(200);   
            }

 

 

This should work.

Thank you

Thanks, i'll give it a try later.

didn't work, only displays the first line.

public override void Process()
        {
            if (Game.LocalPlayer.Character.Position.DistanceTo(Cop) <= 10)
            {
                GameFiber.StartNew(delegate
                {
                    NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", Cop, Game.LocalPlayer.Character, 2100);
                   
                    Game.DisplaySubtitle("line1");
                    GameFiber.Wait(400);
                    Game.DisplaySubtitle("line2");
                    GameFiber.Wait(600);
                    Game.DisplaySubtitle("line3");
                    GameFiber.Wait(600);
                    Game.DisplaySubtitle("line4");
                    GameFiber.Wait(500);
                    Cop.Tasks.EnterVehicle(CopCar, 1000, -1, 10, EnterVehicleFlags.None);
                  	
                    Cop.Tasks.DriveToPosition(CopCar, EndDrivePoint, 25, VehicleDrivingFlags.None, 5f);

                    if (Game.LocalPlayer.Character.Position.DistanceTo(EndDrivePoint) <= 5)
                    {
                        Cop.Tasks.LeaveVehicle(CopCar, LeaveVehicleFlags.None);
                    }
                });
            }

            base.Process();
        }

sorry if I am doing obvious things wrong, I am new to c#.  btw the only task that does work is the "TASK_TURN_PED_TO_FACE_ENTITY", after that the first line but than nothing.

4 hours ago, NoNameSet said:

didn't work, only displays the first line.


public override void Process()
        {
            if (Game.LocalPlayer.Character.Position.DistanceTo(Cop) <= 10)
            {
                GameFiber.StartNew(delegate
                {
                    NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", Cop, Game.LocalPlayer.Character, 2100);
                   
                    Game.DisplaySubtitle("line1");
                    GameFiber.Wait(400);
                    Game.DisplaySubtitle("line2");
                    GameFiber.Wait(600);
                    Game.DisplaySubtitle("line3");
                    GameFiber.Wait(600);
                    Game.DisplaySubtitle("line4");
                    GameFiber.Wait(500);
                    Cop.Tasks.EnterVehicle(CopCar, 1000, -1, 10, EnterVehicleFlags.None);
                  	
                    Cop.Tasks.DriveToPosition(CopCar, EndDrivePoint, 25, VehicleDrivingFlags.None, 5f);

                    if (Game.LocalPlayer.Character.Position.DistanceTo(EndDrivePoint) <= 5)
                    {
                        Cop.Tasks.LeaveVehicle(CopCar, LeaveVehicleFlags.None);
                    }
                });
            }

            base.Process();
        }

sorry if I am doing obvious things wrong, I am new to c#.  btw the only task that does work is the "TASK_TURN_PED_TO_FACE_ENTITY", after that the first line but than nothing.

You are calling conversation1 infinitely many times when the player is 10m away. When they're 10m away every single tick you're convo code is being called.

7 hours ago, ToastinYou said:

You are calling conversation1 infinitely many times when the player is 10m away. When they're 10m away every single tick you're convo code is being called.

That makes sense.

created a callout with a pilot and shooters but they are invisible, so is the helicopter:

Spoiler

using Rage;
using Rage.Native;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using System;
using System.Drawing;
using LSPD_First_Response.Engine.Scripting.Entities;

namespace PursuingCallouts.Callouts
{
    [CalloutInfo("SuspiciousPerson", CalloutProbability.Medium)]
    class SuspiciousPerson : Callout
    {
        public Ped Aggressor;
        public Ped Victim;
        public Ped TaxiDriver;
        public Ped Pilot;
        public Ped Shooter1;
        public Ped Shooter2;
        public Vehicle Taxi;
        public Vehicle Heli;
        public Vector3 TaxiSP;
        public Vector3 AggressorSP;
        public Vector3 VictimSP;
        public Vector3 EndDrivePoint;
        public Vector3 HeliPad;
        public Blip AggressorBlip;
        public Blip TaxiDriverBlip;
        public Blip PilotBlip;
        public Blip Shooter1Blip;
        public Blip Shooter2Blip;

        public override bool OnBeforeCalloutDisplayed()
        {
            TaxiSP = new Vector3(2472.899f, 5114.277f, 46.40291f);
            EndDrivePoint = new Vector3(1418.63831f, 4404.036f, 45.1298676f);
            AggressorSP = new Vector3(1704.73645f, 4708.959f, 42.4599342f);
            VictimSP = new Vector3(1427.15637f, 4379.612f, 44.23329f);
            HeliPad = new Vector3(1963.83057f, 5163.709f, 47.3248367f);

            Aggressor = new Ped(AggressorSP);
            Victim = new Ped(VictimSP);
            TaxiDriver = new Ped("a_m_y_stlat_01", TaxiSP, 5f);
            Taxi = new Vehicle("TAXI", TaxiSP);
            Heli = new Vehicle("POLMAV", HeliPad, 0f);
            Heli.Heading = 112.39476f;
            Pilot = new Ped("s_m_m_pilot_02", HeliPad, 20f);
            Shooter1 = new Ped("s_m_y_swat_01", HeliPad, 20f);
            Shooter2 = new Ped("s_m_y_swat_01", HeliPad, 20f);

            Game.LogTrivial("PursuingCallouts: Spawning Peds and Vehicles");

            Aggressor.Inventory.GiveNewWeapon(WeaponHash.Pistol, 500, true);
            Shooter1.Inventory.GiveNewWeapon(WeaponHash.CarbineRifle, 500, true);
            Shooter2.Inventory.GiveNewWeapon(WeaponHash.CarbineRifle, 500, true);

            TaxiDriver.WarpIntoVehicle(Taxi, -1);
            Pilot.WarpIntoVehicle(Heli, -1);
            Shooter1.WarpIntoVehicle(Heli, 1);
            Shooter2.WarpIntoVehicle(Heli, 2);

            if (!Aggressor.Exists()) return false;
            if (!Victim.Exists()) return false;
            if (!TaxiDriver.Exists()) return false;
            if (!Taxi.Exists()) return false;
            if (!Pilot.Exists()) return false;
            if (!Shooter1.Exists()) return false;
            if (!Shooter2.Exists()) return false;
            if (!Heli.Exists()) return false;

            ShowCalloutAreaBlipBeforeAccepting(AggressorSP, 30f);
            AddMinimumDistanceCheck(10f, Aggressor.Position);

            CalloutMessage = "Suspicious Person";
            CalloutPosition = AggressorSP;

            Functions.PlayScannerAudioUsingPosition("", AggressorSP);

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            TaxiDriverBlip = TaxiDriver.AttachBlip();
            TaxiDriverBlip.Color = Color.Yellow;
            AggressorBlip = Aggressor.AttachBlip();
            AggressorBlip.Color = Color.Red;
            PilotBlip = Pilot.AttachBlip();
            PilotBlip.Color = Color.Blue;
            Shooter1Blip = Shooter1.AttachBlip();
            Shooter1Blip.Color = Color.Blue;
            Shooter2Blip = Shooter2.AttachBlip();
            Shooter2Blip.Color = Color.Blue;
            Game.LogTrivial("PursuingCallouts: Attaching Blips");

            Game.DisplaySubtitle("Get to the ~r~Suspect~w~.", 5000);
            Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "Pursuing Callouts", "Suspicious Person", "~b~Dispatch~w~: We have a suspicious person in sight, please respond code 2 to the suspects location and observe them.");
            Game.DisplayHelp("~y~Yellow~w~ Blip = Taxi, ~r~Red~w~ Blip = Suspect, ~b~Blue~w~ Blip = Helicopter Unit & SWAT", 8000);

            TaxiDriver.Tasks.DriveToPosition(Taxi, Aggressor.Position, 20, VehicleDrivingFlags.Normal, 5f);

            NativeFunction.CallByName<uint>("TASK_HELI_CHASE", Pilot, Aggressor, 0, 0, 50);

            if (Game.LocalPlayer.Character.Position.DistanceTo(Aggressor) <= 25)
            {
                NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", Aggressor, Game.LocalPlayer.Character);
                Game.DisplayHelp("You scared the Suspect!", 3000);
            }

            Game.LogTrivial("PursuingCallouts: Giving the Peds their tasks");

            //Shooter1.RelationshipGroup = "BLUE";
            //Shooter2.RelationshipGroup = "BLUE";
            //Victim.RelationshipGroup = "BLUE";
            //Game.LocalPlayer.Character.RelationshipGroup = "BLUE";
            //Aggressor.RelationshipGroup = "RED";

            //Game.SetRelationshipBetweenRelationshipGroups("RED", "BLUE", Relationship.Hate);

            return base.OnCalloutAccepted();
        }

        public override void OnCalloutNotAccepted()
        {
            if (Taxi.Exists()) Taxi.Delete();
            if (TaxiDriver.Exists()) TaxiDriver.Delete();
            if (Victim.Exists()) Victim.Delete();
            if (Aggressor.Exists()) Aggressor.Delete();
            if (TaxiDriverBlip.Exists()) TaxiDriverBlip.Delete();
            if (AggressorBlip.Exists()) AggressorBlip.Delete();
            if (Pilot.Exists()) Pilot.Delete();
            if (Shooter1.Exists()) Shooter1.Delete();
            if (Shooter2.Exists()) Shooter2.Delete();
            if (Shooter1Blip.Exists()) Shooter1Blip.Delete();
            if (Shooter2Blip.Exists()) Shooter2Blip.Delete();
            if (PilotBlip.Exists()) PilotBlip.Delete();
            if (Heli.Exists()) Heli.Delete();

            Game.LogTrivial("PursuingCallouts: Error when trying to cleanup when the callout doesn't get accepted");

            base.OnCalloutNotAccepted();
        }

        public override void Process()
        {
            if (Taxi.Position.DistanceTo(Aggressor) <= 10)
            {
                Aggressor.Tasks.EnterVehicle(Taxi, 5000, 1, 10, EnterVehicleFlags.None);
                GameFiber.Wait(3000);
                TaxiDriver.Tasks.DriveToPosition(Taxi, EndDrivePoint, 17, VehicleDrivingFlags.Normal, 5f);
            }
            if (TaxiDriver.Position.DistanceTo(Victim) <= 20)
            {
                Aggressor.Tasks.LeaveVehicle(Taxi, LeaveVehicleFlags.None);
                Aggressor.Tasks.FightAgainst(Victim, 5000);
                Aggressor.Tasks.ReactAndFlee(Aggressor);
                TaxiDriver.Tasks.CruiseWithVehicle(Taxi, 25, VehicleDrivingFlags.Normal);
            }
            if (Pilot.Position.DistanceTo(Victim) <= 40)
            {
                Shooter1.Tasks.RappelFromHelicopter();
                Shooter2.Tasks.RappelFromHelicopter();
                Shooter1.Tasks.FightAgainst(Aggressor);
                Shooter2.Tasks.FightAgainst(Aggressor);
            }

            if (Aggressor.IsDead)
            {
                if (AggressorBlip.Exists()) AggressorBlip.Delete();
            }
            if (TaxiDriver.IsDead)
            {
                if (TaxiDriverBlip.Exists()) TaxiDriverBlip.Delete();
            }
            Game.LogTrivial("PursuingCallouts: Error when trying to cleanup in the process method");

            base.Process();
        }

        public override void End()
        {
            if (Taxi.Exists()) Taxi.Dismiss();
            if (TaxiDriver.Exists()) TaxiDriver.Dismiss();
            if (Victim.Exists()) Victim.Dismiss();
            if (Aggressor.Exists()) Aggressor.Dismiss();
            if (TaxiDriverBlip.Exists()) TaxiDriverBlip.Delete();
            if (AggressorBlip.Exists()) AggressorBlip.Delete();
            if (Pilot.Exists()) Pilot.Dismiss();
            if (Shooter1.Exists()) Shooter1.Dismiss();
            if (Shooter2.Exists()) Shooter2.Dismiss();
            if (PilotBlip.Exists()) PilotBlip.Delete();
            if (Shooter1Blip.Exists()) Shooter1Blip.Delete();
            if (Shooter2Blip.Exists()) Shooter2Blip.Delete();
            if (Heli.Exists()) Heli.Dismiss();

            Game.LogTrivial("PursuingCallouts: Error when trying to cleanup in the end method");

            base.End();
        }
    }
}

 

code, isn't finished yet. but still does what I wan't except from the invisible problem...

Edited by NoNameSet

  • The topic was locked
Guest
This topic is now closed to further replies.

Similar Content

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.