Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions [esx_addons]/esx_adminmenu/client/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ local function getCurrentVehicle()
local vehicle = GetVehiclePedIsIn(ped, false)

if vehicle == 0 or not DoesEntityExist(vehicle) then
return nil, "You must be in a vehicle."
return nil, TranslateCap("must_be_in_vehicle")
end

return vehicle
Expand Down Expand Up @@ -318,7 +318,7 @@ local function applyVehicleCustomizations(vehicle, data)
brakeLevel = brakeLevel,
transmissionLevel = transmissionLevel,
suspensionLevel = suspensionLevel,
armorLevel = armorLevel,
armorLevel = armorLevel
}
end

Expand All @@ -330,7 +330,7 @@ local function applyVehiclePerformance(vehicle, engineLevel, brakeLevel, maxPerf
suspensionLevel = maxPerformance and 5 or vehicleLevels.suspension,
armorLevel = maxPerformance and 5 or vehicleLevels.armor,
turbo = maxPerformance and true or nil,
maxPerformance = maxPerformance,
maxPerformance = maxPerformance
})

return levels.engineLevel, levels.brakeLevel
Expand Down Expand Up @@ -394,7 +394,7 @@ local function restoreSpectatePed()
SetPlayerInvincible(PlayerId(), false)

if lastCoords then
SetEntityCoords(ped, lastCoords)
SetEntityCoords(ped, lastCoords.x, lastCoords.y, lastCoords.z, false, false, false, false)
end
end

Expand Down Expand Up @@ -606,7 +606,7 @@ local function nativeRevivePlayer()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)

NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, 0, false)
ped = PlayerPedId()
ClearPedTasksImmediately(ped)
ClearPedBloodDamage(ped)
Expand Down Expand Up @@ -780,7 +780,7 @@ end
function ClientActions.RepairVehicle()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if vehicle == 0 then
return false, "You must be in a vehicle."
return false, TranslateCap("must_be_in_vehicle")
end

SetVehicleFixed(vehicle)
Expand All @@ -794,7 +794,7 @@ end
function ClientActions.CleanVehicle()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if vehicle == 0 then
return false, "You must be in a vehicle."
return false, TranslateCap("must_be_in_vehicle")
end

SetVehicleDirtLevel(vehicle, 0.0)
Expand All @@ -805,7 +805,7 @@ end
function ClientActions.FlipVehicle()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if vehicle == 0 then
return false, "You must be in a vehicle."
return false, TranslateCap("must_be_in_vehicle")
end

SetVehicleOnGroundProperly(vehicle)
Expand All @@ -827,7 +827,7 @@ end
function ClientActions.DeleteVehicle()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if vehicle == 0 then
return false, "You must be in a vehicle."
return false, TranslateCap("must_be_in_vehicle")
end

markDeletedVehicleImpounded(vehicle)
Expand All @@ -848,7 +848,7 @@ function ClientActions.SpawnVehicle(data)

local modelHash, err = requestModel(model, { requireVehicle = true })
if not modelHash then
return false, err or "Invalid vehicle model."
return false, err or TranslateCap("invalid_vehicle_model")
end

local ped = PlayerPedId()
Expand All @@ -867,14 +867,15 @@ function ClientActions.SpawnVehicle(data)

if not vehicle or vehicle == 0 then
SetModelAsNoLongerNeeded(modelHash)
return false, "Failed to spawn vehicle."
return false, TranslateCap("failed_spawn_vehicle")
end

SetEntityAsMissionEntity(vehicle, true, true)
SetVehicleOnGroundProperly(vehicle)
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
SetVehicleNeedsToBeHotwired(vehicle, false)
SetVehRadioStation(vehicle, "OFF")
SetVehicleFuelLevel(vehicle, 100.0)

local fallbackColor = trimString(data.color)
if fallbackColor == "" then
Expand Down Expand Up @@ -917,7 +918,7 @@ function ClientActions.SpawnVehicle(data)
SetModelAsNoLongerNeeded(modelHash)

