#gps-nav

14 messages · Page 1 of 1 (latest)

golden sigil
#

So, this is a little "gps" library I wasted spent my afternoon putting together.

It started as a little experiment of mine a while ago. Then someone in chat mentioned gta v style gps systems, and I remembered I'd already poked at that idea once, though the original code was pretty janky. So I figured I'd take another shot at it.

The core "hack" is using gangzones as dots (think PacMan dots, it's the same concept: you're PacMan and the gangzones are the dots). Each dot is just a tiny, slightly overlapping gangzone chained together so it looks like a visually continuous line at normal distance.

Gangzones are extremely limited (we get 1024 per player for...reasons) so long routes have to be capped. Every dot consumes one slot, and a moderately long route (e.g. LS -> LV) can easily chew through 800 slots. Once a path hits around 600-ish zones (configurable), it doesn't just cut the rest off, it draws until the limit, then silently resumes once you physically reach that point on the route. It's not ideal, but it's the most stable workaround I could think of.

Under the hood, it uses a circular buffer with head/tail pointers. No array shifting, no O(n) operations every time you move a meter, it just bumps the pointer.

One thing worth stressing: if your script is already drawing a bunch of gangzones, you're going to hit the SA-MP limits immediately. Unfortunately, there's no real workaround for that as far as I know.

Visually, the lines are just overlapping squares. Zoom in and it looks like a staircase, zoom out and it smooths into a curve (I'd say it's a feature).

Also, we brute force the geometry by stepping along a vector and spawning a zone every few meters.

If nothing else, it was a fun little POC, and I had a good time building it. Hope it's useful.

https://github.com/FreddieCrew/gps-nav

GitHub

SA-MP/open.mp GPS library. Contribute to FreddieCrew/gps-nav development by creating an account on GitHub.

lime agate
#

maybe you can put the example to use it?

golden sigil
#

lol

lime agate
#

haha

#

nice script

golden sigil
#

thanks

nova mirage
#

Cool

golden sigil
#

finally got around to adding some documentation

peak vigil
#

Did you use this script on a big server to test its performance?

golden sigil
#

nope

#

but it should be fine performance wise for most servers

#

its all O(1) buffer lookups and the pathfinding is threaded, so it technically doesnt care if u have 1 player or 500