🎨 Use tables in command locales

This commit is contained in:
David Malchin
2022-08-22 03:46:52 +03:00
parent ce216ad676
commit 6513c55aa5
3 changed files with 179 additions and 147 deletions
+17 -17
View File
@@ -81,7 +81,7 @@ function QBCore.Commands.Refresh(source)
end
-- Teleport
QBCore.Commands.Add('tp', Lang:t("comm.tp"), { { name = Lang:t("comm.tp_idx"), help = Lang:t("comm.tp_idx_h") }, { name = Lang:t("comm.tp_y"), help = Lang:t("comm.tp_y_h") }, { name = Lang:t("comm.tp_z"), help = Lang:t("comm.tp_z_h") } }, false, function(source, args)
QBCore.Commands.Add('tp', Lang:t("command.tp.help"), { { name = Lang:t("command.tp.params.x.name"), help = Lang:t("command.tp.params.x.help") }, { name = Lang:t("command.tp.params.y.name"), help = Lang:t("command.tp.params.y.help") }, { name = Lang:t("command.tp.params.z.name"), help = Lang:t("command.tp.params.z.help") } }, false, function(source, args)
if args[1] and not args[2] and not args[3] then
if tonumber(args[1]) then
local target = GetPlayerPed(tonumber(args[1]))
@@ -115,18 +115,18 @@ QBCore.Commands.Add('tp', Lang:t("comm.tp"), { { name = Lang:t("comm.tp_idx"), h
end
end, 'admin')
QBCore.Commands.Add('tpm', Lang:t("comm.tpm"), {}, false, function(source)
QBCore.Commands.Add('tpm', Lang:t("command.tpm.help"), {}, false, function(source)
TriggerClientEvent('QBCore:Command:GoToMarker', source)
end, 'admin')
QBCore.Commands.Add('togglepvp', Lang:t("comm.tglpvp"), {}, false, function()
QBCore.Commands.Add('togglepvp', Lang:t("command.togglepvp.help"), {}, false, function()
QBConfig.Server.PVP = not QBConfig.Server.PVP
TriggerClientEvent('QBCore:Client:PvpHasToggled', -1, QBConfig.Server.PVP)
end, 'admin')
-- Permissions
QBCore.Commands.Add('addpermission', Lang:t("comm.addper"), { { name = Lang:t("comm.addper_id"), help = Lang:t("comm.addper_idh") }, { name = Lang:t("comm.addper_per"), help = Lang:t("comm.addper_perh") } }, true, function(source, args)
QBCore.Commands.Add('addpermission', Lang:t("command.addpermission.help"), { { name = Lang:t("command.addpermission.params.id.name"), help = Lang:t("command.addpermission.params.id.help") }, { name = Lang:t("command.addpermission.params.permission.name"), help = Lang:t("command.addpermission.params.permission.help") } }, true, function(source, args)
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
local permission = tostring(args[2]):lower()
if Player then
@@ -136,7 +136,7 @@ QBCore.Commands.Add('addpermission', Lang:t("comm.addper"), { { name = Lang:t("c
end
end, 'god')
QBCore.Commands.Add('removepermission', Lang:t("comm.rper"), { { name = Lang:t("comm.rper_id"), help = Lang:t("comm.rper_idh") }, { name = Lang:t("comm.rper_per"), help = Lang:t("comm.rper_perh") } }, true, function(source, args)
QBCore.Commands.Add('removepermission', Lang:t("command.removepermission.help"), { { name = Lang:t("command.removepermission.params.id.name"), help = Lang:t("command.removepermission.params.id.help") }, { name = Lang:t("command.removepermission.params.permission.name"), help = Lang:t("command.removepermission.params.permission.help") } }, true, function(source, args)
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
local permission = tostring(args[2]):lower()
if Player then
@@ -148,7 +148,7 @@ end, 'god')
-- Open & Close Server
QBCore.Commands.Add('openserver', Lang:t("comm.opserv"), {}, false, function(source)
QBCore.Commands.Add('openserver', Lang:t("command.openserver.help"), {}, false, function(source)
if not QBCore.Config.Server.Closed then
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.server_already_open'), 'error')
return
@@ -161,7 +161,7 @@ QBCore.Commands.Add('openserver', Lang:t("comm.opserv"), {}, false, function(sou
end
end, 'admin')
QBCore.Commands.Add('closeserver', Lang:t("comm.cserv"), {{ name = Lang:t("comm.cserv_r"), help = Lang:t("comm.cserv_rh")}}, false, function(source, args)
QBCore.Commands.Add('closeserver', Lang:t("command.closeserver.help"), {{ name = Lang:t("command.closeserver.params.reason.name"), help = Lang:t("command.closeserver.params.reason.help")}}, false, function(source, args)
if QBCore.Config.Server.Closed then
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.server_already_closed'), 'error')
return
@@ -183,17 +183,17 @@ end, 'admin')
-- Vehicle
QBCore.Commands.Add('car', Lang:t("comm.car"), {{ name = Lang:t("comm.car_m"), help = Lang:t("comm.car_mh") }}, true, function(source, args)
QBCore.Commands.Add('car', Lang:t("command.car.help"), {{ name = Lang:t("command.car.params.model.name"), help = Lang:t("command.car.params.model.help") }}, true, function(source, args)
TriggerClientEvent('QBCore:Command:SpawnVehicle', source, args[1])
end, 'admin')
QBCore.Commands.Add('dv', Lang:t("comm.dv"), {}, false, function(source)
QBCore.Commands.Add('dv', Lang:t("command.dv.help"), {}, false, function(source)
TriggerClientEvent('QBCore:Command:DeleteVehicle', source)
end, 'admin')
-- Money
QBCore.Commands.Add('givemoney', Lang:t("comm.gm"), { { name = Lang:t("comm.gm_id"), help = Lang:t("comm.gm_idh") }, { name = Lang:t("comm.gm_mt"), help = Lang:t("comm.gm_mth") }, { name = Lang:t("comm.gm_a"), help = Lang:t("comm.gm_ah") } }, true, function(source, args)
QBCore.Commands.Add('givemoney', Lang:t("command.givemoney.help"), { { name = Lang:t("command.givemoney.params.id.name"), help = Lang:t("command.givemoney.params.id.help") }, { name = Lang:t("command.givemoney.params.moneytype.name"), help = Lang:t("command.givemoney.params.moneytype.help") }, { name = Lang:t("command.givemoney.params.amount.name"), help = Lang:t("command.givemoney.params.amount.help") } }, true, function(source, args)
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
if Player then
Player.Functions.AddMoney(tostring(args[2]), tonumber(args[3]))
@@ -202,7 +202,7 @@ QBCore.Commands.Add('givemoney', Lang:t("comm.gm"), { { name = Lang:t("comm.gm_i
end
end, 'admin')
QBCore.Commands.Add('setmoney', Lang:t("comm.sm"), { { name = Lang:t("comm.sm_id"), help = Lang:t("comm.sm_idh") }, { name = Lang:t("comm.sm_mt"), help = Lang:t("comm.sm_mth") }, { name = Lang:t("comm.sm_a"), help = Lang:t("comm.sm_ah") } }, true, function(source, args)
QBCore.Commands.Add('setmoney', Lang:t("command.setmoney.help"), { { name = Lang:t("command.setmoney.params.id.name"), help = Lang:t("command.setmoney.params.id.help") }, { name = Lang:t("command.setmoney.params.moneytype.name"), help = Lang:t("command.setmoney.params.moneytype.help") }, { name = Lang:t("command.setmoney.params.amount.name"), help = Lang:t("command.setmoney.params.amount.help") } }, true, function(source, args)
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
if Player then
Player.Functions.SetMoney(tostring(args[2]), tonumber(args[3]))
@@ -213,12 +213,12 @@ end, 'admin')
-- Job
QBCore.Commands.Add('job', Lang:t("comm.job"), {}, false, function(source)
QBCore.Commands.Add('job', Lang:t("command.job.help"), {}, false, function(source)
local PlayerJob = QBCore.Functions.GetPlayer(source).PlayerData.job
TriggerClientEvent('QBCore:Notify', source, Lang:t('info.job_info', {value = PlayerJob.label, value2 = PlayerJob.grade.name, value3 = PlayerJob.onduty}))
end, 'user')
QBCore.Commands.Add('setjob', Lang:t("comm.sjob"), { { name = Lang:t("comm.sjob_id"), help = Lang:t("comm.sjob_idh") }, { name = Lang:t("comm.sjob_j"), help = Lang:t("comm.sjob_jh") }, { name = Lang:t("comm.sjob_g"), help = Lang:t("comm.sjob_gh") } }, true, function(source, args)
QBCore.Commands.Add('setjob', Lang:t("command.setjob.help"), { { name = Lang:t("command.setjob.params.id.name"), help = Lang:t("command.setjob.params.id.help") }, { name = Lang:t("command.setjob.params.job.name"), help = Lang:t("command.setjob.params.job.help") }, { name = Lang:t("command.setjob.params.grade.name"), help = Lang:t("command.setjob.params.grade.help") } }, true, function(source, args)
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
if Player then
Player.Functions.SetJob(tostring(args[2]), tonumber(args[3]))
@@ -229,12 +229,12 @@ end, 'admin')
-- Gang
QBCore.Commands.Add('gang', 'Check Your Gang', {}, false, function(source)
QBCore.Commands.Add('gang', Lang:t("command.gang.help"), {}, false, function(source)
local PlayerGang = QBCore.Functions.GetPlayer(source).PlayerData.gang
TriggerClientEvent('QBCore:Notify', source, Lang:t('info.gang_info', {value = PlayerGang.label, value2 = PlayerGang.grade.name}))
end, 'user')
QBCore.Commands.Add('setgang', Lang:t("comm.sg"), { { name = Lang:t("comm.sg_id"), help = Lang:t("comm.sg_idh") }, { name = Lang:t("comm.sg_g"), help = Lang:t("comm.sg_gh") }, { name = Lang:t("comm.sg_gr"), help = Lang:t("comm.sg_grh") } }, true, function(source, args)
QBCore.Commands.Add('setgang', Lang:t("command.setgang.help"), { { name = Lang:t("command.setgang.params.id.name"), help = Lang:t("command.setgang.params.id.help") }, { name = Lang:t("command.setgang.params.gang.name"), help = Lang:t("command.setgang.params.gang.help") }, { name = Lang:t("command.setgang.params.grade.name"), help = Lang:t("command.setgang.params.grade.help") } }, true, function(source, args)
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
if Player then
Player.Functions.SetGang(tostring(args[2]), tonumber(args[3]))
@@ -245,7 +245,7 @@ end, 'admin')
-- Out of Character Chat
QBCore.Commands.Add('ooc', 'OOC Chat Message', {}, false, function(source, args)
QBCore.Commands.Add('ooc', Lang:t("command.ooc.help"), {}, false, function(source, args)
local message = table.concat(args, ' ')
local Players = QBCore.Functions.GetPlayers()
local Player = QBCore.Functions.GetPlayer(source)
@@ -278,7 +278,7 @@ end, 'user')
-- Me command
QBCore.Commands.Add('me', Lang:t("comm.me"), {{name = Lang:t("comm.me_m"), help = Lang:t("comm.me_mh")}}, false, function(source, args)
QBCore.Commands.Add('me', Lang:t("command.me.help"), {{name = Lang:t("command.me.params.message.name"), help = Lang:t("command.me.params.message.help")}}, false, function(source, args)
if #args < 1 then TriggerClientEvent('QBCore:Notify', source, Lang:t('error.missing_args2'), 'error') return end
local ped = GetPlayerPed(source)
local pCoords = GetEntityCoords(ped)