Same thing as 26 lines of code lol
Usage: /tp 0.0 0.0 0.0 → Teleports to Coords vec3(0.0, 0.0, 0.0)
-- Config
Config = {}
Config.Command = {
command = 'tp'
allowedGroups = {'admin', 'mod'}
}
-- Serverside
ESX = exports["es_extended"]:getSharedObject()
ESX.RegisterCommand(Config.Command.command, Config.Command.allowedGroups, function(xPlayer, args, showError)
if not args.x or not args.y or not args.z then return end
xPlayer.triggerEvent('example:teleport', {args.x, args.y, args.z})
end, false, {help = 'Teleport to specific coords', arguments = {
{name = 'x', help = 'X Coordinate', type = 'string'},
{name = 'y', help = 'Y Coordinate', type = 'string'},
{name = 'z', help = 'Z Coordinate', type = 'string'},
}})
-- Clientside
ESX = exports["es_extended"]:getSharedObject()
RegisterNetEvent('example:teleport', function(coords)
ESX.Game.Teleport(PlayerPedId(), coords, function() end)
end)
Or without clientside event:
-- Config
Config = {}
Config.Command = {
command = 'tp'
allowedGroups = {'admin', 'mod'}
}
-- Serverside
ESX = exports["es_extended"]:getSharedObject()
ESX.RegisterCommand(Config.Command.command, Config.Command.allowedGroups, function(xPlayer, args, showError)
if not args.x or not args.y or not args.z then return end
SetEntityCoords(GetPlayerPed(xPlayer.source), args.x, args.y, args.z, false, false, false, false)
end, false, {help = 'Teleport to specific coords', arguments = {
{name = 'x', help = 'X Coordinate', type = 'string'},
{name = 'y', help = 'Y Coordinate', type = 'string'},
{name = 'z', help = 'Z Coordinate', type = 'string'},
}})