Jump to content
×
×
  • Create New...

I'm new to callout coding - I have a question


Recommended Posts

So I am slowly trying my hand at coding some basic callouts. I have some coding experience (not a lot in C# though) and I am trying to wrap my head around this and use available resources.

I want to spawn a car, and then put the suspect in the car and have them drive away when the player arrives. Here's my issue:

I can't seem to track down the proper coding to have them hop into the vehicle that I have spawned. Is what I have below correct? Do I need to use the VehicleHash.Adder each time for the same vehicle? How do I tell the suspect to enter the vehicle that was spawned OnAccept?

 

 

public async override Task OnAccept()
        {
            InitBlip();
            UpdateData();
            suspect = await SpawnPed(RandomUtils.GetRandomPed(), Location);
            await SpawnVehicle(VehicleHash.Adder, Location);
            suspect.SetIntoVehicle(VehicleHash.Adder, VehicleSeat.Driver);
            victim = await SpawnPed(RandomUtils.GetRandomPed(), Location + 1);
           
        }

        public override void OnStart(Ped player)
        {
            base.OnStart(player);
            suspect.Task.CruiseWithVehicle(VehicleHash.Adder 60f, 0,);

 

Link to post
Share on other sites
  • Management Team

The issue with what you have executed is that you are spawning a vehicle, but not assigning it to anything. Therefore, when you try to set the suspect into the vehicle, it's not executing properly as you are trying to spawn it into a VehicleHash, when I believe it needs to take a Vehicle.

 

Try this:

Quote

vehicle = await SpawnVehicle(VehicleHash.Adder, Location);

suspect.SetIntoVehicle(vehicle, VehicleSeat.Driver);

 

You would also want to assign the vehicle object that was just created in the OnStart, rather than another VehicleHash. Remember to add a comma to seperate each param as well.

Quote

public override void OnStart(Ped player) {

        base.OnStart(player);

        suspect.Task.CruiseWithVehicle(vehicle, 60f, 0,);

 

Sorry for using quote blocks rather than code blocks, code blocks aren't working for me at the moment.

Hope this helped 🙂

NorthCam18

OPERATIONS DIRECTOR

 

GitHub Account | northcam@gtapolicemods.com

Link to post
Share on other sites

This is awesome help! I was running into issues also because I forgot to define the vehicle at the beginning. Did I do this correctly?

 

866833701_ScreenShot2021-02-17at10_20_42AM.thumb.png.16ffe32e45bf3862c8a56128a7fac64f.png

 

1154152638_ScreenShot2021-02-17at10_21_53AM.thumb.png.8ff5d5f8ff3f7109336aee66fe933d76.png

 

I love learning this stuff.  The video series from @BGHDDevelopmentis what got me interested in trying my hand at coding these. It's a departure from the CSS and HTML that I am used to working with for my job, but it's welcome and I hope to keep growing in my knowledge. Any resources are welcome and this community has been great and so helpful. I hope to be able to contribute some callouts once I am done nailing down some of the basics.
 

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

  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.

  • Recently Browsing   0 members

    No registered users viewing this page.

Important Information

Please view the site: Terms of Use, Privacy Policy, and Guidelines. // IMPORTANT: We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.