Jump to content

How to make callouts only spawn near to you


techgamer15

Recommended Posts

So basically I have a callout in development where all the clothes stores in the whole map have a certain "shoplifting" incident. All these locations have vector 3's and are all logged in my plugin, however I noticed that for a simple call like that, they seem to spawn on the other side of the map, instead of nearby. 

 

I need an efficient way to check the distance to the locations, maybe a for-each loop looking inside an array of the x,y,z coordinates, and returning the distances to each callout in another array, then checking which one is the closest and spawning that one. I dont know how efficient that would be, plus coding it would be rather tedious and annoying.

 

Anyone else have any ideas, maybe from your own callout packs?

Edited by techgamer15
Link to comment
Share on other sites

Its beeen a SUPPPER long time since I have made a callout but did you try the Vector3 Method Around2D(Single)? Or maybe the method DistanceTo(Single,Vector3) (when applicable)?


Its been a long time but hopefully that hits somewhere in the ballpark

 

Edited by tHeReALkItKaT

- tHeReALkItKaT

Link to comment
Share on other sites

If I'm understanding this correctly all you need is a spawnpoint class then a list of spawnpoints in a list which you order by distance to a vector when called.

Link to comment
Share on other sites

23 hours ago, tHeReALkItKaT said:

Its beeen a SUPPPER long time since I have made a callout but did you try the Vector3 Method Around2D(Single)? Or maybe the method DistanceTo(Single,Vector3) (when applicable)?


Its been a long time but hopefully that hits somewhere in the ballpark

 

I'll have a look at that when GTA actually works again. Thanks.

Link to comment
Share on other sites

What's so hard about it just create a class where you can set a vector3, a heading you can have the area and street name as well, heres an example from my old callout pack:

internal class SpawnHelper
{
    public float Heading;
    public string Area;
    public string Street;
    public Vector3 Location;
    public Rotator Rotation;
    
    public SpawnHelper(Vector3 location, float heading, string area, string street)
    {
        this.Location = location;
        this.Heading = heading;
        this.Area = area;
        this.Street = street;
    }

    public SpawnHelper(Vector3 location, float heading)
    {
        this.Location = location;
        this.Heading = heading;
    }

    public SpawnHelper(Vector3 location, Rotator rotation)
    {
        this.Location = location;
        this.Rotation = rotation;
    }
}
Edited by NoNameSet
Link to comment
Share on other sites

SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));

I'm not an expert but try this, change 300f to a smaller number

Edited by Boba
Link to comment
Share on other sites

On 7/12/2018 at 7:56 PM, NoNameSet said:

What's so hard about it just create a class where you can set a vector3, a heading you can have the area and street name as well, heres an example from my old callout pack:


internal class SpawnHelper
{
    public float Heading;
    public string Area;
    public string Street;
    public Vector3 Location;
    public Rotator Rotation;
    
    public SpawnHelper(Vector3 location, float heading, string area, string street)
    {
        this.Location = location;
        this.Heading = heading;
        this.Area = area;
        this.Street = street;
    }

    public SpawnHelper(Vector3 location, float heading)
    {
        this.Location = location;
        this.Heading = heading;
    }

    public SpawnHelper(Vector3 location, Rotator rotation)
    {
        this.Location = location;
        this.Rotation = rotation;
    }
}

I have this issue too, but I load all my locations from a XML file, how do I make them spawn when you are in a certain range only?

Link to comment
Share on other sites

21 minutes ago, NoNameSet said:

check the distance?

What do you mean?

27 minutes ago, NoNameSet said:

check the distance?

            //LOAD A LIST OF SPAWNS FROM A FILE
            ListOfSpawns = Serialization.LoadFromXML<ExtendedSpawnPoint>("FirearmLSTCoords");

            //GET A RANDOM INDEX
            int randIndex = MathHelper.GetRandomInteger(0, ListOfSpawns.Count - 1);

            ExtendedSpawnPoint espSpawn = ListOfSpawns[randIndex];

            //GET A SPAWN FROM THE LIST
            SpawnPoint = ListOfSpawns[randIndex].Position;

 

this is my code, I want the callout only to apear when the player is in a certain range of the spawns

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