local label = Helpers and Helpers.resolveVehicleName and Helpers.resolveVehicleName(modelHash) or model
notifyAction(("Spawned %s%s."):format(label, colorLabel and (" (" .. colorLabel .. ")") or ""))
notifyAction((TranslateCap("vehicle_spawned") .. " %s%s"):format(label, colorLabel and (" (" .. colorLabel .. ")") or ""))

return true
end
Expand Down Expand Up @@ -979,7 +980,7 @@ function ClientActions.CycleVehicleColor()

local presets = getColorPresets()
if #presets == 0 then
return false, "No vehicle color presets configured."
return false, TranslateCap("no_vehicle_color_presets")
end

vehicleColorIndex = vehicleColorIndex + 1
Expand All @@ -1001,7 +1002,7 @@ function ClientActions.CycleVehicleNeonColor()

local presets = getNeonPresets()
if #presets == 0 then
return false, "No neon color presets configured."
return false, TranslateCap("no_neon_color_presets")
end

neonColorIndex = neonColorIndex + 1
Expand Down Expand Up @@ -1162,7 +1163,7 @@ RegisterNetEvent("esx-adminmenu:client:setModel", function(model)
local modelHash, err = requestModel(model)
if not modelHash then
if ESX and ESX.ShowNotification then
ESX.ShowNotification(err or "Invalid model.", "error")
ESX.ShowNotification(err or TranslateCap("invalid_model"), "error")
end
return
end
Expand All @@ -1188,7 +1189,7 @@ RegisterNetEvent("esx-adminmenu:client:setRadioChannel", function(channel)
end)

if not ok and ESX and ESX.ShowNotification then
ESX.ShowNotification("pma-voice radio export was not available.", "error")
ESX.ShowNotification(TranslateCap("pma_voice_radio_export_info"), "error")
end
end)

Expand Down
56 changes: 36 additions & 20 deletions [esx_addons]/esx_adminmenu/client/nui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ end

local function notifyClientError(err)
if ESX and ESX.ShowNotification then
ESX.ShowNotification(err or "Action failed.", "error")
ESX.ShowNotification(err or TranslateCap("action_failed"), "error")
end
end

