Teleport Player

Is it possible to create an event that teleports the player somewhere?

Sure you can, the function you’re looking for is SetEntityCoords.

Example usage in a command

RegisterCommand("teleport", function()
     SetEntityCoords(PlayerPedId(), 0, 0, 0, false, false, false, false)
end, false)

Example usage in a net event

RegisterNetEvent("my_teleport")
AddEventHandler("my_teleport", function()
     SetEntityCoords(PlayerPedId(), 0, 0, 0, false, false, false, false)
end)

For more information, read the docs: SetEntityCoords - Natives @ Cfx.re Docs (fivem.net)

works fine thanks =)

is there a possible way to trigger this on server-side?

@BleckHall

Sure you can.

-- client.lua
RegisterCommand("teleport", function()
    TriggerServerEvent("my_teleport_event")
end)
-- server.lua
RegisterNetEvent("my_teleport_event")
AddEventHandler("my_teleport_event", function()
    local player = source
    SetEntityCoords(player, 0, 0, 0, false, false, false, false)
end)

Do note, you can also register the command server-side to avoid triggering a net event, instead calling a function or in-line code.