Jump to content

Two questions about callouts..


jmargel74

Recommended Posts

Just making a simple callout, I want to Semi's to follow each other.  First question, when they spawn I need them to spawn one behind the other, the second question is when they spawn they won't spawn facing the correct direction on a road.  They just seem to spawn where they like.  Below is my code.  Any advice?  I'm new to this..

 

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


namespace Mayhem
{
    [CalloutInfo("StolenVehicle", CalloutProbability.High)]
    public class StolenVehicle : Callout
    {
        private Ped Suspect1;
        private Ped Suspect2;
        private Ped Suspect3;
        private Vehicle Truck1;
        private Vehicle Truck1Trailer;
        private Vehicle Truck2;
        private Vehicle Truck2Trailer;
        private Vehicle Truck3;
        private Vehicle Truck3Trailer;
        private Vector3 SpawnPoint;
        private Vector3 SpawnPoint2;
        private Vector3 SpawnPoint3;
        private Blip SuspectBlip;
        private Blip SuspectBlip1;
        private Blip SuspectBlip2;
        private Blip SuspectBlip3;
        private LHandle Pursuit;
        private bool PursuitCreated = false;

        public override bool OnBeforeCalloutDisplayed()
        {
            SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(250f));
      

            ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 30f);
            AddMinimumDistanceCheck(20f, SpawnPoint);

            CalloutMessage = "Stolen Tractor Trailers!";
            CalloutPosition = SpawnPoint;

            Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_GRAND_THEFT_AUTO IN_OR_ON_POSITION", SpawnPoint);

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {

            Truck1 = new Vehicle("PHANTOM", SpawnPoint);
            Truck1Trailer = new Vehicle("FREIGHTTRAILER", SpawnPoint);
            Truck1.Trailer = Truck1Trailer;

            Vector3 o1 = Truck1.GetOffsetPosition(new Vector3(25f, -25f, 0f));

            Truck2 = new Vehicle("PHANTOM", o1);
            Truck2Trailer = new Vehicle("FREIGHTTRAILER", o1);
            Truck2.Trailer = Truck2Trailer;

            Suspect1 = Truck1.CreateRandomDriver();
            Suspect1.IsPersistent = true;
            Suspect1.BlockPermanentEvents = true;
            Suspect1.RelationshipGroup = "Friends1";

            Suspect2 = Truck2.CreateRandomDriver();
            Suspect2.IsPersistent = true;
            Suspect2.BlockPermanentEvents = true;
            Suspect2.RelationshipGroup = "Friends2";
            Game.SetRelationshipBetweenRelationshipGroups("Friends1", "Friends2", Relationship.Companion);

            SuspectBlip1 = Suspect1.AttachBlip();
            SuspectBlip1.IsFriendly = false;

            SuspectBlip2 = Suspect2.AttachBlip();
            SuspectBlip2.IsFriendly = false;

            Suspect1.Tasks.CruiseWithVehicle(20f, VehicleDrivingFlags.Emergency);
            Suspect2.Tasks.CruiseWithVehicle(20f, VehicleDrivingFlags.Emergency);

            Suspect1.Inventory.GiveNewWeapon("WEAPON_PISTOL", -1, true);
            Suspect2.Inventory.GiveNewWeapon("WEAPON_PISTOL", -1, true);

            Suspect1.Tasks.FightAgainst(Game.LocalPlayer.Character, -1);
            Suspect2.Tasks.FightAgainst(Game.LocalPlayer.Character, -1);

            Suspect2.Tasks.ChaseWithGroundVehicle(Suspect1);
           
            return base.OnCalloutAccepted();
        }

        public override void Process()
        {
           
            base.Process();
            if (!PursuitCreated && Game.LocalPlayer.Character.DistanceTo(Suspect1.Position) < 30f)
            {
                Pursuit = Functions.CreatePursuit();
                Functions.AddPedToPursuit(Pursuit, Suspect1);
                Functions.AddPedToPursuit(Pursuit, Suspect2);
                Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                PursuitCreated = true;
            }

            if (PursuitCreated && !Functions.IsPursuitStillRunning(Pursuit))
            {
                End();
            }
        }

        public override void End()
        {
            base.End();
            if (Suspect1.Exists()) { Suspect1.Dismiss(); }
            if (Truck1.Exists()) { Truck1.Dismiss(); }
            if (Truck1Trailer.Exists()) { Truck1Trailer.Dismiss(); }
            if (SuspectBlip1.Exists()) { SuspectBlip1.Delete(); }

            if (Suspect2.Exists()) { Suspect2.Dismiss(); }
            if (Truck2.Exists()) { Truck2.Dismiss(); }
            if (Truck2Trailer.Exists()) { Truck2Trailer.Dismiss(); }
            if (SuspectBlip2.Exists()) { SuspectBlip2.Delete(); }


        }
    }
}

 

 

Edited by jmargel74
Link to comment
Share on other sites

ToastinYou,

 

   I tried your code and modified it some.  The first truck is fine, the second trucker seems to want to get out of his truck pretty quickly.  With the traffic they don't seem to stay with each other.  Give it a try and see what you recommend.  It's hard to program these when the api functions really don't tell you what they do.  I really appreciate your help, I think if we can work out the bugs we could have a really cool callout.

Link to comment
Share on other sites

5 hours ago, jmargel74 said:

ToastinYou,

 

   I tried your code and modified it some.  The first truck is fine, the second trucker seems to want to get out of his truck pretty quickly.  With the traffic they don't seem to stay with each other.  Give it a try and see what you recommend.  It's hard to program these when the api functions really don't tell you what they do.  I really appreciate your help, I think if we can work out the bugs we could have a really cool callout.

It's hard to keep vehicles in line, and I am not aware of a way to do something like that.

Then, to prevent the second trucker from getting out of his vehicle, use this native:
 

NativeFunction.Natives.SET_PED_COMBAT_ATTRIBUTES(_myPed, 3, false); // sets BF_CanLeaveVehicle to false (Ped ped, int attributeIndex, BOOL enabled)
                                                                                            /*BF_CanUseCover = 0,
                                                                                            BF_CanUseVehicles = 1,
                                                                                            BF_CanDoDrivebys = 2,
                                                                                            BF_CanLeaveVehicle = 3,
                                                                                            BF_CanFightArmedPedsWhenNotArmed = 5,
                                                                                            BF_CanTauntInVehicle = 20,
                                                                                            BF_AlwaysFight = 46,
                                                                                            BF_IgnoreTrafficWhenDriving = 52,
                                                                                            BF_FreezeMovement = 292,
                                                                                            BF_PlayerCanUseFireingWeapons = 1424*/

 

Link to comment
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...