/tp command that teleports you to coordinates

Hello I need a simple script that when you type /tp and the coords teleports you there, any help is appriciated

2 Likes

Use the following references:

RegisterCommand (To create the /tp command):

Here’s a handy tutorial about how the register command native works:

SetEntityCoords or SetPedCoordsKeepVehicle to teleport the player (depends if you want to teleport the vehicle the player is in or not)


And that should be it!

Can make a resource with this code please?

1 Like

You can also use this script…

1 Like

I need a vrp script, not a esx

Since other people will find themselves here like I did, and I had to figure out how to make this work, here is a clientside snippet of code

RegisterCommand(‘tpto’, function(source, args, rawCommand)
if tonumber(args[1]) ~= nil and tonumber(args[2]) ~= nil and tonumber(args[3]) ~= nil then
local posx = tonumber(args[1])
local posy = tonumber(args[2])
local posz = tonumber(args[3])
local coords = { x = posx, y = posy, z = posz}
ESX.Game.Teleport(PlayerPedId(), coords)
end
end)

if you’re not using ESX just change the ESX section to whatever works for you

1 Like

Is there a server side?

If you have an updated QBCore server this is built in.

Of course :smile:, but he didn’t mention that.

1 Like