Jump to content

New programer, does anyone know what's causing a crash here?


SteveOhByte

Recommended Posts

I've been trying to get custom locations working for my callout pack, I think I've done everything correctly and I don't see error messages in Visual studio, but it's clear that the problem is here somewhere:

 

Spoiler

YouToolBackRoad = new Vector3(2653.1551300970923f, 3512.095996984054f, 0f);
            YouToolSideRoad = new Vector3(2714.225604481665f, 3436.5440488848185f, 0f);
            YouToolLot = new Vector3(2761.278126811762f, 3457.787128559615f, 0f);

            HumaneLabArea = new Vector3(3503.4937209865193f, 3664.1484739719267f, 0f);
            HumaneLabLot = new Vector3(3591.52747244283f, 3762.7770581763402f, 0f);
            HumaneLabEntry = new Vector3(3410.906499627296f, 3744.5687041693714f, 0f);

            SandyAirfield = new Vector3(1783.7999209865193f, 3277.220951323843f, 0f);
            GrapeseedAirfield = new Vector3(2134.417103510791f, 4799.135873739639f, 0f);
            LSInternational = new Vector3(-1051.4940052270729f, -3009.21326958208f, 0f);

            PaletoGas = new Vector3(158.2111656467173f, 6582.03720358865f, 0f);
            SandyGas = new Vector3(1986.3088988094776f, 3764.405672726937f, 0f);
            HarmonyGas = new Vector3(1227.2316229385965f, 2662.768560625255f, 0f);
            GrapeseedGas = new Vector3(1694.4541875745713f, 4784.217116746875f, 0f);


            if (Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(YouToolLot) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(YouToolSideRoad) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(HumaneLabArea) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(HumaneLabEntry) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(HumaneLabLot) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(GrapeseedAirfield) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(GrapeseedGas) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(SandyAirfield) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(SandyGas) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(HarmonyGas) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(LSInternational) && Game.LocalPlayer.Character.DistanceTo(YouToolBackRoad) < Game.LocalPlayer.Character.DistanceTo(PaletoGas))
            {
                CalloutLocation = YouToolBackRoad;
            }
            else
            {
                CalloutLocation = YouToolLot;
            }

 

I've only put in the if statement for part of it today but I've got it set up to test for now.

 

Any and all help is appreciated thanks! 🙂

Everyone wants happiness, no one wants pain. But you can't have a rainbow, without a little rain.

Link to comment
Share on other sites

What kind of problem do you have with this code? The style can definitely be better but there's no obvious bug. You could use an array/dictionary to store vectors and LINQ to check the condition so your code would look like this:

 

CalloutLocation = locations.All(l => DistanceToPlayer(l) > distToBackRoad) ? YouToolBackRoad : YouToolLot;

Link to comment
Share on other sites

6 hours ago, LtFlash said:

What kind of problem do you have with this code? The style can definitely be better but there's no obvious bug. You could use an array/dictionary to store vectors and LINQ to check the condition so your code would look like this:

 

CalloutLocation = locations.All(l => DistanceToPlayer(l) > distToBackRoad) ? YouToolBackRoad : YouToolLot;

That's part of the problem, I'm not sure what the problem with the code is. I'm getting no errors, it just crashes when running through the code. This might be easier to see (The if statement continues as it did above):

Capture.PNG

Everyone wants happiness, no one wants pain. But you can't have a rainbow, without a little rain.

Link to comment
Share on other sites

Whenever you ask for help with code crashing, you should specify what happens when it crashes. Saying "it crashed" could be anything. Post an excerpt from your log showing the particular exception. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

7 hours ago, PNWParksFan said:

Whenever you ask for help with code crashing, you should specify what happens when it crashes. Saying "it crashed" could be anything. Post an excerpt from your log showing the particular exception. 

Thanks for the advice 🙂

 

Here is the log

https://pastebin.com/iDwSGDxh

 

I'm not sure what to make of it since it ends so abruptly...

Everyone wants happiness, no one wants pain. But you can't have a rainbow, without a little rain.

Link to comment
Share on other sites

  • 2 weeks later...

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