Added 'coordinate' arg type for ESX.RegisterCommand()

This commit is contained in:
Ilias Rbayti
2023-08-15 14:48:54 +02:00
parent a95e0397b0
commit e51aaae1b1
2 changed files with 11 additions and 4 deletions
+3 -3
View File
@@ -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' }
}
})
+8 -1
View File
@@ -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