How to Get & Use Coordinates (vector3) in FiveM

How to get and use coordinates in FiveM — GetEntityCoords, vector3 vs vector4, distance and heading, and converting formats.

Coordinates are everywhere in FiveM scripting — spawns, markers, blips, job points, teleports and distance checks. Getting them and working with them efficiently saves a lot of time. This guide covers how to get and use coordinates (vector3) in FiveM.

Getting your current coordinates

The quickest way in-game is to print your position:

local coords = GetEntityCoords(PlayerPedId())
print(coords.x, coords.y, coords.z)
-- heading:
print(GetEntityHeading(PlayerPedId()))

Many servers add a /coords command that copies this to your clipboard for placing props, blips and markers.

vector3 and vector4

FiveM uses vector3(x, y, z) for positions and vector4(x, y, z, w) when you also need a heading (w). Natives like SetEntityCoords, AddBlipForCoord and CreateObject take these. You can index them with .x, .y, .z or do vector maths directly (e.g. #(coordsA - coordsB) for distance).

Distance and heading

Common needs: the distance between a player and a point (for an interaction range), and the heading to face from one point to another (for spawns). You can compute these with vector subtraction and atan2, or skip the maths entirely with our free Vector3 / coordinates tool — paste two coordinates and get the 3D/2D distance, heading and midpoint, plus conversion between vector3, vector4, Lua table, JSON and C# formats.

Converting formats

Coordinates show up in many formats — a raw x, y, z from a map editor, a Lua table from a config, JSON from an API. The Vector3 tool auto-detects any format you paste and outputs all of them, ready to drop into your script.

Frequently asked questions

How do I get my coordinates in FiveM?

Use GetEntityCoords(PlayerPedId()) and print x, y, z (and GetEntityHeading for the facing). Many servers bind this to a /coords command.

What’s the difference between vector3 and vector4 in FiveM?

vector3 is a position (x, y, z); vector4 adds a heading (w). Use vector4 when you need the entity to face a direction, like a spawn point.

How do I get the distance between two coordinates?

Subtract the vectors and take the magnitude (#(a - b)), or use our Vector3 tool to compute 3D/2D distance instantly.

Ready to play?

Run your own FiveM server with XGamingServer

Spin up an always-on FiveM server your friends can join in minutes — no port-forwarding, no tech headaches.

99.9%Uptime SLA
< 5 minInstant setup
24/7Human support
DDoSProtected
Instant setup Your server is live in minutes with a one-click control panel.
Mods & plugins Install mods, plugins and workshop content in a few clicks.
DDoS protected Enterprise DDoS mitigation keeps your server online 24/7.
Low-latency hardware Premium CPUs & NVMe SSDs for lag-free multiplayer.
Free backups Automatic backups so your world is never lost.
Real human support Gamers helping gamers — 24/7, no bots, no scripts.

Pick your FiveM plan & play in minutes

See all plans
Starter $8.40/mo 4 GB RAM Renews $12/mo Buy now
Rookie $17.50/mo 8 GB RAM Renews $25/mo Buy now
Pro $24.50/mo 12 GB RAM Renews $35/mo Buy now