Expand All @@ -82,7 +82,7 @@ end
local function openDashboard(cb)
xLib.callback("esx-adminmenu:server:openDashboard", false, function(res)
if not res or not res.success then
local err = getCallbackError(res, "You do not have permission to open the admin dashboard.")
local err = getCallbackError(res, TranslateCap("no_permission_open_dashboard"))
notifyClientError(err)

if cb then
Expand Down Expand Up @@ -111,7 +111,7 @@ end
local function openAdminMenu(cb)
xLib.callback("esx-adminmenu:server:canOpen", false, function(res)
if not res or not res.success then
local err = getCallbackError(res, "You do not have permission to open the admin menu.")
local err = getCallbackError(res, TranslateCap("no_permission_open_menu"))
notifyClientError(err)

if cb then
Expand Down Expand Up @@ -159,7 +159,7 @@ end

local function runProtectedClientAction(cb, label, action, permissionAction)
if not permissionAction then
cb({ success = false, err = "Missing admin action permission." })
cb({ success = false, err = TranslateCap("missing_admin_action_permission") })
return
end

Expand All @@ -176,7 +176,7 @@ local function runProtectedClientAction(cb, label, action, permissionAction)
end

if not success then
cb({ success = false, err = err or "Action failed." })
cb({ success = false, err = err or TranslateCap("action_failed") })
return
end

Expand Down Expand Up @@ -205,7 +205,7 @@ end, false)
local function runAdminCommandAction(action, handler)
checkAdminAction(action, function(res)
if not res or not res.success then
notifyClientError(getCallbackError(res, "You do not have permission to use this command."))
notifyClientError(getCallbackError(res, TranslateCap("no_permission_command")))
return
end

Expand All @@ -218,8 +218,8 @@ local function runAdminCommandAction(action, handler)
end)
end

RegisterKeyMapping("adminmenu", "Open Admin Menu", "keyboard", Config.Keybinds.AdminMenu)
RegisterKeyMapping("admindashboard", "Open Admin Dashboard", "keyboard", Config.Keybinds.AdminDashboard)
RegisterKeyMapping("adminmenu", TranslateCap("open_admin_menu"), "keyboard", Config.Keybinds.AdminMenu)
RegisterKeyMapping("admindashboard", TranslateCap("open_admin_dashboard"), "keyboard", Config.Keybinds.AdminDashboard)

xLib.nui.register("openDashboard", function(data, cb)
openDashboard(cb)
Expand Down Expand Up @@ -269,14 +269,32 @@ end
-- reference bare.
local directActions = {
{ name = "heal", permission = "heal", run = ClientActions.Heal },
{ name = "armor", permission = "armor", run = function() return ClientActions.SetArmor(100) end },
{
name = "armor",
permission = "armor",
run = function()
return ClientActions.SetArmor(100)
end
},
{ name = "repairVehicle", permission = "repairVehicle", run = ClientActions.RepairVehicle },
{ name = "cleanVehicle", permission = "cleanVehicle", run = ClientActions.CleanVehicle },
{ name = "deleteVehicle", permission = "deleteVehicle", run = ClientActions.DeleteVehicle },
{ name = "waypoint", permission = "waypoint", run = ClientActions.TeleportToWaypoint },
{ name = "spawnVehicle", permission = "spawnVehicle", run = function(data) return ClientActions.SpawnVehicle(data or {}) end },
{
name = "spawnVehicle",
permission = "spawnVehicle",
run = function(data)
return ClientActions.SpawnVehicle(data or {})
end
},
{ name = "flipVehicle", permission = "flipVehicle", run = ClientActions.FlipVehicle },
{ name = "customizeVehicle", permission = "customizeVehicle", run = function(data) return ClientActions.CustomizeVehicle(data or {}) end },
{
name = "customizeVehicle",
permission = "customizeVehicle",
run = function(data)
return ClientActions.CustomizeVehicle(data or {})
end
},
{ name = "copyCoords", permission = "copyCoords", run = ClientActions.CopyCoords },
{ name = "cycleVehicleTransmission", permission = "transmissionLevel", run = ClientActions.CycleVehicleTransmission },
{ name = "cycleVehicleSuspension", permission = "suspensionLevel", run = ClientActions.CycleVehicleSuspension },
Expand Down Expand Up @@ -310,10 +328,8 @@ xLib.nui.register("adminMenu:setVehiclePerformance", function(data, cb)
runProtectedClientAction(cb, "[esx-adminmenu:setVehiclePerformance]", function()
local success, err, extra = ClientActions.SetVehiclePerformance(data or {})
if success then
sendQuickMenuState("engineLevel", true,
data and data.engineLevel and (tostring(data.engineLevel) .. "/5") or nil)
sendQuickMenuState("brakeLevel", true,
data and data.brakeLevel and (tostring(data.brakeLevel) .. "/5") or nil)
sendQuickMenuState("engineLevel", true, data and data.engineLevel and (tostring(data.engineLevel) .. "/5") or nil)
sendQuickMenuState("brakeLevel", true, data and data.brakeLevel and (tostring(data.brakeLevel) .. "/5") or nil)
end

return success, err, extra
Expand Down Expand Up @@ -606,7 +622,7 @@ end)
RegisterNetEvent("esx-adminmenu:client:copyToClipboard", function(text)
xLib.nui.send({
action = "copyToClipboard",
data = text,
data = text
})
end)

Expand All @@ -616,8 +632,8 @@ RegisterNetEvent("esx-adminmenu:client:open", function(data)
xLib.nui.send({
action = "openAdminDashboard",
data = {
players = data or {},
},
players = data or {}
}
})
end)

Expand All @@ -634,8 +650,8 @@ RegisterNetEvent("esx-adminmenu:client:openInformation", function(data)
data = {
players = data.players or {},
selectedPlayerId = data.selectedPlayerId,
serverData = data.serverData,
},
serverData = data.serverData
}
})
end)

Expand Down
Loading
Loading