Skip to content

Commit

Permalink
Merge pull request #1154 from Kenshiin13/Better-SetCoords
Browse files Browse the repository at this point in the history
Feature Request 1143: Added 'coordinate' arg type for ESX.RegisterCommand()
  • Loading branch information
Gellipapa authored Aug 18, 2023
2 parents 1f48b63 + c279b4e commit ba594a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions [core]/es_extended/server/commands.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ESX.RegisterCommand('setcoords', 'admin', function(xPlayer, args)
ESX.RegisterCommand({'setcoords', 'tp'}, 'admin', function(xPlayer, args)
xPlayer.setCoords({ x = args.x, y = args.y, z = args.z })
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Set Coordinates /setcoords Triggered!", "pink", {
Expand All @@ -13,9 +13,9 @@ end, false, {
help = TranslateCap('command_setcoords'),
validate = true,
arguments = {
{ name = 'x', help = TranslateCap('command_setcoords_x'), type = 'number' },
{ name = 'y', help = TranslateCap('command_setcoords_y'), type = 'number' },
{ name = 'z', help = TranslateCap('command_setcoords_z'), type = 'number' }
{ name = 'x', help = TranslateCap('command_setcoords_x'), type = 'coordinate' },
{ name = 'y', help = TranslateCap('command_setcoords_y'), type = 'coordinate' },
{ name = 'z', help = TranslateCap('command_setcoords_z'), type = 'coordinate' }
}
})

Expand Down
9 changes: 8 additions & 1 deletion [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion)
local merge = table.concat(args, " ")

newArgs[v.name] = string.sub(merge, lenght)
end
elseif v.type == 'coordinate' then
local coord = tonumber(args[k]:match("(-?%d+%.?%d*)"))
if(not coord) then
error = TranslateCap('commanderror_argumentmismatch_number', k)
else
newArgs[v.name] = coord
end
end
end

--backwards compatibility
Expand Down

0 comments on commit ba594a7

Please sign in to comment.