[Help] Trying to convert the map data into code

Hey all. I have a bit of an interesting challenge.

On a high level, I’m trying to have a player’s client do something when they’re in a specific area of the map. That something will consist of a few natives and some logic checks, however, the challenging part that I’m trying to come across is the following:

How do I ‘searialize’ (I guess that’s the right word) the map data into code for easy translations? For example, let’s pretend that something is an outfit change everytime a player is in a different ‘zone’ - Well to determine the zone, I have to try to convert the map data (let’s start with 2d) into code, and I don’t quite know how to do that…Does anyone have nay thoughts on how this can be done?

Well, if I understood correctly, it’s just about some coordinate and distance logic checks.

For specific zones you mentioned you could use a third party script like GitHub - DemmyDemon/paradise-area: Arbituary-shaped areas!.

I hope I could help you.

I also have a much simpler implementation of a similar concept, where the zones are just rectangles.

Edit: Oh, and the license for both is very liberal. Yoink at will.

Hey Demonen!
I guess I’ll be a bit more specific:
I’m trying to work on a crosswinds script where I define areas on the map to make aircraft do something. The hard part is serailizing / hashing / mapping points on a map for logic processing. I’m kinda at a loss for what I’m trying to do to get started…I have some pieces to the puzzle like what’s gonna happen, but I’m honestly stuck on where to start…

Hopefully that helps!

When you say “serializing/hashing/mapping”, what do you mean?
Those three are entirely separate concepts.

Right, but I’m not sure which term would fit in the context of what I’m trying to do…taking the entirety of the map and placing it in a state of interactivity via code. Maybe one of those terms? Maybe none? but this is getting way beside the actual point Im trying to make / goal I’m trying to achieve…

Maybe try GetZoneAtCoords - FiveM Natives @ Cfx.re Docs and GetZoneFromNameId - FiveM Natives @ Cfx.re Docs if you want to use the already existing GTA Neighborhoods / Zones

Like, check the area every second or two, with the player coords ( GetEntityCoords(PlayerPedId()) ) and if the player is in zone X, do something.

You might also want to save the previous zone of the player, as to not spam that do something

1 Like

This may be JUUST what I need! Thanks CritteR!

I’ll let you know how it goes! <3

You can also use PolyZones for a more advanced way of making zones, I personally never used it but I have read on it and it sounds like something worth trying.

On another note, if you want to make a basic rectangle zone, you can can get the X and Y for both sides and run some if statements. Probably be better to do a table/array of those stored then just run a check if the GetEntityCoords(PlayerPedId()) is > or < to the X and Y you stored.