Jump to content

Random closest spawn-point from coordinate list?


Luigi4518

Recommended Posts

Currently I have a system for calling random spawn-points using a set of set coordinates using 'new random().next(x, x); Unfortunately this system gets buggy and can select points from any point on the map which often leads to either the suspect escaping instantly and/or lspdfr crashing.

I'm hoping somebody around here would be able to point me in the right directing as to setting up a list containing the preset coordinates that can be randomly selected from within a maximum distance restriction.

Link to comment
Share on other sites

  • Management Team

You may want to try one of these approaches:

  • After randomly getting a point, check if the distance exceeds your maximum distance. If so, get a new random point. Do this until you have found a valid point (adding some kind of maximum number of attempts is a good idea btw).
  • From a maths point of view, you could apply the closest pair of points problem to this. Yours is slighty different in the regard that you allow multiple points within a range, but a little altered algorithm should work here. Note that bruting takes O(n²) here, so I'd go for a divide and conquer algorithm, which should take O(n log n).

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Link to comment
Share on other sites

If you simply need a location that's on a valid street, I'd recommend using the following:

Vector3 SpawnPoint= World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(radius));

If you have a list of specific spawn points you want to select from, LMS has explained it above. If you need to check the distance, I recommend using this:

if (Vector3.Distance(Game.LocalPlayer.Character.Position, SpawnPoint)< radius){}

Hope it helps!

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

Somethings not working (Usually my code) as now its throwing a fit. It doesn't limit it by distance but now spawns the callout in only one place using old code that isn't even in the callout now.

Would it help if I paste the callout or part of it here?

 

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