mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Re-done locale names for commands, moved hardcoded strings to locale and added /setgroup command
This commit is contained in:
+45
-38
@@ -1,65 +1,65 @@
|
||||
ESX.RegisterCommand('setcoords', 'admin', function(xPlayer, args, showError)
|
||||
xPlayer.setCoords({x = args.x, y = args.y, z = args.z})
|
||||
end, false, {help = 'Teleport to coordinates', validate = true, arguments = {
|
||||
{name = 'x', help = 'X coords', type = 'number'},
|
||||
{name = 'y', help = 'Y coords', type = 'number'},
|
||||
{name = 'z', help = 'Z coords', type = 'number'}
|
||||
end, false, {help = _U('command_setcoords'), validate = true, arguments = {
|
||||
{name = 'x', help = _U('command_setcoords_x'), type = 'number'},
|
||||
{name = 'y', help = _U('command_setcoords_y'), type = 'number'},
|
||||
{name = 'z', help = _U('command_setcoords_z'), type = 'number'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('setjob', 'admin', function(xPlayer, args, showError)
|
||||
if ESX.DoesJobExist(args.job, args.grade) then
|
||||
args.playerId.setJob(args.job, args.grade)
|
||||
else
|
||||
showError('That job does not exist')
|
||||
showError(_U('command_setjob_invalid'))
|
||||
end
|
||||
end, true, {help = _U('setjob'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('id_param'), type = 'player'},
|
||||
{name = 'job', help = _U('setjob_param2'), type = 'string'},
|
||||
{name = 'grade', help = _U('setjob_param3'), type = 'number'}
|
||||
end, true, {help = _U('command_setjob'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
|
||||
{name = 'job', help = _U('command_setjob_job'), type = 'string'},
|
||||
{name = 'grade', help = _U('command_setjob_grade'), type = 'number'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError)
|
||||
xPlayer.triggerEvent('esx:spawnVehicle', args.car)
|
||||
end, false, {help = _U('spawn_car'), validate = false, arguments = {
|
||||
{name = 'car', help = _U('spawn_car_param'), type = 'any'}
|
||||
end, false, {help = _U('command_car'), validate = false, arguments = {
|
||||
{name = 'car', help = _U('command_car_car'), type = 'any'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand({'cardel', 'dv'}, 'admin', function(xPlayer, args, showError)
|
||||
xPlayer.triggerEvent('esx:deleteVehicle', args.radius)
|
||||
end, false, {help = _U('spawn_car'), validate = false, arguments = {
|
||||
{name = 'radius', help = 'Optional, delete every vehicle within the specified radius', type = 'any'}
|
||||
end, false, {help = _U('command_cardel'), validate = false, arguments = {
|
||||
{name = 'radius', help = _U('command_cardel_radius'), type = 'any'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('giveaccountmoney', 'admin', function(xPlayer, args, showError)
|
||||
if args.playerId.getAccount(args.account) then
|
||||
args.playerId.addAccountMoney(args.account, args.amount)
|
||||
else
|
||||
showError(_U('invalid_account'))
|
||||
showError(_U('command_giveaccountmoney_invalid'))
|
||||
end
|
||||
end, true, {help = _U('giveaccountmoney'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('id_param'), type = 'player'},
|
||||
{name = 'account', help = _U('account'), type = 'string'},
|
||||
{name = 'amount', help = _U('money_amount'), type = 'number'}
|
||||
end, true, {help = _U('command_giveaccountmoney'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
|
||||
{name = 'account', help = _U('command_giveaccountmoney_account'), type = 'string'},
|
||||
{name = 'amount', help = _U('command_giveaccountmoney_amount'), type = 'number'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, showError)
|
||||
args.playerId.addInventoryItem(args.item, args.count)
|
||||
end, true, {help = _U('giveitem'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('id_param'), type = 'player'},
|
||||
{name = 'item', help = _U('item'), type = 'item'},
|
||||
{name = 'count', help = _U('amount'), type = 'number'}
|
||||
end, true, {help = _U('command_giveitem'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
|
||||
{name = 'item', help = _U('command_giveitem_item'), type = 'item'},
|
||||
{name = 'count', help = _U('command_giveitem_count'), type = 'number'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('giveweapon', 'admin', function(xPlayer, args, showError)
|
||||
if args.playerId.hasWeapon(args.weapon) then
|
||||
showError('Player already has that weapon')
|
||||
showError(_U('command_giveweapon_hasalready'))
|
||||
else
|
||||
xPlayer.addWeapon(args.weapon, args.ammo)
|
||||
end
|
||||
end, true, {help = _U('giveweapon'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('id_param'), type = 'player'},
|
||||
{name = 'weapon', help = _U('weapon'), type = 'weapon'},
|
||||
{name = 'ammo', help = _U('amountammo'), type = 'number'}
|
||||
end, true, {help = _U('command_giveweapon'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
|
||||
{name = 'weapon', help = _U('command_giveweapon_weapon'), type = 'weapon'},
|
||||
{name = 'ammo', help = _U('command_giveweapon_ammo'), type = 'number'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('giveweaponcomponent', 'admin', function(xPlayer, args, showError)
|
||||
@@ -68,29 +68,29 @@ ESX.RegisterCommand('giveweaponcomponent', 'admin', function(xPlayer, args, show
|
||||
|
||||
if component then
|
||||
if xPlayer.hasWeaponComponent(args.weaponName, args.componentName) then
|
||||
showError('Player already has that weapon component')
|
||||
showError(_U('command_giveweaponcomponent_hasalready'))
|
||||
else
|
||||
xPlayer.addWeaponComponent(args.weaponName, args.componentName)
|
||||
end
|
||||
else
|
||||
showError('Invalid weapon component')
|
||||
showError(_U('command_giveweaponcomponent_invalid'))
|
||||
end
|
||||
else
|
||||
showError('Player does not have that weapon')
|
||||
showError(_U('command_giveweaponcomponent_missingweapon'))
|
||||
end
|
||||
end, true, {help = 'Give weapon component', validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('id_param'), type = 'player'},
|
||||
{name = 'weaponName', help = _U('weapon'), type = 'weapon'},
|
||||
{name = 'componentName', help = 'weapon component', type = 'string'}
|
||||
end, true, {help = _U('command_giveweaponcomponent'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
|
||||
{name = 'weaponName', help = _U('command_giveweapon_weapon'), type = 'weapon'},
|
||||
{name = 'componentName', help = _U('command_giveweaponcomponent_component'), type = 'string'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand({'clear', 'cls'}, 'user', function(xPlayer, args, showError)
|
||||
xPlayer.triggerEvent('chat:clear')
|
||||
end, false, {help = _U('chat_clear')})
|
||||
end, false, {help = _U('command_clear')})
|
||||
|
||||
ESX.RegisterCommand({'clearall', 'clsall'}, 'admin', function(xPlayer, args, showError)
|
||||
TriggerClientEvent('chat:clear', -1)
|
||||
end, false, {help = _U('chat_clear_all')})
|
||||
end, false, {help = _U('command_clearall')})
|
||||
|
||||
ESX.RegisterCommand('clearinventory', 'admin', function(xPlayer, args, showError)
|
||||
for k,v in ipairs(args.playerId.inventory) do
|
||||
@@ -99,7 +99,7 @@ ESX.RegisterCommand('clearinventory', 'admin', function(xPlayer, args, showError
|
||||
end
|
||||
end
|
||||
end, true, {help = _U('command_clearinventory'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('id_param'), type = 'player'}
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('clearloadout', 'admin', function(xPlayer, args, showError)
|
||||
@@ -107,5 +107,12 @@ ESX.RegisterCommand('clearloadout', 'admin', function(xPlayer, args, showError)
|
||||
args.playerId.removeWeapon(v.name)
|
||||
end
|
||||
end, true, {help = _U('command_clearloadout'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('id_param'), type = 'player'}
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('setgroup', 'admin', function(xPlayer, args, showError)
|
||||
args.playerId.setGorup(args.group)
|
||||
end, true, {help = _U('command_setgroup'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
|
||||
{name = 'group', help = _U('command_setgroup_group'), type = 'string'},
|
||||
}})
|
||||
|
||||
@@ -50,14 +50,14 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
local command = ESX.RegisteredCommands[name]
|
||||
|
||||
if not command.allowConsole and playerId == 0 then
|
||||
print('[es_extended] [^3WARNING^7] That command can not be run from console')
|
||||
print(('[es_extended] [^3WARNING^7] %s'):format(_U('commanderror_console')))
|
||||
else
|
||||
local xPlayer, error = ESX.GetPlayerFromId(playerId), nil
|
||||
|
||||
if command.suggestion then
|
||||
if command.suggestion.validate then
|
||||
if #args ~= #command.suggestion.arguments then
|
||||
error = ('Argument count mismatch (passed %s, wanted %s)'):format(#args, #command.suggestion.arguments)
|
||||
error = _U('commanderror_argumentmismatch', #args, #command.suggestion.arguments)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,7 +72,7 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
if newArg then
|
||||
newArgs[v.name] = newArg
|
||||
else
|
||||
error = ('Argument #%s type mismatch (passed string, wanted number)'):format(k)
|
||||
error = _U('commanderror_argumentmismatch_number', k)
|
||||
end
|
||||
elseif v.type == 'player' or v.type == 'playerId' then
|
||||
local targetPlayer = tonumber(args[k])
|
||||
@@ -89,10 +89,10 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
newArgs[v.name] = targetPlayer
|
||||
end
|
||||
else
|
||||
error = 'Player not online'
|
||||
error = _U('commanderror_invalidplayerid')
|
||||
end
|
||||
else
|
||||
error = ('Argument #%s type mismatch (passed string, wanted number)'):format(k)
|
||||
error = _U('commanderror_argumentmismatch_number', k)
|
||||
end
|
||||
elseif v.type == 'string' then
|
||||
newArgs[v.name] = args[k]
|
||||
@@ -100,13 +100,13 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
if ESX.Items[args[k]] then
|
||||
newArgs[v.name] = args[k]
|
||||
else
|
||||
error = _U('invalid_item')
|
||||
error = _U('commanderror_invaliditem')
|
||||
end
|
||||
elseif v.type == 'weapon' then
|
||||
if ESX.GetWeapon(args[k]) then
|
||||
newArgs[v.name] = string.upper(args[k])
|
||||
else
|
||||
error = 'Invalid weapon'
|
||||
error = _U('commanderror_invalidweapon')
|
||||
end
|
||||
elseif v.type == 'any' then
|
||||
newArgs[v.name] = args[k]
|
||||
|
||||
Reference in New Issue
Block a user