diff --git a/server-data/resources/[esx]/es_extended/client/main.lua b/server-data/resources/[esx]/es_extended/client/main.lua index 657c4503d..f59f29ef0 100644 --- a/server-data/resources/[esx]/es_extended/client/main.lua +++ b/server-data/resources/[esx]/es_extended/client/main.lua @@ -22,7 +22,7 @@ function ESX.SpawnPlayer(skin, coords, cb) p:resolve() end) Citizen.Await(p) - + local playerPed = PlayerPedId() FreezeEntityPosition(playerPed, true) SetEntityCoordsNoOffset(playerPed, coords.x, coords.y, coords.z, false, false, false, true) @@ -54,7 +54,7 @@ AddEventHandler("esx:playerLoaded", function(xPlayer, _, skin) while not DoesEntityExist(ESX.PlayerData.ped) do Wait(20) end - + ESX.PlayerLoaded = true local metadata = ESX.PlayerData.metadata diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua index 64d823b38..a71db3fa2 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua @@ -1,18 +1,18 @@ local CurrentAction, CurrentActionMsg, CurrentActionData = nil, "", {} local HasAlreadyEnteredMarker, LastHospital, LastPart, LastPartNum -local isBusy, deadPlayers, deadPlayerBlips, isOnDuty = false, {}, {}, false +local isBusy, deadPlayers, deadPlayerBlips, isOnDuty, vehicle = false, {}, {}, false, {} isInShopMenu = false function OpenAmbulanceActionsMenu() local elements = { { unselectable = true, icon = "fas fa-shirt", title = "Ambulance Actions" }, - { icon = "fas fa-shirt", title = _U("cloakroom"), value = "cloakroom" }, + { icon = "fas fa-shirt", title = TranslateCap("cloakroom"), value = "cloakroom" }, } if Config.EnablePlayerManagement and ESX.PlayerData.job.grade_name == "boss" then elements[#elements + 1] = { icon = "fas fa-ambulance", - title = _U("boss_actions"), + title = TranslateCap("boss_actions"), value = "boss_actions", } end @@ -30,20 +30,20 @@ end function OpenMobileAmbulanceActionsMenu() local elements = { - { unselectable = true, icon = "fas fa-ambulance", title = _U("ambulance") }, - { icon = "fas fa-ambulance", title = _U("ems_menu"), value = "citizen_interaction" }, + { unselectable = true, icon = "fas fa-ambulance", title = TranslateCap("ambulance") }, + { icon = "fas fa-ambulance", title = TranslateCap("ems_menu"), value = "citizen_interaction" }, } ESX.OpenContext("right", elements, function(_, element) if element.value == "citizen_interaction" then local elements2 = { { unselectable = true, icon = "fas fa-ambulance", title = element.title }, - { icon = "fas fa-syringe", title = _U("ems_menu_revive"), value = "revive" }, - { icon = "fas fa-bandage", title = _U("ems_menu_small"), value = "small" }, - { icon = "fas fa-bandage", title = _U("ems_menu_big"), value = "big" }, - { icon = "fas fa-car", title = _U("ems_menu_putincar"), value = "put_in_vehicle" }, - { icon = "fas fa-syringe", title = _U("ems_menu_search"), value = "search" }, - { icon = "fas fa-syringe", title = _U("billing"), value = "billing" }, + { icon = "fas fa-syringe", title = TranslateCap("ems_menu_revive"), value = "revive" }, + { icon = "fas fa-bandage", title = TranslateCap("ems_menu_small"), value = "small" }, + { icon = "fas fa-bandage", title = TranslateCap("ems_menu_big"), value = "big" }, + { icon = "fas fa-car", title = TranslateCap("ems_menu_putincar"), value = "put_in_vehicle" }, + { icon = "fas fa-syringe", title = TranslateCap("ems_menu_search"), value = "search" }, + { icon = "fas fa-syringe", title = TranslateCap("billing"), value = "billing" }, } ESX.OpenContext("right", elements2, function(_, element2) @@ -56,7 +56,7 @@ function OpenMobileAmbulanceActionsMenu() if element2.value == "search" then TriggerServerEvent("esx_ambulancejob:svsearch") elseif closestPlayer == -1 or closestDistance > 1.0 then - ESX.ShowNotification(_U("no_players")) + ESX.ShowNotification(TranslateCap("no_players")) else if element2.value == "revive" then revivePlayer(closestPlayer) @@ -70,7 +70,7 @@ function OpenMobileAmbulanceActionsMenu() local playerPed = PlayerPedId() isBusy = true - ESX.ShowNotification(_U("heal_inprogress")) + ESX.ShowNotification(TranslateCap("heal_inprogress")) TaskStartScenarioInPlace(playerPed, "CODE_HUMAN_MEDIC_TEND_TO_DEAD", 0, true) Wait(10000) ClearPedTasks(playerPed) @@ -81,13 +81,13 @@ function OpenMobileAmbulanceActionsMenu() GetPlayerServerId(closestPlayer), "small" ) - ESX.ShowNotification(_U("heal_complete", GetPlayerName(closestPlayer))) + ESX.ShowNotification(TranslateCap("heal_complete", GetPlayerName(closestPlayer))) isBusy = false else - ESX.ShowNotification(_U("player_not_conscious")) + ESX.ShowNotification(TranslateCap("player_not_conscious")) end else - ESX.ShowNotification(_U("not_enough_bandage")) + ESX.ShowNotification(TranslateCap("not_enough_bandage")) end end, "bandage") elseif element2.value == "big" then @@ -100,20 +100,20 @@ function OpenMobileAmbulanceActionsMenu() local playerPed = PlayerPedId() isBusy = true - ESX.ShowNotification(_U("heal_inprogress")) + ESX.ShowNotification(TranslateCap("heal_inprogress")) TaskStartScenarioInPlace(playerPed, "CODE_HUMAN_MEDIC_TEND_TO_DEAD", 0, true) Wait(10000) ClearPedTasks(playerPed) TriggerServerEvent("esx_ambulancejob:removeItem", "medikit") TriggerServerEvent("esx_ambulancejob:heal", GetPlayerServerId(closestPlayer), "big") - ESX.ShowNotification(_U("heal_complete", GetPlayerName(closestPlayer))) + ESX.ShowNotification(TranslateCap("heal_complete", GetPlayerName(closestPlayer))) isBusy = false else - ESX.ShowNotification(_U("player_not_conscious")) + ESX.ShowNotification(TranslateCap("player_not_conscious")) end else - ESX.ShowNotification(_U("not_enough_medikit")) + ESX.ShowNotification(TranslateCap("not_enough_medikit")) end end, "medikit") elseif element2.value == "put_in_vehicle" then @@ -130,16 +130,16 @@ local billing if billing == "billing" then ESX.UI.Menu.Open("dialog", GetCurrentResourceName(), "billing", { - title = _U("invoice_amount"), + title = TranslateCap("invoice_amount"), }, function(data, menu) local amount = tonumber(data.value) if amount == nil then - ESX.ShowNotification(_U("amount_invalid")) + ESX.ShowNotification(TranslateCap("amount_invalid")) else menu.close() local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U("no_players_near")) + ESX.ShowNotification(TranslateCap("no_players_near")) else TriggerServerEvent( "esx_billing:sendBill", @@ -148,7 +148,7 @@ if billing == "billing" then "Ambulance", amount ) - ESX.ShowNotification(_U("billing_sent")) + ESX.ShowNotification(TranslateCap("billing_sent")) end end end, function(_, menu) @@ -167,7 +167,7 @@ function revivePlayer(closestPlayer) if IsPedDeadOrDying(closestPlayerPed, 1) then local playerPed = PlayerPedId() local lib, anim = "mini@cpr@char_a@cpr_str", "cpr_pumpchest" - ESX.ShowNotification(_U("revive_inprogress")) + ESX.ShowNotification(TranslateCap("revive_inprogress")) for _ = 1, 15 do Wait(900) @@ -180,10 +180,10 @@ function revivePlayer(closestPlayer) TriggerServerEvent("esx_ambulancejob:removeItem", "medikit") TriggerServerEvent("esx_ambulancejob:revive", GetPlayerServerId(closestPlayer)) else - ESX.ShowNotification(_U("player_not_unconscious")) + ESX.ShowNotification(TranslateCap("player_notTranslateCapnconscious")) end else - ESX.ShowNotification(_U("not_enough_medikit")) + ESX.ShowNotification(TranslateCap("not_enough_medikit")) end isBusy = false end, "medikit") @@ -422,15 +422,15 @@ end) AddEventHandler("esx_ambulancejob:hasEnteredMarker", function(hospital, part, partNum) if part == "AmbulanceActions" then CurrentAction = part - CurrentActionMsg = _U("actions_prompt") + CurrentActionMsg = TranslateCap("actions_prompt") CurrentActionData = {} elseif part == "Vehicles" then CurrentAction = part - CurrentActionMsg = _U("garage_prompt") + CurrentActionMsg = TranslateCap("garage_prompt") CurrentActionData = { hospital = hospital, partNum = partNum } elseif part == "Helicopters" then CurrentAction = part - CurrentActionMsg = _U("helicopter_prompt") + CurrentActionMsg = TranslateCap("helicopter_prompt") CurrentActionData = { hospital = hospital, partNum = partNum } end end) @@ -504,9 +504,9 @@ end) function OpenCloakroomMenu() local elements = { - { unselectable = true, icon = "fas fa-shirt", title = _U("cloakroom") }, - { icon = "fas fa-shirt", title = _U("ems_clothes_civil"), value = "citizen_wear" }, - { icon = "fas fa-shirt", title = _U("ems_clothes_ems"), value = "ambulance_wear" }, + { unselectable = true, icon = "fas fa-shirt", title = TranslateCap("cloakroom") }, + { icon = "fas fa-shirt", title = TranslateCap("ems_clothes_civil"), value = "citizen_wear" }, + { icon = "fas fa-shirt", title = TranslateCap("ems_clothes_ems"), value = "ambulance_wear" }, } ESX.OpenContext("right", elements, function(_, element) @@ -549,7 +549,7 @@ AddEventHandler("esx_ambulancejob:heal", function(healType, quiet) end if not quiet then - ESX.ShowNotification(_U("healed")) + ESX.ShowNotification(TranslateCap("healed")) end end) @@ -587,7 +587,7 @@ AddEventHandler("esx_ambulancejob:setDeadPlayers", function(_deadPlayers) SetBlipCategory(blip, 7) BeginTextCommandSetBlipName("STRING") - AddTextComponentSubstringPlayerName(_U("blip_dead")) + AddTextComponentSubstringPlayerName(TranslateCap("blip_dead")) EndTextCommandSetBlipName(blip) deadPlayerBlips[playerId] = blip diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua index 51844b155..10ef47fb3 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua @@ -60,7 +60,7 @@ CreateThread(function() SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") - AddTextComponentSubstringPlayerName(_U("blip_hospital")) + AddTextComponentSubstringPlayerName(TranslateCap("blip_hospital")) EndTextCommandSetBlipName(blip) end end) @@ -161,7 +161,7 @@ AddEventHandler("esx_ambulancejob:useItem", function(itemName) end TriggerEvent("esx_ambulancejob:heal", "big", true) - ESX.ShowNotification(_U("used_medikit")) + ESX.ShowNotification(TranslateCap("used_medikit")) end) elseif itemName == "bandage" then local lib, anim = "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01" -- TODO better animations @@ -177,7 +177,7 @@ AddEventHandler("esx_ambulancejob:useItem", function(itemName) end TriggerEvent("esx_ambulancejob:heal", "small", true) - ESX.ShowNotification(_U("used_bandage")) + ESX.ShowNotification(TranslateCap("used_bandage")) end) end end) @@ -197,7 +197,7 @@ function StartDistressSignal() SetTextDropShadow() SetTextOutline() BeginTextCommandDisplayText("STRING") - AddTextComponentSubstringPlayerName(_U("distress_send")) + AddTextComponentSubstringPlayerName(TranslateCap("distress_send")) EndTextCommandDisplayText(0.175, 0.805) if IsControlJustReleased(0, 47) then @@ -212,7 +212,7 @@ function SendDistressSignal() local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) - ESX.ShowNotification(_U("distress_sent")) + ESX.ShowNotification(TranslateCap("distress_sent")) TriggerServerEvent("esx_ambulancejob:onPlayerDistress") end @@ -278,7 +278,7 @@ function StartDeathTimer() -- early respawn timer while earlySpawnTimer > 0 and isDead do Wait(0) - text = _U("respawn_available_in", secondsToClock(earlySpawnTimer)) + text = TranslateCap("respawn_available_in", secondsToClock(earlySpawnTimer)) DrawGenericTextThisFrame() @@ -290,17 +290,17 @@ function StartDeathTimer() -- bleedout timer while bleedoutTimer > 0 and isDead do Wait(0) - text = _U("respawn_bleedout_in", secondsToClock(bleedoutTimer)) + text = TranslateCap("respawn_bleedout_in", secondsToClock(bleedoutTimer)) if not Config.EarlyRespawnFine then - text = text .. _U("respawn_bleedout_prompt") + text = text .. TranslateCap("respawn_bleedout_prompt") if IsControlPressed(0, 38) and timeHeld > 60 then RemoveItemsAfterRPDeath() break end elseif Config.EarlyRespawnFine and canPayFine then - text = text .. _U("respawn_bleedout_fine", ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount)) + text = text .. TranslateCap("respawn_bleedout_fine", ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount)) if IsControlPressed(0, 38) and timeHeld > 60 then TriggerServerEvent("esx_ambulancejob:payFine") diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua index f87f6421c..30bb24b4b 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua @@ -3,10 +3,10 @@ local spawnedVehicles = {} function OpenVehicleSpawnerMenu(type, hospital, part, partNum) local playerCoords = GetEntityCoords(PlayerPedId()) local elements = { - { unselectable = true, icon = "fas fa-car", title = _U("garage_title") }, - { icon = "fas fa-car", title = _U("garage_storeditem"), action = "garage" }, - { icon = "fas fa-car", title = _U("garage_storeitem"), action = "store_garage" }, - { icon = "fas fa-car", title = _U("garage_buyitem"), action = "buy_vehicle" }, + { unselectable = true, icon = "fas fa-car", title = TranslateCap("garage_title") }, + { icon = "fas fa-car", title = TranslateCap("garage_storeditem"), action = "garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_storeitem"), action = "store_garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_buyitem"), action = "buy_vehicle" }, } ESX.OpenContext("right", elements, function(_, element) if element.action == "buy_vehicle" then @@ -23,7 +23,7 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) icon = "fas fa-car", title = ('%s - %s'):format( vehicleLabel, - _U("shop_item", ESX.Math.GroupDigits(vehicle.price)) + TranslateCap("shop_item", ESX.Math.GroupDigits(vehicle.price)) ), name = vehicleLabel, model = vehicle.model, @@ -37,10 +37,10 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) if #shopElements > 0 then OpenShopMenu(shopElements, playerCoords, shopCoords) else - ESX.ShowNotification(_U("garage_notauthorized")) + ESX.ShowNotification(TranslateCap("garage_notauthorized")) end else - ESX.ShowNotification(_U("garage_notauthorized")) + ESX.ShowNotification(TranslateCap("garage_notauthorized")) end elseif element.action == "garage" then local garage = { @@ -62,10 +62,10 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) ) if v.stored then - label = label .. ('%s'):format(_U("garage_stored")) + label = label .. ('%s'):format(TranslateCap("garage_stored")) else label = label - .. ('%s'):format(_U("garage_notstored")) + .. ('%s'):format(TranslateCap("garage_notstored")) end garage[#garage + 1] = { @@ -100,19 +100,19 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) elementG.plate, false ) - ESX.ShowNotification(_U("garage_released")) + ESX.ShowNotification(TranslateCap("garage_released")) end ) end else - ESX.ShowNotification(_U("garage_notavailable")) + ESX.ShowNotification(TranslateCap("garage_notavailable")) end end) else - ESX.ShowNotification(_U("garage_empty")) + ESX.ShowNotification(TranslateCap("garage_empty")) end else - ESX.ShowNotification(_U("garage_empty")) + ESX.ShowNotification(TranslateCap("garage_empty")) end end, type) elseif element.action == "store_garage" then @@ -135,7 +135,7 @@ function StoreNearbyVehicle(playerCoords) end end else - ESX.ShowNotification(_U("garage_store_nearby")) + ESX.ShowNotification(TranslateCap("garage_store_nearby")) return end @@ -149,7 +149,7 @@ function StoreNearbyVehicle(playerCoords) CreateThread(function() while isBusy do Wait(0) - drawLoadingText(_U("garage_storing"), 255, 255, 255, 255) + drawLoadingText(TranslateCap("garage_storing"), 255, 255, 255, 255) end end) @@ -175,9 +175,9 @@ function StoreNearbyVehicle(playerCoords) end isBusy = false - ESX.ShowNotification(_U("garage_has_stored")) + ESX.ShowNotification(TranslateCap("garage_has_stored")) else - ESX.ShowNotification(_U("garage_has_notstored")) + ESX.ShowNotification(TranslateCap("garage_has_notstored")) end end, vehiclePlates) end @@ -196,7 +196,7 @@ function GetAvailableVehicleSpawnPoint(hospital, part, partNum) if found then return true, foundSpawnPoint else - ESX.ShowNotification(_U("garage_blocked")) + ESX.ShowNotification(TranslateCap("garage_blocked")) return false end end @@ -251,7 +251,7 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) ESX.TriggerServerCallback("esx_ambulancejob:buyJobVehicle", function(bought) if bought then ESX.ShowNotification( - _U("vehicleshop_bought", element.name, ESX.Math.GroupDigits(element.price)) + TranslateCap("vehicleshop_bought", element.name, ESX.Math.GroupDigits(element.price)) ) isInShopMenu = false @@ -262,7 +262,7 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) ESX.Game.Teleport(playerPed, restoreCoords) else - ESX.ShowNotification(_U("vehicleshop_money")) + ESX.ShowNotification(TranslateCap("vehicleshop_money")) ESX.CloseContext() end end, props, element.type) @@ -301,7 +301,7 @@ function WaitForVehicleToLoad(modelHash) RequestModel(modelHash) BeginTextCommandBusyspinnerOn("STRING") - AddTextComponentSubstringPlayerName(_U("vehicleshop_awaiting_model")) + AddTextComponentSubstringPlayerName(TranslateCap("vehicleshop_awaiting_model")) EndTextCommandBusyspinnerOn(4) while not HasModelLoaded(modelHash) do diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua index cb6dac6d1..5ace2dc5f 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua @@ -22,18 +22,18 @@ AddEventHandler("esx_ambulancejob:revive", function(playerId) if xTarget then if deadPlayers[playerId] then if Config.ReviveReward > 0 then - xPlayer.showNotification(_U("revive_complete_award", xTarget.name, Config.ReviveReward)) + xPlayer.showNotification(TranslateCap("revive_complete_award", xTarget.name, Config.ReviveReward)) xPlayer.addMoney(Config.ReviveReward, "Revive Reward") xTarget.triggerEvent("esx_ambulancejob:revive") else - xPlayer.showNotification(_U("revive_complete", xTarget.name)) + xPlayer.showNotification(TranslateCap("revive_complete", xTarget.name)) xTarget.triggerEvent("esx_ambulancejob:revive") end else - xPlayer.showNotification(_U("player_not_unconscious")) + xPlayer.showNotification(TranslateCap("player_notTranslateCapnconscious")) end else - xPlayer.showNotification(_U("revive_fail_offline")) + xPlayer.showNotification(TranslateCap("revive_fail_offline")) end end end) @@ -148,7 +148,7 @@ if Config.EarlyRespawnFine then local xPlayer = ESX.GetPlayerFromId(source) local fineAmount = Config.EarlyRespawnFineAmount - xPlayer.showNotification(_U("respawn_bleedout_fine_msg", ESX.Math.GroupDigits(fineAmount))) + xPlayer.showNotification(TranslateCap("respawn_bleedout_fine_msg", ESX.Math.GroupDigits(fineAmount))) xPlayer.removeAccountMoney("bank", fineAmount, "Respawn Fine") end) end @@ -250,9 +250,9 @@ AddEventHandler("esx_ambulancejob:removeItem", function(item) xPlayer.removeInventoryItem(item, 1) if item == "bandage" then - xPlayer.showNotification(_U("used_bandage")) + xPlayer.showNotification(TranslateCap("used_bandage")) elseif item == "medikit" then - xPlayer.showNotification(_U("used_medikit")) + xPlayer.showNotification(TranslateCap("used_medikit")) end end) @@ -271,7 +271,7 @@ AddEventHandler("esx_ambulancejob:giveItem", function(itemName, amount) if xPlayer.canCarryItem(itemName, amount) then xPlayer.addInventoryItem(itemName, amount) else - xPlayer.showNotification(_U("max_item")) + xPlayer.showNotification(TranslateCap("max_item")) end end) @@ -283,7 +283,7 @@ ESX.RegisterCommand( end, true, { - help = _U("revive_help"), + help = TranslateCap("revive_help"), validate = true, arguments = { { name = "playerId", help = "The player id", type = "player" }, diff --git a/server-data/resources/[esx_addons]/esx_boat/client/main.lua b/server-data/resources/[esx_addons]/esx_boat/client/main.lua index 4e8b67a13..d1a1cb7e2 100644 --- a/server-data/resources/[esx_addons]/esx_boat/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_boat/client/main.lua @@ -6,7 +6,7 @@ function OpenBoatShop(shop) local playerPed = PlayerPedId() local elements = { - { unselectable = true, icon = "fas fa-ship", title = _U("boat_shop") }, + { unselectable = true, icon = "fas fa-ship", title = TranslateCap("boat_shop") }, } for _, v in ipairs(Config.Vehicles) do @@ -55,7 +55,7 @@ function OpenBoatShop(shop) ESX.TriggerServerCallback("esx_boat:buyBoat", function(bought) if bought then ESX.ShowNotification( - _U("boat_shop_bought", element.name, ESX.Math.GroupDigits(element.price)) + TranslateCap("boat_shop_bought", element.name, ESX.Math.GroupDigits(element.price)) ) DeleteSpawnedVehicles() @@ -63,13 +63,13 @@ function OpenBoatShop(shop) ESX.CloseContext() CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") FreezeEntityPosition(playerPed, false) SetEntityVisible(playerPed, true) SetEntityCoords(playerPed, shop.Outside.x, shop.Outside.y, shop.Outside.z) else - ESX.ShowNotification(_U("boat_shop_nomoney")) + ESX.ShowNotification(TranslateCap("boat_shop_nomoney")) end end, props) elseif element3.value == "stop" then @@ -83,23 +83,23 @@ function OpenBoatShop(shop) end, function() isInShopMenu = false CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end, function() isInShopMenu = false CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end function OpenBoatGarage(garage) ESX.TriggerServerCallback("esx_boat:getGarage", function(ownedBoats) if #ownedBoats == 0 then - ESX.ShowNotification(_U("garage_noboats")) + ESX.ShowNotification(TranslateCap("garage_noboats")) else -- get all available boats local elements = { - { unselectable = true, icon = "fas fa-ship", title = _U("garage") }, + { unselectable = true, icon = "fas fa-ship", title = TranslateCap("garage") }, } for i = 1, #ownedBoats, 1 do ownedBoats[i] = json.decode(ownedBoats[i]) @@ -117,7 +117,7 @@ function OpenBoatGarage(garage) if ESX.Game.IsSpawnPointClear(garage.SpawnPoint, 4.0) then TriggerServerEvent("esx_boat:takeOutVehicle", vehicleProps.plate) - ESX.ShowNotification(_U("garage_taken")) + ESX.ShowNotification(TranslateCap("garage_taken")) ESX.Game.SpawnVehicle(vehicleProps.model, garage.SpawnPoint, garage.SpawnPoint.w, function(vehicle) TaskWarpPedIntoVehicle(playerPed, vehicle, -1) @@ -126,11 +126,11 @@ function OpenBoatGarage(garage) ESX.CloseContext() else - ESX.ShowNotification(_U("garage_blocked")) + ESX.ShowNotification(TranslateCap("garage_blocked")) end end, function() CurrentAction = "garage_out" - CurrentActionMsg = _U("garage_open") + CurrentActionMsg = TranslateCap("garage_open") end) end end) @@ -138,15 +138,15 @@ end function OpenLicenceMenu(shop) local elements = { - { unselectable = true, icon = "fas fa-ship", title = _U("license_menu") }, + { unselectable = true, icon = "fas fa-ship", title = TranslateCap("license_menu") }, { icon = "fas fa-ship", title = "Purchase Boat License" }, } ESX.OpenContext("right", elements, function(_, element) local elements2 = { { unselectable = true, icon = "fas fa-ship", title = element.title }, - { icon = "fas fa-check-double", title = _U("license_buy_yes", Config.LicensePrice), val = "yes" }, - { icon = "fas fa-window-close", title = _U("license_buy_no"), val = "no" }, + { icon = "fas fa-check-double", title = TranslateCap("license_buy_yes", Config.LicensePrice), val = "yes" }, + { icon = "fas fa-window-close", title = TranslateCap("license_buy_no"), val = "no" }, } ESX.OpenContext("right", elements2, function(_, element2) @@ -158,21 +158,21 @@ function OpenLicenceMenu(shop) ESX.TriggerServerCallback("esx_boat:buyBoatLicense", function(boughtLicense) if boughtLicense then - ESX.ShowNotification(_U("license_bought", ESX.Math.GroupDigits(Config.LicensePrice))) + ESX.ShowNotification(TranslateCap("license_bought", ESX.Math.GroupDigits(Config.LicensePrice))) ESX.CloseContext() OpenBoatShop(shop) -- parse current shop else - ESX.ShowNotification(_U("license_nomoney")) + ESX.ShowNotification(TranslateCap("license_nomoney")) end end) end, function() CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end, function() CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end @@ -182,14 +182,14 @@ function StoreBoatInGarage(vehicle, teleportCoords) ESX.TriggerServerCallback("esx_boat:storeVehicle", function(rowsChanged) if rowsChanged > 0 then ESX.Game.DeleteVehicle(vehicle) - ESX.ShowNotification(_U("garage_stored")) + ESX.ShowNotification(TranslateCap("garage_stored")) local playerPed = PlayerPedId() ESX.Game.Teleport(playerPed, teleportCoords, function() SetEntityHeading(playerPed, teleportCoords.w) end) else - ESX.ShowNotification(_U("garage_notowner")) + ESX.ShowNotification(TranslateCap("garage_notowner")) end end, vehicleProps.plate) end @@ -234,7 +234,7 @@ function reset(shop) local playerPed = PlayerPedId() isInShopMenu = false CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") DeleteSpawnedVehicles() FreezeEntityPosition(playerPed, false) SetEntityVisible(playerPed, true) diff --git a/server-data/resources/[esx_addons]/esx_boat/client/marker.lua b/server-data/resources/[esx_addons]/esx_boat/client/marker.lua index 6874b750f..b8ccee1dd 100644 --- a/server-data/resources/[esx_addons]/esx_boat/client/marker.lua +++ b/server-data/resources/[esx_addons]/esx_boat/client/marker.lua @@ -1,5 +1,4 @@ -local HasAlreadyEnteredMarker = false -local LastZone = nil +local HasAlreadyEnteredMarker, LastZone, LastZoneNum = false, nil, {} CurrentAction = nil CurrentActionMsg = "" @@ -45,11 +44,11 @@ end) AddEventHandler("esx_boat:hasEnteredMarker", function(zone, zoneNum) if zone == "boat_shop" then CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") CurrentActionData = { zoneNum = zoneNum } elseif zone == "garage_out" then CurrentAction = "garage_out" - CurrentActionMsg = _U("garage_open") + CurrentActionMsg = TranslateCap("garage_open") CurrentActionData = { zoneNum = zoneNum } elseif zone == "garage_in" then local playerPed = PlayerPedId() @@ -60,7 +59,7 @@ AddEventHandler("esx_boat:hasEnteredMarker", function(zone, zoneNum) if DoesEntityExist(vehicle) and GetPedInVehicleSeat(vehicle, -1) == playerPed then CurrentAction = "garage_in" - CurrentActionMsg = _U("garage_store") + CurrentActionMsg = TranslateCap("garage_store") CurrentActionData = { vehicle = vehicle, zoneNum = zoneNum } end end @@ -235,7 +234,7 @@ CreateThread(function() for i = 1, #Config.Zones.Garages, 1 do table.insert(blipList, { coords = Config.Zones.Garages[i].GaragePos, - text = _U("blip_garage"), + text = TranslateCap("blip_garage"), sprite = 356, color = 3, scale = 1.0, @@ -245,7 +244,7 @@ CreateThread(function() for i = 1, #Config.Zones.BoatShops, 1 do table.insert(blipList, { coords = Config.Zones.BoatShops[i].Outside, - text = _U("blip_shop"), + text = TranslateCap("blip_shop"), sprite = 427, color = 3, scale = 1.0, diff --git a/server-data/resources/[esx_addons]/esx_policejob/client/main.lua b/server-data/resources/[esx_addons]/esx_policejob/client/main.lua index 16aa6c845..88072a59a 100644 --- a/server-data/resources/[esx_addons]/esx_policejob/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_policejob/client/main.lua @@ -1,5 +1,6 @@ -local CurrentActionData, handcuffTimer, dragStatus, blipsCops, currentTask = {}, {}, {}, {}, {} -local HasAlreadyEnteredMarker, isDead, isHandcuffed, hasAlreadyJoined, playerInService = false, false, false, false, false +local CurrentActionData, handcuffTimer, dragStatus, blipsCops, currentTask, sex, action = {}, {}, {}, {}, {}, {}, {} +local HasAlreadyEnteredMarker, isDead, isHandcuffed, hasAlreadyJoined, playerInService = + false, false, false, false, false local LastStation, LastPart, LastPartNum, LastEntity, CurrentAction, CurrentActionMsg dragStatus.isDragged, isInShopMenu = false, false @@ -12,21 +13,21 @@ function cleanPlayer(playerPed) end function setUniform(uniform, playerPed) - TriggerEvent('skinchanger:getSkin', function(skin) + TriggerEvent("skinchanger:getSkin", function(skin) local uniformObject - + sex = (skin.sex == 0) and "male" or "female" uniformObject = Config.Uniforms[uniform][sex] if uniformObject then - TriggerEvent('skinchanger:loadClothes', skin, uniformObject) + TriggerEvent("skinchanger:loadClothes", skin, uniformObject) - if uniform == 'bullet_wear' then + if uniform == "bullet_wear" then SetPedArmour(playerPed, 100) end else - ESX.ShowNotification(TranslateCap('no_outfit')) + ESX.ShowNotification(TranslateCap("no_outfit")) end end) end @@ -36,126 +37,127 @@ function OpenCloakroomMenu() local grade = ESX.PlayerData.job.grade_name local elements = { - {unselectable = true, icon = "fas fa-shirt", title = TranslateCap("cloakroom")}, - {icon = "fas fa-shirt", title = TranslateCap('citizen_wear'), value = 'citizen_wear'}, - {icon = "fas fa-shirt", title = TranslateCap('bullet_wear'), uniform = 'bullet_wear'}, - {icon = "fas fa-shirt", title = TranslateCap('gilet_wear'), uniform = 'gilet_wear'}, - {icon = "fas fa-shirt", title = TranslateCap('police_wear'), uniform = grade} + { unselectable = true, icon = "fas fa-shirt", title = TranslateCap("cloakroom") }, + { icon = "fas fa-shirt", title = TranslateCap("citizen_wear"), value = "citizen_wear" }, + { icon = "fas fa-shirt", title = TranslateCap("bullet_wear"), uniform = "bullet_wear" }, + { icon = "fas fa-shirt", title = TranslateCap("gilet_wear"), uniform = "gilet_wear" }, + { icon = "fas fa-shirt", title = TranslateCap("police_wear"), uniform = grade }, } if Config.EnableCustomPeds then - for k,v in ipairs(Config.CustomPeds.shared) do - elements[#elements+1] = { + for _, v in ipairs(Config.CustomPeds.shared) do + elements[#elements + 1] = { icon = "fas fa-shirt", - title = v.label, - value = 'freemode_ped', - maleModel = v.maleModel, - femaleModel = v.femaleModel + title = v.label, + value = "freemode_ped", + maleModel = v.maleModel, + femaleModel = v.femaleModel, } end - for k,v in ipairs(Config.CustomPeds[grade]) do - elements[#elements+1] = { + for _, v in ipairs(Config.CustomPeds[grade]) do + elements[#elements + 1] = { icon = "fas fa-shirt", - title = v.label, - value = 'freemode_ped', - maleModel = v.maleModel, - femaleModel = v.femaleModel + title = v.label, + value = "freemode_ped", + maleModel = v.maleModel, + femaleModel = v.femaleModel, } end end - ESX.OpenContext("right", elements, function(menu,element) + ESX.OpenContext("right", elements, function(menu, element) cleanPlayer(playerPed) - local data = {current = element} + local data = { current = element } - if data.current.value == 'citizen_wear' then + if data.current.value == "citizen_wear" then if Config.EnableCustomPeds then - ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) + ESX.TriggerServerCallback("esx_skin:getPlayerSkin", function(skin, jobSkin) local isMale = skin.sex == 0 - TriggerEvent('skinchanger:loadDefaultModel', isMale, function() - ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin) - TriggerEvent('skinchanger:loadSkin', skin) - TriggerEvent('esx:restoreLoadout') + TriggerEvent("skinchanger:loadDefaultModel", isMale, function() + ESX.TriggerServerCallback("esx_skin:getPlayerSkin", function(skin) + TriggerEvent("skinchanger:loadSkin", skin) + TriggerEvent("esx:restoreLoadout") end) end) - end) else - ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin) - TriggerEvent('skinchanger:loadSkin', skin) + ESX.TriggerServerCallback("esx_skin:getPlayerSkin", function(skin) + TriggerEvent("skinchanger:loadSkin", skin) end) end if Config.EnableESXService then - ESX.TriggerServerCallback('esx_service:isInService', function(isInService) + ESX.TriggerServerCallback("esx_service:isInService", function(isInService) if isInService then playerInService = false local notification = { - title = TranslateCap('service_anonunce'), - subject = '', - msg = TranslateCap('service_out_announce', GetPlayerName(PlayerId())), - iconType = 1 + title = TranslateCap("service_anonunce"), + subject = "", + msg = TranslateCap("service_out_announce", GetPlayerName(PlayerId())), + iconType = 1, } - TriggerServerEvent('esx_service:notifyAllInService', notification, 'police') + TriggerServerEvent("esx_service:notifyAllInService", notification, "police") - TriggerServerEvent('esx_service:disableService', 'police') - TriggerEvent('esx_policejob:updateBlip') - ESX.ShowNotification(TranslateCap('service_out')) + TriggerServerEvent("esx_service:disableService", "police") + TriggerEvent("esx_policejob:updateBlip") + ESX.ShowNotification(TranslateCap("service_out")) end - end, 'police') + end, "police") end end - if Config.EnableESXService and data.current.value ~= 'citizen_wear' then + if Config.EnableESXService and data.current.value ~= "citizen_wear" then local awaitService - ESX.TriggerServerCallback('esx_service:isInService', function(isInService) + ESX.TriggerServerCallback("esx_service:isInService", function(isInService) if not isInService then - if Config.MaxInService ~= -1 then - ESX.TriggerServerCallback('esx_service:enableService', function(canTakeService, maxInService, inServiceCount) - if not canTakeService then - ESX.ShowNotification(TranslateCap('service_max', inServiceCount, maxInService)) - else - awaitService = true - playerInService = true - - local notification = { - title = TranslateCap('service_anonunce'), - subject = '', - msg = TranslateCap('service_in_announce', GetPlayerName(PlayerId())), - iconType = 1 - } - - TriggerServerEvent('esx_service:notifyAllInService', notification, 'police') - TriggerEvent('esx_policejob:updateBlip') - ESX.ShowNotification(TranslateCap('service_in')) - end - end, 'police') + ESX.TriggerServerCallback( + "esx_service:enableService", + function(canTakeService, maxInService, inServiceCount) + if not canTakeService then + ESX.ShowNotification(TranslateCap("service_max", inServiceCount, maxInService)) + else + awaitService = true + playerInService = true + + local notification = { + title = TranslateCap("service_anonunce"), + subject = "", + msg = TranslateCap("service_in_announce", GetPlayerName(PlayerId())), + iconType = 1, + } + + TriggerServerEvent("esx_service:notifyAllInService", notification, "police") + TriggerEvent("esx_policejob:updateBlip") + ESX.ShowNotification(TranslateCap("service_in")) + end + end, + "police" + ) else awaitService = true playerInService = true local notification = { - title = TranslateCap('service_anonunce'), - subject = '', - msg = TranslateCap('service_in_announce', GetPlayerName(PlayerId())), - iconType = 1 + title = TranslateCap("service_anonunce"), + subject = "", + msg = TranslateCap("service_in_announce", GetPlayerName(PlayerId())), + iconType = 1, } - TriggerServerEvent('esx_service:notifyAllInService', notification, 'police') - TriggerEvent('esx_policejob:updateBlip') - ESX.ShowNotification(TranslateCap('service_in')) + TriggerServerEvent("esx_service:notifyAllInService", notification, "police") + TriggerEvent("esx_policejob:updateBlip") + ESX.ShowNotification(TranslateCap("service_in")) end - else awaitService = true end - end, 'police') + end, "police") while awaitService == nil do Wait(0) @@ -169,10 +171,10 @@ function OpenCloakroomMenu() if data.current.uniform then setUniform(data.current.uniform, playerPed) - elseif data.current.value == 'freemode_ped' then + elseif data.current.value == "freemode_ped" then local modelHash - ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) + ESX.TriggerServerCallback("esx_skin:getPlayerSkin", function(skin, jobSkin) if skin.sex == 0 then modelHash = joaat(data.current.maleModel) else @@ -184,13 +186,13 @@ function OpenCloakroomMenu() SetModelAsNoLongerNeeded(modelHash) SetPedDefaultComponentVariation(PlayerPedId()) - TriggerEvent('esx:restoreLoadout') + TriggerEvent("esx:restoreLoadout") end) end) end end, function(menu) - CurrentAction = 'menu_cloakroom' - CurrentActionMsg = TranslateCap('open_cloackroom') + CurrentAction = "menu_cloakroom" + CurrentActionMsg = TranslateCap("open_cloackroom") CurrentActionData = {} end) end @@ -198,154 +200,155 @@ end function OpenArmoryMenu(station) local elements if Config.OxInventory then - exports.ox_inventory:openInventory('stash', {id = 'society_police', owner = station}) + exports.ox_inventory:openInventory("stash", { id = "society_police", owner = station }) return ESX.CloseContext() else elements = { - {unselectable = true, icon = "fas fa-gun", title = TranslateCap('armory')}, - {icon = "fas fa-gun", title = TranslateCap('buy_weapons'), value = 'buy_weapons'} - + { unselectable = true, icon = "fas fa-gun", title = TranslateCap("armory") }, + { icon = "fas fa-gun", title = TranslateCap("buy_weapons"), value = "buy_weapons" }, } if Config.EnableArmoryManagement then - table.insert(elements, {icon = "fas fa-gun", title = TranslateCap('get_weapon'), value = 'get_weapon'}) - table.insert(elements, {icon = "fas fa-gun", title = TranslateCap('put_weapon'), value = 'put_weapon'}) - table.insert(elements, {icon = "fas fa-box", title = TranslateCap('remove_object'), value = 'get_stock'}) - table.insert(elements, {icon = "fas fa-box", title = TranslateCap('deposit_object'), value = 'put_stock'}) + table.insert(elements, { icon = "fas fa-gun", title = TranslateCap("get_weapon"), value = "get_weapon" }) + table.insert(elements, { icon = "fas fa-gun", title = TranslateCap("put_weapon"), value = "put_weapon" }) + table.insert(elements, { icon = "fas fa-box", title = TranslateCap("remove_object"), value = "get_stock" }) + table.insert(elements, { icon = "fas fa-box", title = TranslateCap("deposit_object"), value = "put_stock" }) end end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} - if data.current.value == 'get_weapon' then + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } + if data.current.value == "get_weapon" then OpenGetWeaponMenu() - elseif data.current.value == 'put_weapon' then + elseif data.current.value == "put_weapon" then OpenPutWeaponMenu() - elseif data.current.value == 'buy_weapons' then + elseif data.current.value == "buy_weapons" then OpenBuyWeaponsMenu() - elseif data.current.value == 'put_stock' then + elseif data.current.value == "put_stock" then OpenPutStocksMenu() - elseif data.current.value == 'get_stock' then + elseif data.current.value == "get_stock" then OpenGetStocksMenu() end end, function(menu) - CurrentAction = 'menu_armory' - CurrentActionMsg = TranslateCap('open_armory') - CurrentActionData = {station = station} + CurrentAction = "menu_armory" + CurrentActionMsg = TranslateCap("open_armory") + CurrentActionData = { station = station } end) end function OpenPoliceActionsMenu() local elements = { - {unselectable = true, icon = "fas fa-police", title = TranslateCap('menu_title')}, - {icon = "fas fa-user", title = TranslateCap('citizen_interaction'), value = 'citizen_interaction'}, - {icon = "fas fa-car", title = TranslateCap('vehicle_interaction'), value = 'vehicle_interaction'}, - {icon = "fas fa-object", title = TranslateCap('object_spawner'), value = 'object_spawner'} + { unselectable = true, icon = "fas fa-police", title = TranslateCap("menu_title") }, + { icon = "fas fa-user", title = TranslateCap("citizen_interaction"), value = "citizen_interaction" }, + { icon = "fas fa-car", title = TranslateCap("vehicle_interaction"), value = "vehicle_interaction" }, + { icon = "fas fa-object", title = TranslateCap("object_spawner"), value = "object_spawner" }, } - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } - if data.current.value == 'citizen_interaction' then + if data.current.value == "citizen_interaction" then local elements2 = { - {unselectable = true, icon = "fas fa-user", title = element.title}, - {icon = "fas fa-idkyet", title = TranslateCap('id_card'), value = 'identity_card'}, - {icon = "fas fa-idkyet", title = TranslateCap('search'), value = 'search'}, - {icon = "fas fa-idkyet", title = TranslateCap('handcuff'), value = 'handcuff'}, - {icon = "fas fa-idkyet", title = TranslateCap('drag'), value = 'drag'}, - {icon = "fas fa-idkyet", title = TranslateCap('put_in_vehicle'), value = 'put_in_vehicle'}, - {icon = "fas fa-idkyet", title = TranslateCap('out_the_vehicle'), value = 'out_the_vehicle'}, - {icon = "fas fa-idkyet", title = TranslateCap('fine'), value = 'fine'}, - {icon = "fas fa-idkyet", title = TranslateCap('unpaid_bills'), value = 'unpaid_bills'} + { unselectable = true, icon = "fas fa-user", title = element.title }, + { icon = "fas fa-idkyet", title = TranslateCap("id_card"), value = "identity_card" }, + { icon = "fas fa-idkyet", title = TranslateCap("search"), value = "search" }, + { icon = "fas fa-idkyet", title = TranslateCap("handcuff"), value = "handcuff" }, + { icon = "fas fa-idkyet", title = TranslateCap("drag"), value = "drag" }, + { icon = "fas fa-idkyet", title = TranslateCap("put_in_vehicle"), value = "put_in_vehicle" }, + { icon = "fas fa-idkyet", title = TranslateCap("out_the_vehicle"), value = "out_the_vehicle" }, + { icon = "fas fa-idkyet", title = TranslateCap("fine"), value = "fine" }, + { icon = "fas fa-idkyet", title = TranslateCap("unpaid_bills"), value = "unpaid_bills" }, } if Config.EnableLicenses then - elements2[#elements2+1] = { + elements2[#elements2 + 1] = { icon = "fas fa-scroll", - title = TranslateCap('license_check'), - value = 'license' + title = TranslateCap("license_check"), + value = "license", } end - ESX.OpenContext("right", elements2, function(menu2,element2) + ESX.OpenContext("right", elements2, function(menu2, element2) local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer ~= -1 and closestDistance <= 3.0 then - local data2 = {current = element2} + local data2 = { current = element2 } local action = data2.current.value - if action == 'identity_card' then + if action == "identity_card" then OpenIdentityCardMenu(closestPlayer) - elseif action == 'search' then + elseif action == "search" then OpenBodySearchMenu(closestPlayer) - elseif action == 'handcuff' then - TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer)) - elseif action == 'drag' then - TriggerServerEvent('esx_policejob:drag', GetPlayerServerId(closestPlayer)) - elseif action == 'put_in_vehicle' then - TriggerServerEvent('esx_policejob:putInVehicle', GetPlayerServerId(closestPlayer)) - elseif action == 'out_the_vehicle' then - TriggerServerEvent('esx_policejob:OutVehicle', GetPlayerServerId(closestPlayer)) - elseif action == 'fine' then + elseif action == "handcuff" then + TriggerServerEvent("esx_policejob:handcuff", GetPlayerServerId(closestPlayer)) + elseif action == "drag" then + TriggerServerEvent("esx_policejob:drag", GetPlayerServerId(closestPlayer)) + elseif action == "put_in_vehicle" then + TriggerServerEvent("esx_policejob:putInVehicle", GetPlayerServerId(closestPlayer)) + elseif action == "out_the_vehicle" then + TriggerServerEvent("esx_policejob:OutVehicle", GetPlayerServerId(closestPlayer)) + elseif action == "fine" then OpenFineMenu(closestPlayer) - elseif action == 'license' then + elseif action == "license" then ShowPlayerLicense(closestPlayer) - elseif action == 'unpaid_bills' then + elseif action == "unpaid_bills" then OpenUnpaidBillsMenu(closestPlayer) end else - ESX.ShowNotification(TranslateCap('no_players_nearby')) + ESX.ShowNotification(TranslateCap("no_players_nearby")) end end, function(menu) OpenPoliceActionsMenu() end) - elseif data.current.value == 'vehicle_interaction' then - local elements3 = { - {unselectable = true, icon = "fas fa-car", title = element.title} + elseif data.current.value == "vehicle_interaction" then + local elements3 = { + { unselectable = true, icon = "fas fa-car", title = element.title }, } local playerPed = PlayerPedId() local vehicle = ESX.Game.GetVehicleInDirection() if DoesEntityExist(vehicle) then - elements3[#elements3+1] = {icon = "fas fa-car", title = TranslateCap('vehicle_info'), value = 'vehicle_infos'} - elements3[#elements3+1] = {icon = "fas fa-car", title = TranslateCap('pick_lock'), value = 'hijack_vehicle'} - elements3[#elements3+1] = {icon = "fas fa-car", title = TranslateCap('impound'), value = 'impound'} + elements3[#elements3 + 1] = + { icon = "fas fa-car", title = TranslateCap("vehicle_info"), value = "vehicle_infos" } + elements3[#elements3 + 1] = + { icon = "fas fa-car", title = TranslateCap("pick_lock"), value = "hijack_vehicle" } + elements3[#elements3 + 1] = { icon = "fas fa-car", title = TranslateCap("impound"), value = "impound" } end - elements3[#elements3+1] = { + elements3[#elements3 + 1] = { icon = "fas fa-scroll", - title = TranslateCap('search_database'), - value = 'search_database' + title = TranslateCap("search_database"), + value = "search_database", } - - ESX.OpenContext("right", elements3, function(menu3,element3) - local data2 = {current = element3} - local coords = GetEntityCoords(playerPed) + + ESX.OpenContext("right", elements3, function(menu3, element3) + local data2 = { current = element3 } + local coords = GetEntityCoords(playerPed) vehicle = ESX.Game.GetVehicleInDirection() - action = data2.current.value + action = data2.current.value - if action == 'search_database' then + if action == "search_database" then LookupVehicle(element3) elseif DoesEntityExist(vehicle) then - if action == 'vehicle_infos' then + if action == "vehicle_infos" then local vehicleData = ESX.Game.GetVehicleProperties(vehicle) OpenVehicleInfosMenu(vehicleData) - elseif action == 'hijack_vehicle' then + elseif action == "hijack_vehicle" then if IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 3.0) then - TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_WELDING', 0, true) + TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_WELDING", 0, true) Wait(20000) ClearPedTasksImmediately(playerPed) SetVehicleDoorsLocked(vehicle, 1) SetVehicleDoorsLockedForAllPlayers(vehicle, false) - ESX.ShowNotification(TranslateCap('vehicle_unlocked')) + ESX.ShowNotification(TranslateCap("vehicle_unlocked")) end - elseif action == 'impound' then + elseif action == "impound" then if currentTask.busy then return end - ESX.ShowHelpNotification(TranslateCap('impound_prompt')) - TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true) + ESX.ShowHelpNotification(TranslateCap("impound_prompt")) + TaskStartScenarioInPlace(playerPed, "CODE_HUMAN_MEDIC_TEND_TO_DEAD", 0, true) currentTask.busy = true currentTask.task = ESX.SetTimeout(10000, function() @@ -360,7 +363,7 @@ function OpenPoliceActionsMenu() vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 3.0, 0, 71) if not DoesEntityExist(vehicle) and currentTask.busy then - ESX.ShowNotification(TranslateCap('impound_canceled_moved')) + ESX.ShowNotification(TranslateCap("impound_canceled_moved")) ESX.ClearTimeout(currentTask.task) ClearPedTasks(playerPed) currentTask.busy = false @@ -370,23 +373,23 @@ function OpenPoliceActionsMenu() end) end else - ESX.ShowNotification(TranslateCap('no_vehicles_nearby')) + ESX.ShowNotification(TranslateCap("no_vehicles_nearby")) end end, function(menu) OpenPoliceActionsMenu() end) elseif data.current.value == "object_spawner" then local elements4 = { - {unselectable = true, icon = "fas fa-object", title = element.title}, - {icon = "fas fa-cone", title = TranslateCap('cone'), model = 'prop_roadcone02a'}, - {icon = "fas fa-cone", title = TranslateCap('barrier'), model = 'prop_barrier_work05'}, - {icon = "fas fa-cone", title = TranslateCap('spikestrips'), model = 'p_ld_stinger_s'}, - {icon = "fas fa-cone", title = TranslateCap('box'), model = 'prop_boxpile_07d'}, - {icon = "fas fa-cone", title = TranslateCap('cash'), model = 'hei_prop_cash_crate_half_full'} + { unselectable = true, icon = "fas fa-object", title = element.title }, + { icon = "fas fa-cone", title = TranslateCap("cone"), model = "prop_roadcone02a" }, + { icon = "fas fa-cone", title = TranslateCap("barrier"), model = "prop_barrier_work05" }, + { icon = "fas fa-cone", title = TranslateCap("spikestrips"), model = "p_ld_stinger_s" }, + { icon = "fas fa-cone", title = TranslateCap("box"), model = "prop_boxpile_07d" }, + { icon = "fas fa-cone", title = TranslateCap("cash"), model = "hei_prop_cash_crate_half_full" }, } - ESX.OpenContext("right", elements4, function(menu4,element4) - local data2 = {current = element4} + ESX.OpenContext("right", elements4, function(menu4, element4) + local data2 = { current = element4 } local playerPed = PlayerPedId() local coords, forward = GetEntityCoords(playerPed), GetEntityForwardVector(playerPed) local objectCoords = (coords + forward * 1.0) @@ -404,32 +407,32 @@ function OpenPoliceActionsMenu() end function OpenIdentityCardMenu(player) - ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data) + ESX.TriggerServerCallback("esx_policejob:getOtherPlayerData", function(data) local elements = { - {icon = "fas fa-user", title = TranslateCap('name', data.name)}, - {icon = "fas fa-user", title = TranslateCap('job', ('%s - %s'):format(data.job, data.grade))} + { icon = "fas fa-user", title = TranslateCap("name", data.name) }, + { icon = "fas fa-user", title = TranslateCap("job", ("%s - %s"):format(data.job, data.grade)) }, } if Config.EnableESXIdentity then - elements[#elements+1] = {icon = "fas fa-user", title = TranslateCap('sex', TranslateCap(data.sex))} - elements[#elements+1] = {icon = "fas fa-user", title = TranslateCap('sex', TranslateCap(data.sex))} - elements[#elements+1] = {icon = "fas fa-user", title = TranslateCap('height', data.height)} + elements[#elements + 1] = { icon = "fas fa-user", title = TranslateCap("sex", TranslateCap(data.sex)) } + elements[#elements + 1] = { icon = "fas fa-user", title = TranslateCap("sex", TranslateCap(data.sex)) } + elements[#elements + 1] = { icon = "fas fa-user", title = TranslateCap("height", data.height) } end if Config.EnableESXOptionalneeds and data.drunk then - elements[#elements+1] = {title = TranslateCap('bac', data.drunk)} + elements[#elements + 1] = { title = TranslateCap("bac", data.drunk) } end if data.licenses then - elements[#elements+1] = {title = TranslateCap('license_label')} + elements[#elements + 1] = { title = TranslateCap("license_label") } - for i=1, #data.licenses, 1 do - elements[#elements+1] = {title = data.licenses[i].label} + for i = 1, #data.licenses, 1 do + elements[#elements + 1] = { title = data.licenses[i].label } end end ESX.OpenContext("right", elements, nil, function(menu) - OpenPoliceActionsMenu() + OpenPoliceActionsMenu() end) end, GetPlayerServerId(player)) end @@ -437,58 +440,68 @@ end function OpenBodySearchMenu(player) if Config.OxInventory then ESX.CloseContext() - exports.ox_inventory:openInventory('player', GetPlayerServerId(player)) + exports.ox_inventory:openInventory("player", GetPlayerServerId(player)) return end - ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(data) + ESX.TriggerServerCallback("esx_policejob:getOtherPlayerData", function(data) local elements = { - {unselectable = true, icon = "fas fa-user", title = TranslateCap('search')} + { unselectable = true, icon = "fas fa-user", title = TranslateCap("search") }, } - for i=1, #data.accounts, 1 do - if data.accounts[i].name == 'black_money' and data.accounts[i].money > 0 then - elements[#elements+1] = { + for i = 1, #data.accounts, 1 do + if data.accounts[i].name == "black_money" and data.accounts[i].money > 0 then + elements[#elements + 1] = { icon = "fas fa-money", - title = TranslateCap('confiscate_dirty', ESX.Math.Round(data.accounts[i].money)), - value = 'black_money', - itemType = 'item_account', - amount = data.accounts[i].money + title = TranslateCap("confiscate_dirty", ESX.Math.Round(data.accounts[i].money)), + value = "black_money", + itemType = "item_account", + amount = data.accounts[i].money, } break end end - table.insert(elements, {label = TranslateCap('guns_label')}) + table.insert(elements, { label = TranslateCap("guns_label") }) - for i=1, #data.weapons, 1 do - elements[#elements+1] = { + for i = 1, #data.weapons, 1 do + elements[#elements + 1] = { icon = "fas fa-gun", - title = TranslateCap('confiscate_weapon', ESX.GetWeaponLabel(data.weapons[i].name), data.weapons[i].ammo), - value = data.weapons[i].name, - itemType = 'item_weapon', - amount = data.weapons[i].ammo + title = TranslateCap( + "confiscate_weapon", + ESX.GetWeaponLabel(data.weapons[i].name), + data.weapons[i].ammo + ), + value = data.weapons[i].name, + itemType = "item_weapon", + amount = data.weapons[i].ammo, } end - elements[#elements+1] = {title = TranslateCap('inventory_label')} + elements[#elements + 1] = { title = TranslateCap("inventory_label") } - for i=1, #data.inventory, 1 do + for i = 1, #data.inventory, 1 do if data.inventory[i].count > 0 then - elements[#elements+1] = { + elements[#elements + 1] = { icon = "fas fa-box", - title = TranslateCap('confiscate_inv', data.inventory[i].count, data.inventory[i].label), - value = data.inventory[i].name, - itemType = 'item_standard', - amount = data.inventory[i].count + title = TranslateCap("confiscate_inv", data.inventory[i].count, data.inventory[i].label), + value = data.inventory[i].name, + itemType = "item_standard", + amount = data.inventory[i].count, } end end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } if data.current.value then - TriggerServerEvent('esx_policejob:confiscatePlayerItem', GetPlayerServerId(player), data.current.itemType, data.current.value, data.current.amount) + TriggerServerEvent( + "esx_policejob:confiscatePlayerItem", + GetPlayerServerId(player), + data.current.itemType, + data.current.value, + data.current.amount + ) OpenBodySearchMenu(player) end end) @@ -496,58 +509,73 @@ function OpenBodySearchMenu(player) end function OpenFineMenu(player) - if Config.EnableFinePresets then - local elements = { - {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')}, - {icon = "fas fa-scroll", title = TranslateCap('traffic_offense'), value = 0}, - {icon = "fas fa-scroll", title = TranslateCap('minor_offense'), value = 1}, - {icon = "fas fa-scroll", title = TranslateCap('average_offense'), value = 2}, - {icon = "fas fa-scroll", title = TranslateCap('major_offense'), value = 3} - } - - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} - OpenFineCategoryMenu(player, data.current.value) - end) - else - ESX.CloseContext() - ESX.CloseContext() - OpenFineTextInput(player) - end + if Config.EnableFinePresets then + local elements = { + { unselectable = true, icon = "fas fa-scroll", title = TranslateCap("fine") }, + { icon = "fas fa-scroll", title = TranslateCap("traffic_offense"), value = 0 }, + { icon = "fas fa-scroll", title = TranslateCap("minor_offense"), value = 1 }, + { icon = "fas fa-scroll", title = TranslateCap("average_offense"), value = 2 }, + { icon = "fas fa-scroll", title = TranslateCap("major_offense"), value = 3 }, + } + + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } + OpenFineCategoryMenu(player, data.current.value) + end) + else + ESX.CloseContext() + ESX.CloseContext() + OpenFineTextInput(player) + end end local fineList = {} function OpenFineCategoryMenu(player, category) - if not fineList[category] then + if not fineList[category] then local p = promise.new() - ESX.TriggerServerCallback('esx_policejob:getFineList', function(fines) + ESX.TriggerServerCallback("esx_policejob:getFineList", function(fines) p:resolve(fines) end, category) fineList[category] = Citizen.Await(p) - end + end local elements = { - {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('fine')} + { unselectable = true, icon = "fas fa-scroll", title = TranslateCap("fine") }, } - for k,fine in ipairs(fineList[category]) do - elements[#elements+1] = { + for k, fine in ipairs(fineList[category]) do + elements[#elements + 1] = { icon = "fas fa-scroll", - title = ('%s %s'):format(fine.label, TranslateCap('armory_item', ESX.Math.GroupDigits(fine.amount))), - value = fine.id, - amount = fine.amount, - fineLabel = fine.label + title = ('%s %s'):format( + fine.label, + TranslateCap("armory_item", ESX.Math.GroupDigits(fine.amount)) + ), + value = fine.id, + amount = fine.amount, + fineLabel = fine.label, } end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } if Config.EnablePlayerManagement then - TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), 'society_police', TranslateCap('fine_total', data.current.fineLabel), data.current.amount) + TriggerServerEvent( + "esx_billing:sendBill", + GetPlayerServerId(player), + "society_police", + TranslateCap("fine_total", data.current.fineLabel), + data.current.amount + ) else - TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), '', TranslateCap('fine_total', data.current.fineLabel), data.current.amount) + TriggerServerEvent( + "esx_billing:sendBill", + GetPlayerServerId(player), + "", + TranslateCap("fine_total", data.current.fineLabel), + data.current.amount + ) end ESX.SetTimeout(300, function() @@ -557,61 +585,62 @@ function OpenFineCategoryMenu(player, category) end function OpenFineTextInput(player) - Citizen.CreateThread(function() - local amount = 0 - local reason = '' - AddTextEntry('FMMC_KEY_TIP1', TranslateCap('fine_enter_amount')) - Citizen.Wait(0) - DisplayOnscreenKeyboard(1, 'FMMC_KEY_TIP1', '', '', '', '', '', 30) - while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do - Citizen.Wait(0) - end - if UpdateOnscreenKeyboard() ~= 2 then - amount = tonumber(GetOnscreenKeyboardResult()) - if amount == nil or amount <= 0 then - ESX.ShowNotification(TranslateCap('invalid_amount')) - return - end - end - AddTextEntry('FMMC_KEY_TIP1', TranslateCap('fine_enter_text')) - Citizen.Wait(0) - DisplayOnscreenKeyboard(1, 'FMMC_KEY_TIP1', '', '', '', '', '', 120) - while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do - Citizen.Wait(0) - end - if UpdateOnscreenKeyboard() ~= 2 then - reason = GetOnscreenKeyboardResult() - end - Citizen.Wait(500) - TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(player), 'society_police', reason, amount) - OpenPoliceActionsMenu() - end) + Citizen.CreateThread(function() + local amount = 0 + local reason = "" + AddTextEntry("FMMC_KEY_TIP1", TranslateCap("fine_enter_amount")) + Citizen.Wait(0) + DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP1", "", "", "", "", "", 30) + while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do + Citizen.Wait(0) + end + if UpdateOnscreenKeyboard() ~= 2 then + amount = tonumber(GetOnscreenKeyboardResult()) + if amount == nil or amount <= 0 then + ESX.ShowNotification(TranslateCap("invalid_amount")) + return + end + end + AddTextEntry("FMMC_KEY_TIP1", TranslateCap("fine_enter_text")) + Citizen.Wait(0) + DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP1", "", "", "", "", "", 120) + while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do + Citizen.Wait(0) + end + if UpdateOnscreenKeyboard() ~= 2 then + reason = GetOnscreenKeyboardResult() + end + Citizen.Wait(500) + TriggerServerEvent("esx_billing:sendBill", GetPlayerServerId(player), "society_police", reason, amount) + OpenPoliceActionsMenu() + end) end - function LookupVehicle(elementF) local elements = { - {unselectable = true, icon = "fas fa-car", title = elementF.title}, - {title = TranslateCap('search_plate'), input = true, inputType = "text", inputPlaceholder = "ABC 123"}, - {icon = "fas fa-check-double", title = TranslateCap('lookup_plate'), value = "lookup"} + { unselectable = true, icon = "fas fa-car", title = elementF.title }, + { title = TranslateCap("search_plate"), input = true, inputType = "text", inputPlaceholder = "ABC 123" }, + { icon = "fas fa-check-double", title = TranslateCap("lookup_plate"), value = "lookup" }, } - ESX.OpenContext("right", elements, function(menu,element) - local data = {value = menu.eles[2].inputValue} + ESX.OpenContext("right", elements, function(menu, element) + local data = { value = menu.eles[2].inputValue } local length = string.len(data.value) if not data.value or length < 2 or length > 8 then - ESX.ShowNotification(TranslateCap('search_database_error_invalid')) + ESX.ShowNotification(TranslateCap("search_database_error_invalid")) else - ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo) + ESX.TriggerServerCallback("esx_policejob:getVehicleInfos", function(retrivedInfo) local elements = { - {unselectable = true, icon = "fas fa-car", title = element.title}, - {unselectable = true, icon = "fas fa-car", title = TranslateCap('plate', retrivedInfo.plate)} + { unselectable = true, icon = "fas fa-car", title = element.title }, + { unselectable = true, icon = "fas fa-car", title = TranslateCap("plate", retrivedInfo.plate) }, } if not retrivedInfo.owner then - elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner_unknown')} + elements[#elements + 1] = + { unselectable = true, icon = "fas fa-user", title = TranslateCap("owner_unknown") } else - elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner', retrivedInfo.owner)} + elements[#elements + 1] = + { unselectable = true, icon = "fas fa-user", title = TranslateCap("owner", retrivedInfo.owner) } end ESX.OpenContext("right", elements, nil, function(menu) @@ -624,28 +653,32 @@ end function ShowPlayerLicense(player) local elements = { - {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('license_revoke')} + { unselectable = true, icon = "fas fa-scroll", title = TranslateCap("license_revoke") }, } - ESX.TriggerServerCallback('esx_policejob:getOtherPlayerData', function(playerData) + ESX.TriggerServerCallback("esx_policejob:getOtherPlayerData", function(playerData) if playerData.licenses then - for i=1, #playerData.licenses, 1 do + for i = 1, #playerData.licenses, 1 do if playerData.licenses[i].label and playerData.licenses[i].type then - elements[#elements+1] = { + elements[#elements + 1] = { icon = "fas fa-scroll", title = playerData.licenses[i].label, - type = playerData.licenses[i].type + type = playerData.licenses[i].type, } end end end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} - ESX.ShowNotification(TranslateCap('licence_you_revoked', data.current.label, playerData.name)) - TriggerServerEvent('esx_policejob:message', GetPlayerServerId(player), TranslateCap('license_revoked', data.current.label)) + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } + ESX.ShowNotification(TranslateCap("licence_you_revoked", data.current.label, playerData.name)) + TriggerServerEvent( + "esx_policejob:message", + GetPlayerServerId(player), + TranslateCap("license_revoked", data.current.label) + ) - TriggerServerEvent('esx_license:removeLicense', GetPlayerServerId(player), data.current.type) + TriggerServerEvent("esx_license:removeLicense", GetPlayerServerId(player), data.current.type) ESX.SetTimeout(300, function() ShowPlayerLicense(player) @@ -656,36 +689,39 @@ end function OpenUnpaidBillsMenu(player) local elements = { - {unselectable = true, icon = "fas fa-scroll", title = TranslateCap('unpaid_bills')} + { unselectable = true, icon = "fas fa-scroll", title = TranslateCap("unpaid_bills") }, } - ESX.TriggerServerCallback('esx_billing:getTargetBills', function(bills) - for k,bill in ipairs(bills) do - elements[#elements+1] = { + ESX.TriggerServerCallback("esx_billing:getTargetBills", function(bills) + for _, bill in ipairs(bills) do + elements[#elements + 1] = { unselectable = true, icon = "fas fa-scroll", - title = ('%s - %s'):format(bill.label, TranslateCap('armory_item', ESX.Math.GroupDigits(bill.amount))), - billId = bill.id + title = ('%s - %s'):format( + bill.label, + TranslateCap("armory_item", ESX.Math.GroupDigits(bill.amount)) + ), + billId = bill.id, } end ESX.OpenContext("right", elements, nil, nil) - end, GetPlayerServerId(player)) end function OpenVehicleInfosMenu(vehicleData) - ESX.TriggerServerCallback('esx_policejob:getVehicleInfos', function(retrivedInfo) + ESX.TriggerServerCallback("esx_policejob:getVehicleInfos", function(retrivedInfo) local elements = { - {unselectable = true, icon = "fas fa-car", title = TranslateCap('vehicle_info')}, - {icon = "fas fa-car", title = TranslateCap('plate', retrivedInfo.plate)} - + { unselectable = true, icon = "fas fa-car", title = TranslateCap("vehicle_info") }, + { icon = "fas fa-car", title = TranslateCap("plate", retrivedInfo.plate) }, } if not retrivedInfo.owner then - elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner_unknown')} + elements[#elements + 1] = + { unselectable = true, icon = "fas fa-user", title = TranslateCap("owner_unknown") } else - elements[#elements+1] = {unselectable = true, icon = "fas fa-user", title = TranslateCap('owner', retrivedInfo.owner)} + elements[#elements + 1] = + { unselectable = true, icon = "fas fa-user", title = TranslateCap("owner", retrivedInfo.owner) } end ESX.OpenContext("right", elements, nil, nil) @@ -693,24 +729,24 @@ function OpenVehicleInfosMenu(vehicleData) end function OpenGetWeaponMenu() - ESX.TriggerServerCallback('esx_policejob:getArmoryWeapons', function(weapons) + ESX.TriggerServerCallback("esx_policejob:getArmoryWeapons", function(weapons) local elements = { - {unselectable = true, icon = "fas fa-gun", title = TranslateCap('get_weapon_menu')} + { unselectable = true, icon = "fas fa-gun", title = TranslateCap("get_weapon_menu") }, } - for i=1, #weapons, 1 do + for i = 1, #weapons, 1 do if weapons[i].count > 0 then - elements[#elements+1] = { + elements[#elements + 1] = { icon = "fas fa-gun", - title = 'x' .. weapons[i].count .. ' ' .. ESX.GetWeaponLabel(weapons[i].name), - value = weapons[i].name + title = "x" .. weapons[i].count .. " " .. ESX.GetWeaponLabel(weapons[i].name), + value = weapons[i].name, } end end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} - ESX.TriggerServerCallback('esx_policejob:removeArmoryWeapon', function() + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } + ESX.TriggerServerCallback("esx_policejob:removeArmoryWeapon", function() ESX.CloseContext() OpenGetWeaponMenu() end, data.current.value) @@ -719,27 +755,27 @@ function OpenGetWeaponMenu() end function OpenPutWeaponMenu() - local elements = { - {unselectable = true, icon = "fas fa-gun", title = TranslateCap('put_weapon_menu')} + local elements = { + { unselectable = true, icon = "fas fa-gun", title = TranslateCap("put_weapon_menu") }, } - local playerPed = PlayerPedId() + local playerPed = PlayerPedId() local weaponList = ESX.GetWeaponList() - for i=1, #weaponList, 1 do + for i = 1, #weaponList, 1 do local weaponHash = joaat(weaponList[i].name) - if HasPedGotWeapon(playerPed, weaponHash, false) and weaponList[i].name ~= 'WEAPON_UNARMED' then - elements[#elements+1] = { + if HasPedGotWeapon(playerPed, weaponHash, false) and weaponList[i].name ~= "WEAPON_UNARMED" then + elements[#elements + 1] = { icon = "fas fa-gun", title = weaponList[i].label, - value = weaponList[i].name + value = weaponList[i].name, } end end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} - ESX.TriggerServerCallback('esx_policejob:addArmoryWeapon', function() + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } + ESX.TriggerServerCallback("esx_policejob:addArmoryWeapon", function() ESX.CloseContext() OpenPutWeaponMenu() end, data.current.value, true) @@ -748,32 +784,41 @@ end function OpenBuyWeaponsMenu() local elements = { - {unselectable = true, icon = "fas fa-gun", title = TranslateCap('armory_weapontitle')} + { unselectable = true, icon = "fas fa-gun", title = TranslateCap("armory_weapontitle") }, } local playerPed = PlayerPedId() - for k,v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job.grade_name]) do - local weaponNum, weapon = ESX.GetWeapon(v.weapon) + for _, v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job.grade_name]) do + local _, weapon = ESX.GetWeapon(v.weapon) local components, label = {} local hasWeapon = HasPedGotWeapon(playerPed, joaat(v.weapon), false) if v.components then - for i=1, #v.components do + for i = 1, #v.components do if v.components[i] then local component = weapon.components[i] local hasComponent = HasPedGotWeaponComponent(playerPed, joaat(v.weapon), component.hash) if hasComponent then - label = ('%s: %s'):format(component.label, TranslateCap('armory_owned')) + label = ('%s: %s'):format( + component.label, + TranslateCap("armory_owned") + ) else if v.components[i] > 0 then - label = ('%s: %s'):format(component.label, TranslateCap('armory_item', ESX.Math.GroupDigits(v.components[i]))) + label = ('%s: %s'):format( + component.label, + TranslateCap("armory_item", ESX.Math.GroupDigits(v.components[i])) + ) else - label = ('%s: %s'):format(component.label, TranslateCap('armory_free')) + label = ('%s: %s'):format( + component.label, + TranslateCap("armory_free") + ) end end - components[#components+1] = { + components[#components + 1] = { icon = "fas fa-gun", title = label, componentLabel = component.label, @@ -781,7 +826,7 @@ function OpenBuyWeaponsMenu() name = component.name, price = v.components[i], hasComponent = hasComponent, - componentNum = i + componentNum = i, } end end @@ -790,43 +835,52 @@ function OpenBuyWeaponsMenu() if hasWeapon and v.components then label = ('%s: >'):format(weapon.label) elseif hasWeapon and not v.components then - label = ('%s: %s'):format(weapon.label, TranslateCap('armory_owned')) + label = ('%s: %s'):format(weapon.label, TranslateCap("armory_owned")) else if v.price > 0 then - label = ('%s: %s'):format(weapon.label, TranslateCap('armory_item', ESX.Math.GroupDigits(v.price))) + label = ('%s: %s'):format( + weapon.label, + TranslateCap("armory_item", ESX.Math.GroupDigits(v.price)) + ) else - label = ('%s: %s'):format(weapon.label, TranslateCap('armory_free')) + label = ('%s: %s'):format(weapon.label, TranslateCap("armory_free")) end end - elements[#elements+1] = { + elements[#elements + 1] = { icon = "fas fa-gun", title = label, weaponLabel = weapon.label, name = weapon.name, components = components, price = v.price, - hasWeapon = hasWeapon + hasWeapon = hasWeapon, } end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } if data.current.hasWeapon then if #data.current.components > 0 then OpenWeaponComponentShop(data.current.components, data.current.name, menu) end else - ESX.TriggerServerCallback('esx_policejob:buyWeapon', function(bought) + ESX.TriggerServerCallback("esx_policejob:buyWeapon", function(bought) if bought then if data.current.price > 0 then - ESX.ShowNotification(TranslateCap('armory_bought', data.current.weaponLabel, ESX.Math.GroupDigits(data.current.price))) + ESX.ShowNotification( + TranslateCap( + "armory_bought", + data.current.weaponLabel, + ESX.Math.GroupDigits(data.current.price) + ) + ) end ESX.CloseContext() OpenBuyWeaponsMenu() else - ESX.ShowNotification(TranslateCap('armory_money')) + ESX.ShowNotification(TranslateCap("armory_money")) end end, data.current.name, 1) end @@ -834,23 +888,28 @@ function OpenBuyWeaponsMenu() end function OpenWeaponComponentShop(components, weaponName, parentShop) - - ESX.OpenContext("right", components, function(menu,element) - local data = {current = element} + ESX.OpenContext("right", components, function(menu, element) + local data = { current = element } if data.current.hasComponent then - ESX.ShowNotification(TranslateCap('armory_hascomponent')) + ESX.ShowNotification(TranslateCap("armory_hascomponent")) else - ESX.TriggerServerCallback('esx_policejob:buyWeapon', function(bought) + ESX.TriggerServerCallback("esx_policejob:buyWeapon", function(bought) if bought then if data.current.price > 0 then - ESX.ShowNotification(TranslateCap('armory_bought', data.current.componentLabel, ESX.Math.GroupDigits(data.current.price))) + ESX.ShowNotification( + TranslateCap( + "armory_bought", + data.current.componentLabel, + ESX.Math.GroupDigits(data.current.price) + ) + ) end ESX.CloseContext() parentShop.close() OpenBuyWeaponsMenu() else - ESX.ShowNotification(TranslateCap('armory_money')) + ESX.ShowNotification(TranslateCap("armory_money")) end end, weaponName, 2, data.current.componentNum) end @@ -858,38 +917,45 @@ function OpenWeaponComponentShop(components, weaponName, parentShop) end function OpenGetStocksMenu() - ESX.TriggerServerCallback('esx_policejob:getStockItems', function(items) + ESX.TriggerServerCallback("esx_policejob:getStockItems", function(items) local elements = { - {unselectable = true, icon = "fas fa-box", title = TranslateCap('police_stock')} + { unselectable = true, icon = "fas fa-box", title = TranslateCap("police_stock") }, } - for i=1, #items, 1 do - elements[#elements+1] = { + for i = 1, #items, 1 do + elements[#elements + 1] = { icon = "fas fa-box", - title = 'x' .. items[i].count .. ' ' .. items[i].label, - value = items[i].name + title = "x" .. items[i].count .. " " .. items[i].label, + value = items[i].name, } end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } local itemName = data.current.value local elements2 = { - {unselectable = true, icon = "fas fa-box", title = element.title}, - {title = TranslateCap('quantity'), input = true, inputType = "number", inputMin = 1, inputMax = 150, inputPlaceholder = TranslateCap('quantity_placeholder')}, - {icon = "fas fa-check-double", title = TranslateCap('confirm'), value = "confirm"} + { unselectable = true, icon = "fas fa-box", title = element.title }, + { + title = TranslateCap("quantity"), + input = true, + inputType = "number", + inputMin = 1, + inputMax = 150, + inputPlaceholder = TranslateCap("quantity_placeholder"), + }, + { icon = "fas fa-check-double", title = TranslateCap("confirm"), value = "confirm" }, } - ESX.OpenContext("right", elements2, function(menu2,element2) - local data2 = {value = menu2.eles[2].inputValue} + ESX.OpenContext("right", elements2, function(menu2, element2) + local data2 = { value = menu2.eles[2].inputValue } local count = tonumber(data2.value) if not count then - ESX.ShowNotification(TranslateCap('quantity_invalid')) + ESX.ShowNotification(TranslateCap("quantity_invalid")) else ESX.CloseContext() - TriggerServerEvent('esx_policejob:getStockItem', itemName, count) + TriggerServerEvent("esx_policejob:getStockItem", itemName, count) Wait(300) OpenGetStocksMenu() @@ -900,43 +966,50 @@ function OpenGetStocksMenu() end function OpenPutStocksMenu() - ESX.TriggerServerCallback('esx_policejob:getPlayerInventory', function(inventory) + ESX.TriggerServerCallback("esx_policejob:getPlayerInventory", function(inventory) local elements = { - {unselectable = true, icon = "fas fa-box", title = TranslateCap('inventory')} + { unselectable = true, icon = "fas fa-box", title = TranslateCap("inventory") }, } - for i=1, #inventory.items, 1 do + for i = 1, #inventory.items, 1 do local item = inventory.items[i] if item.count > 0 then - elements[#elements+1] = { + elements[#elements + 1] = { icon = "fas fa-box", - title = item.label .. ' x' .. item.count, - type = 'item_standard', - value = item.name + title = item.label .. " x" .. item.count, + type = "item_standard", + value = item.name, } end end - ESX.OpenContext("right", elements, function(menu,element) - local data = {current = element} + ESX.OpenContext("right", elements, function(menu, element) + local data = { current = element } local itemName = data.current.value local elements2 = { - {unselectable = true, icon = "fas fa-box", title = element.title}, - {title = TranslateCap('quantity'), input = true, inputType = "number", inputMin = 1, inputMax = 150, inputPlaceholder = TranslateCap('quantity_placeholder')}, - {icon = "fas fa-check-double", title = TranslateCap('confirm'), value = "confirm"} + { unselectable = true, icon = "fas fa-box", title = element.title }, + { + title = TranslateCap("quantity"), + input = true, + inputType = "number", + inputMin = 1, + inputMax = 150, + inputPlaceholder = TranslateCap("quantity_placeholder"), + }, + { icon = "fas fa-check-double", title = TranslateCap("confirm"), value = "confirm" }, } - ESX.OpenContext("right", elements2, function(menu2,element2) - local data2 = {value = menu2.eles[2].inputValue} + ESX.OpenContext("right", elements2, function(menu2, element2) + local data2 = { value = menu2.eles[2].inputValue } local count = tonumber(data2.value) if not count then - ESX.ShowNotification(TranslateCap('quantity_invalid')) + ESX.ShowNotification(TranslateCap("quantity_invalid")) else ESX.CloseContext() - TriggerServerEvent('esx_policejob:putStockItems', itemName, count) + TriggerServerEvent("esx_policejob:putStockItems", itemName, count) Wait(300) OpenPutStocksMenu() @@ -947,27 +1020,29 @@ function OpenPutStocksMenu() end function OnPlayerData(k, v) - if k ~= 'job' then return end - if v.name == 'police' then + if k ~= "job" then + return + end + if v.name == "police" then Wait(1000) - TriggerServerEvent('esx_policejob:forceBlip') + TriggerServerEvent("esx_policejob:forceBlip") end end -RegisterNetEvent('esx_phone:loaded') -AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts) +RegisterNetEvent("esx_phone:loaded") +AddEventHandler("esx_phone:loaded", function(phoneNumber, contacts) local specialContact = { - name = TranslateCap('phone_police'), - number = 'police', - base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NDFGQTJDRkI0QUJCMTFFN0JBNkQ5OENBMUI4QUEzM0YiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDFGQTJDRkM0QUJCMTFFN0JBNkQ5OENBMUI4QUEzM0YiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0MUZBMkNGOTRBQkIxMUU3QkE2RDk4Q0ExQjhBQTMzRiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo0MUZBMkNGQTRBQkIxMUU3QkE2RDk4Q0ExQjhBQTMzRiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoW66EYAAAjGSURBVHjapJcLcFTV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' + name = TranslateCap("phone_police"), + number = "police", + base64Icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NDFGQTJDRkI0QUJCMTFFN0JBNkQ5OENBMUI4QUEzM0YiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDFGQTJDRkM0QUJCMTFFN0JBNkQ5OENBMUI4QUEzM0YiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0MUZBMkNGOTRBQkIxMUU3QkE2RDk4Q0ExQjhBQTMzRiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo0MUZBMkNGQTRBQkIxMUU3QkE2RDk4Q0ExQjhBQTMzRiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoW66EYAAAjGSURBVHjapJcLcFTVGcd/u3cfSXaTLEk2j80TCI8ECI9ABCyoiBqhBVQqVG2ppVKBQqUVgUl5OU7HKqNOHUHU0oHamZZWoGkVS6cWAR2JPJuAQBPy2ISEvLN57+v2u2E33e4k6Ngz85+9d++95/zP9/h/39GpqsqiRYsIGz8QZAq28/8PRfC+4HT4fMXFxeiH+GC54NeCbYLLATLpYe/ECx4VnBTsF0wWhM6lXY8VbBE0Ch4IzLcpfDFD2P1TgrdC7nMCZLRxQ9AkiAkQCn77DcH3BC2COoFRkCSIG2JzLwqiQi0RSmCD4JXbmNKh0+kc/X19tLtc9Ll9sk9ZS1yoU71YIk3xsbEx8QaDEc2ttxmaJSKC1ggSKBK8MKwTFQVXRzs3WzpJGjmZgvxcMpMtWIwqsjztvSrlzjYul56jp+46qSmJmMwR+P3+4aZ8TtCprRkk0DvUW7JjmV6lsqoKW/pU1q9YQOE4Nxkx4ladE7zd8ivuVmJQfXZKW5dx5EwPRw4fxNx2g5SUVLw+33AkzoRaQDP9SkFu6OKqz0uF8yaz7vsOL6ycQVLkcSg/BlWNsjuFoKE1knqDSl5aNnmPLmThrE0UvXqQqvJPyMrMGorEHwQfEha57/3P7mXS684GFjy8kreLppPUuBXfyd/ibeoS2kb0mWPANhJdYjb61AxUvx5PdT3+4y+Tb3mTd19ZSebE+VTXVGNQlHAC7w4VhH8TbA36vKq6ilnzlvPSunHw6Trc7XpZ14AyfgYeyz18crGN1Alz6e3qwNNQSv4dZox1h/BW9+O7eIaEsVv41Y4XeHJDG83Nl4mLTwzGhJYtx0PzNTjOB9KMTlc7Nkcem39YAGU7cbeBKVLMPGMVf296nMd2VbBq1wmizHoqqm/wrS1/Zf0+N19YN2PIu1fcIda4Vk66Zx/rVi+jo9eIX9wZGGcFXUMR6BHUa76/2ezioYcXMtpyAl91DSaTfDxlJbtLprHm2ecpObqPuTPzSNV9yKz4a4zJSuLo71/j8Q17ON69EmXiPIlNMe6FoyzOqWPW/MU03Lw5EFcyKghTrNDh7+/vw545mcJcWbTiGKpRdGPMXbx90sGmDaux6sXk+kimjU+BjnMkx3kYP34cXrFuZ+3nrHi6iDMt92JITcPjk3R3naRwZhpuNSqoD93DKaFVU7j2dhcF8+YzNlpErbIBTVh8toVccbaysPB+4pMcuPw25kwSsau7BIlmHpy3guaOPtISYyi/UkaJM5Lpc5agq5Xkcl6gIHkmqaMn0dtylcjIyPThCNyhaXyfR2W0I1our0v6qBii07ih5rDtGSOxNVdk1y4R2SR8jR/g7hQD9l1jUeY/WLJB5m39AlZN4GZyIQ1fFJNsEgt0duBIc5GRkcZF53mNwIzhXPDgQPoZIkiMkbTxtstDMVnmFA4cOsbz2/aKjSQjev4Mp9ZAg+hIpFhB3EH5Yal16+X+Kq3dGfxkzRY+KauBjBzREvGN0kNCTARu94AejBLMHorAQ7cEQMGs2cXvkWshYLDi6e9l728O8P1XW6hKeB2yv42q18tjj+iFTGoSi+X9jJM9RTxS9E+OHT0krhNiZqlbqraoT7RAU5bBGrEknEBhgJks7KXbLS8qERI0ErVqF/Y4K6NHZfLZB+/wzJvncacvFd91oXO3o/O40MfZKJOKu/rne+mRQByXM4lYreb1tUnkizVVA/0SpfpbWaCNBeEE5gb/UH19NLqEgDF+oNDQWcn41Cj0EXFEWqzkOIyYekslFkThsvMxpIyE2hIc6lXGZ6cPyK7Nnk5OipixRdxgUESAYmhq68VsGgy5CYKCUAJTg0+izApXne3CJFmUTwg4L3FProFxU+6krqmXu3MskkhSD2av41jLdzlnfFrSdCZxyqfMnppN6ZUa7pwt0h3fiK9DCt4IO9e7YqisvI7VYgmNv7mhBKKD/9psNi5dOMv5ZjukjsLdr0ffWsyTi6eSlfcA+dmiVyOXs+/sHNZu3M6PdxzgVO9GmDSHsSNqmTz/R6y6Xxqma4fwaS5Mn85n1ZE0Vl3CHBER3lUNEhiURpPJRFdTOcVnpUJnPIhR7cZXfoH5UYc5+E4RzRH3sfSnl9m2dSMjE+Tz9msse+o5dr7UwcQ5T3HwlWUkNuzG3dKFSTbsNs7m/Y8vExOlC29UWkMJlAxKoRQMR3IC7x85zOn6fHS50+U/2Untx2R1voinu5no+DQmz7yPXmMKZnsu0wrm0Oe3YhOVHdm8A09dBQYhTv4T7C+xUPrZh8Qn2MMr4qcDSRfoirWgKAvtgOpv1JI8Zi77X15G7L+fxeOUOiUFxZiULD5fSlNzNM62W+k1yq5gjajGX/ZHvOIyxd+Fkj+P092rWP/si0Qr7VisMaEWuCiYonXFwbAUTWWPYLV245NITnGkUXnpI9butLJn2y6iba+hlp7C09qBcvoN7FYL9mhxo1/y/LoEXK8Pv6qIC8WbBY/xr9YlPLf9dZT+OqKTUwfmDBm/GOw7ws4FWpuUP2gJEZvKqmocuXPZuWYJMzKuSsH+SNwh3bo0p6hao6HeEqwYEZ2M6aKWd3PwTCy7du/D0F1DsmzE6/WGLr5LsDF4LggnYBacCOboQLHQ3FFfR58SR+HCR1iQH8ukhA5s5o5AYZMwUqOp74nl8xvRHDlRTsnxYpJsUjtsceHt2C8Fm0MPJrphTkZvBc4It9RKLOFx91Pf0Igu0k7W2MmkOewS2QYJUJVWVz9VNbXUVVwkyuAmKTFJayrDo/4Jwe/CT0aGYTrWVYEeUfsgXssMRcpyenraQJa0VX9O3ZU+Ma1fax4xGxUsUVFkOUbcama1hf+7+LmA9juHWshwmwOE1iMmCFYEzg1jtIm1BaxW6wCGGoFdewPfvyE4ertTiv4rHC73B855dwp2a23bbd4tC1hvhOCbX7b4VyUQKhxrtSOaYKngasizvwi0RmOS4O1QZf2yYfiaR+73AvhTQEVf+rpn9/8IMAChKDrDzfsdIQAAAABJRU5ErkJggg==", } - TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon) + TriggerEvent("esx_phone:addSpecialContact", specialContact.name, specialContact.number, specialContact.base64Icon) end) -- don't show dispatches if the player isn't in service -AddEventHandler('esx_phone:cancelMessage', function(dispatchNumber) - if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' and ESX.PlayerData.job.name == dispatchNumber then +AddEventHandler("esx_phone:cancelMessage", function(dispatchNumber) + if ESX.PlayerData.job and ESX.PlayerData.job.name == "police" and ESX.PlayerData.job.name == dispatchNumber then -- if esx_service is enabled if Config.EnableESXService and not playerInService then CancelEvent() @@ -975,31 +1050,31 @@ AddEventHandler('esx_phone:cancelMessage', function(dispatchNumber) end end) -AddEventHandler('esx_policejob:hasEnteredMarker', function(station, part, partNum) - if part == 'Cloakroom' then - CurrentAction = 'menu_cloakroom' - CurrentActionMsg = TranslateCap('open_cloackroom') +AddEventHandler("esx_policejob:hasEnteredMarker", function(station, part, partNum) + if part == "Cloakroom" then + CurrentAction = "menu_cloakroom" + CurrentActionMsg = TranslateCap("open_cloackroom") CurrentActionData = {} - elseif part == 'Armory' then - CurrentAction = 'menu_armory' - CurrentActionMsg = TranslateCap('open_armory') - CurrentActionData = {station = station} - elseif part == 'Vehicles' then - CurrentAction = 'menu_vehicle_spawner' - CurrentActionMsg = TranslateCap('garage_prompt') - CurrentActionData = {station = station, part = part, partNum = partNum} - elseif part == 'Helicopters' then - CurrentAction = 'Helicopters' - CurrentActionMsg = TranslateCap('helicopter_prompt') - CurrentActionData = {station = station, part = part, partNum = partNum} - elseif part == 'BossActions' then - CurrentAction = 'menu_boss_actions' - CurrentActionMsg = TranslateCap('open_bossmenu') + elseif part == "Armory" then + CurrentAction = "menu_armory" + CurrentActionMsg = TranslateCap("open_armory") + CurrentActionData = { station = station } + elseif part == "Vehicles" then + CurrentAction = "menu_vehicle_spawner" + CurrentActionMsg = TranslateCap("garage_prompt") + CurrentActionData = { station = station, part = part, partNum = partNum } + elseif part == "Helicopters" then + CurrentAction = "Helicopters" + CurrentActionMsg = TranslateCap("helicopter_prompt") + CurrentActionData = { station = station, part = part, partNum = partNum } + elseif part == "BossActions" then + CurrentAction = "menu_boss_actions" + CurrentActionMsg = TranslateCap("open_bossmenu") CurrentActionData = {} end end) -AddEventHandler('esx_policejob:hasExitedMarker', function(station, part, partNum) +AddEventHandler("esx_policejob:hasExitedMarker", function(station, part, partNum) if not isInShopMenu then ESX.CloseContext() end @@ -1007,48 +1082,47 @@ AddEventHandler('esx_policejob:hasExitedMarker', function(station, part, partNum CurrentAction = nil end) -AddEventHandler('esx_policejob:hasEnteredEntityZone', function(entity) +AddEventHandler("esx_policejob:hasEnteredEntityZone", function(entity) local playerPed = PlayerPedId() - if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' and IsPedOnFoot(playerPed) then - CurrentAction = 'remove_entity' - CurrentActionMsg = TranslateCap('remove_prop') - CurrentActionData = {entity = entity} + if ESX.PlayerData.job and ESX.PlayerData.job.name == "police" and IsPedOnFoot(playerPed) then + CurrentAction = "remove_entity" + CurrentActionMsg = TranslateCap("remove_prop") + CurrentActionData = { entity = entity } end if GetEntityModel(entity) == `p_ld_stinger_s` then - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) + local _ = GetEntityCoords(playerPed) if IsPedInAnyVehicle(playerPed, false) then local vehicle = GetVehiclePedIsIn(playerPed) - for i=0, 7, 1 do + for i = 0, 7, 1 do SetVehicleTyreBurst(vehicle, i, true, 1000) end end end end) -AddEventHandler('esx_policejob:hasExitedEntityZone', function(entity) - if CurrentAction == 'remove_entity' then +AddEventHandler("esx_policejob:hasExitedEntityZone", function(entity) + if CurrentAction == "remove_entity" then CurrentAction = nil end end) -RegisterNetEvent('esx_policejob:handcuff') -AddEventHandler('esx_policejob:handcuff', function() +RegisterNetEvent("esx_policejob:handcuff") +AddEventHandler("esx_policejob:handcuff", function() isHandcuffed = not isHandcuffed local playerPed = PlayerPedId() if isHandcuffed then - RequestAnimDict('mp_arresting') - while not HasAnimDictLoaded('mp_arresting') do + RequestAnimDict("mp_arresting") + while not HasAnimDictLoaded("mp_arresting") do Wait(100) end - TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0, 0, 0, 0) - RemoveAnimDict('mp_arresting') + TaskPlayAnim(playerPed, "mp_arresting", "idle", 8.0, -8, -1, 49, 0, 0, 0, 0) + RemoveAnimDict("mp_arresting") SetEnableHandcuffs(playerPed, true) DisablePlayerFiring(playerPed, true) @@ -1078,8 +1152,8 @@ AddEventHandler('esx_policejob:handcuff', function() end end) -RegisterNetEvent('esx_policejob:unrestrain') -AddEventHandler('esx_policejob:unrestrain', function() +RegisterNetEvent("esx_policejob:unrestrain") +AddEventHandler("esx_policejob:unrestrain", function() if isHandcuffed then local playerPed = PlayerPedId() isHandcuffed = false @@ -1098,8 +1172,8 @@ AddEventHandler('esx_policejob:unrestrain', function() end end) -RegisterNetEvent('esx_policejob:drag') -AddEventHandler('esx_policejob:drag', function(copId) +RegisterNetEvent("esx_policejob:drag") +AddEventHandler("esx_policejob:drag", function(copId) if isHandcuffed then dragStatus.isDragged = not dragStatus.isDragged dragStatus.CopId = copId @@ -1118,7 +1192,23 @@ CreateThread(function() if DoesEntityExist(targetPed) and IsPedOnFoot(targetPed) and not IsPedDeadOrDying(targetPed, true) then if not wasDragged then - AttachEntityToEntity(ESX.PlayerData.ped, targetPed, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true) + AttachEntityToEntity( + ESX.PlayerData.ped, + targetPed, + 11816, + 0.54, + 0.54, + 0.0, + 0.0, + 0.0, + 0.0, + false, + false, + false, + false, + 2, + true + ) wasDragged = true else Wait(1000) @@ -1132,12 +1222,12 @@ CreateThread(function() wasDragged = false DetachEntity(ESX.PlayerData.ped, true, false) end - Wait(Sleep) + Wait(Sleep) end end) -RegisterNetEvent('esx_policejob:putInVehicle') -AddEventHandler('esx_policejob:putInVehicle', function() +RegisterNetEvent("esx_policejob:putInVehicle") +AddEventHandler("esx_policejob:putInVehicle", function() if isHandcuffed then local playerPed = PlayerPedId() local vehicle, distance = ESX.Game.GetClosestVehicle() @@ -1145,7 +1235,7 @@ AddEventHandler('esx_policejob:putInVehicle', function() if vehicle and distance < 5 then local maxSeats, freeSeat = GetVehicleMaxNumberOfPassengers(vehicle) - for i=maxSeats - 1, 0, -1 do + for i = maxSeats - 1, 0, -1 do if IsVehicleSeatFree(vehicle, i) then freeSeat = i break @@ -1160,8 +1250,8 @@ AddEventHandler('esx_policejob:putInVehicle', function() end end) -RegisterNetEvent('esx_policejob:OutVehicle') -AddEventHandler('esx_policejob:OutVehicle', function() +RegisterNetEvent("esx_policejob:OutVehicle") +AddEventHandler("esx_policejob:OutVehicle", function() local GetVehiclePedIsIn = GetVehiclePedIsIn local IsPedSittingInAnyVehicle = IsPedSittingInAnyVehicle local TaskLeaveVehicle = TaskLeaveVehicle @@ -1197,7 +1287,7 @@ CreateThread(function() DisableControlAction(0, 37, true) -- Select Weapon DisableControlAction(0, 23, true) -- Also 'enter'? - DisableControlAction(0, 288, true) -- Disable phone + DisableControlAction(0, 288, true) -- Disable phone DisableControlAction(0, 289, true) -- Inventory DisableControlAction(0, 170, true) -- Animations DisableControlAction(0, 167, true) -- Job @@ -1213,40 +1303,40 @@ CreateThread(function() DisableControlAction(2, 36, true) -- Disable going stealth - DisableControlAction(0, 47, true) -- Disable weapon + DisableControlAction(0, 47, true) -- Disable weapon DisableControlAction(0, 264, true) -- Disable melee DisableControlAction(0, 257, true) -- Disable melee DisableControlAction(0, 140, true) -- Disable melee DisableControlAction(0, 141, true) -- Disable melee DisableControlAction(0, 142, true) -- Disable melee DisableControlAction(0, 143, true) -- Disable melee - DisableControlAction(0, 75, true) -- Disable exit vehicle + DisableControlAction(0, 75, true) -- Disable exit vehicle DisableControlAction(27, 75, true) -- Disable exit vehicle - if IsEntityPlayingAnim(ESX.PlayerData.ped, 'mp_arresting', 'idle', 3) ~= 1 then - ESX.Streaming.RequestAnimDict('mp_arresting', function() - TaskPlayAnim(ESX.PlayerData.ped, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0.0, false, false, false) - RemoveAnimDict('mp_arresting') + if IsEntityPlayingAnim(ESX.PlayerData.ped, "mp_arresting", "idle", 3) ~= 1 then + ESX.Streaming.RequestAnimDict("mp_arresting", function() + TaskPlayAnim(ESX.PlayerData.ped, "mp_arresting", "idle", 8.0, -8, -1, 49, 0.0, false, false, false) + RemoveAnimDict("mp_arresting") end) end end - Wait(Sleep) + Wait(Sleep) end end) -- Create blips CreateThread(function() - for k,v in pairs(Config.PoliceStations) do + for _, v in pairs(Config.PoliceStations) do local blip = AddBlipForCoord(v.Blip.Coords) - SetBlipSprite (blip, v.Blip.Sprite) + SetBlipSprite(blip, v.Blip.Sprite) SetBlipDisplay(blip, v.Blip.Display) - SetBlipScale (blip, v.Blip.Scale) - SetBlipColour (blip, v.Blip.Colour) + SetBlipScale(blip, v.Blip.Scale) + SetBlipColour(blip, v.Blip.Colour) SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName('STRING') - AddTextComponentSubstringPlayerName(TranslateCap('map_blip')) + BeginTextCommandSetBlipName("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("map_blip")) EndTextCommandSetBlipName(blip) end end) @@ -1255,105 +1345,226 @@ end) CreateThread(function() while true do local Sleep = 1500 - if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' then + if ESX.PlayerData.job and ESX.PlayerData.job.name == "police" then Sleep = 500 local playerPed = PlayerPedId() local playerCoords = GetEntityCoords(playerPed) local isInMarker, hasExited = false, false local currentStation, currentPart, currentPartNum - for k,v in pairs(Config.PoliceStations) do - for i=1, #v.Cloakrooms, 1 do + for k, v in pairs(Config.PoliceStations) do + for i = 1, #v.Cloakrooms, 1 do local distance = #(playerCoords - v.Cloakrooms[i]) if distance < Config.DrawDistance then - DrawMarker(Config.MarkerType.Cloakrooms, v.Cloakrooms[i], 0.0, 0.0, 0.0, 0, 0.0, 0.0, 1.0, 1.0, 1.0, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + DrawMarker( + Config.MarkerType.Cloakrooms, + v.Cloakrooms[i], + 0.0, + 0.0, + 0.0, + 0, + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + Config.MarkerColor.r, + Config.MarkerColor.g, + Config.MarkerColor.b, + 100, + false, + true, + 2, + true, + false, + false, + false + ) Sleep = 0 if distance < Config.MarkerSize.x then - isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Cloakroom', i + isInMarker, currentStation, currentPart, currentPartNum = true, k, "Cloakroom", i end end end - for i=1, #v.Armories, 1 do + for i = 1, #v.Armories, 1 do local distance = #(playerCoords - v.Armories[i]) if distance < Config.DrawDistance then - DrawMarker(Config.MarkerType.Armories, v.Armories[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + DrawMarker( + Config.MarkerType.Armories, + v.Armories[i], + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.5, + 0.5, + 0.5, + Config.MarkerColor.r, + Config.MarkerColor.g, + Config.MarkerColor.b, + 100, + false, + true, + 2, + true, + false, + false, + false + ) Sleep = 0 if distance < Config.MarkerSize.x then - isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Armory', i + isInMarker, currentStation, currentPart, currentPartNum = true, k, "Armory", i end end end - for i=1, #v.Vehicles, 1 do + for i = 1, #v.Vehicles, 1 do local distance = #(playerCoords - v.Vehicles[i].Spawner) if distance < Config.DrawDistance then - DrawMarker(Config.MarkerType.Vehicles, v.Vehicles[i].Spawner, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + DrawMarker( + Config.MarkerType.Vehicles, + v.Vehicles[i].Spawner, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + Config.MarkerColor.r, + Config.MarkerColor.g, + Config.MarkerColor.b, + 100, + false, + true, + 2, + true, + false, + false, + false + ) Sleep = 0 if distance < Config.MarkerSize.x then - isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Vehicles', i + isInMarker, currentStation, currentPart, currentPartNum = true, k, "Vehicles", i end end end - for i=1, #v.Helicopters, 1 do - local distance = #(playerCoords - v.Helicopters[i].Spawner) + for i = 1, #v.Helicopters, 1 do + local distance = #(playerCoords - v.Helicopters[i].Spawner) if distance < Config.DrawDistance then - DrawMarker(Config.MarkerType.Helicopters, v.Helicopters[i].Spawner, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + DrawMarker( + Config.MarkerType.Helicopters, + v.Helicopters[i].Spawner, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + Config.MarkerColor.r, + Config.MarkerColor.g, + Config.MarkerColor.b, + 100, + false, + true, + 2, + true, + false, + false, + false + ) Sleep = 0 if distance < Config.MarkerSize.x then - isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Helicopters', i + isInMarker, currentStation, currentPart, currentPartNum = true, k, "Helicopters", i end end end - if Config.EnablePlayerManagement and ESX.PlayerData.job.grade_name == 'boss' then - for i=1, #v.BossActions, 1 do + if Config.EnablePlayerManagement and ESX.PlayerData.job.grade_name == "boss" then + for i = 1, #v.BossActions, 1 do local distance = #(playerCoords - v.BossActions[i]) if distance < Config.DrawDistance then - DrawMarker(Config.MarkerType.BossActions, v.BossActions[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false) + DrawMarker( + Config.MarkerType.BossActions, + v.BossActions[i], + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + Config.MarkerColor.r, + Config.MarkerColor.g, + Config.MarkerColor.b, + 100, + false, + true, + 2, + true, + false, + false, + false + ) Sleep = 0 if distance < Config.MarkerSize.x then - isInMarker, currentStation, currentPart, currentPartNum = true, k, 'BossActions', i + isInMarker, currentStation, currentPart, currentPartNum = true, k, "BossActions", i end end end end end - if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum)) then + if + isInMarker and not HasAlreadyEnteredMarker + or ( + isInMarker + and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum) + ) + then if - (LastStation and LastPart and LastPartNum) and - (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum) + (LastStation and LastPart and LastPartNum) + and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum) then - TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum) + TriggerEvent("esx_policejob:hasExitedMarker", LastStation, LastPart, LastPartNum) hasExited = true end HasAlreadyEnteredMarker = true - LastStation = currentStation - LastPart = currentPart - LastPartNum = currentPartNum + LastStation = currentStation + LastPart = currentPart + LastPartNum = currentPartNum - TriggerEvent('esx_policejob:hasEnteredMarker', currentStation, currentPart, currentPartNum) + TriggerEvent("esx_policejob:hasEnteredMarker", currentStation, currentPart, currentPartNum) end if not hasExited and not isInMarker and HasAlreadyEnteredMarker then HasAlreadyEnteredMarker = false - TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum) + TriggerEvent("esx_policejob:hasExitedMarker", LastStation, LastPart, LastPartNum) end end - Wait(Sleep) + Wait(Sleep) end end) @@ -1364,115 +1575,132 @@ CreateThread(function() `prop_barrier_work05`, `p_ld_stinger_s`, `prop_boxpile_07d`, - `hei_prop_cash_crate_half_full` + `hei_prop_cash_crate_half_full`, } while true do local Sleep = 1500 - local GetEntityCoords = GetEntityCoords - local GetClosestObjectOfType = GetClosestObjectOfType - local DoesEntityExist = DoesEntityExist - local playerCoords = GetEntityCoords(ESX.PlayerData.ped) - - local closestDistance = -1 - local closestEntity = nil - - for i=1, #trackedEntities, 1 do - local object = GetClosestObjectOfType(playerCoords, 3.0, trackedEntities[i], false, false, false) - - if DoesEntityExist(object) then - Sleep = 500 - local objCoords = GetEntityCoords(object) - local distance = #(playerCoords - objCoords) - - if closestDistance == -1 or closestDistance > distance then - closestDistance = distance - closestEntity = object - end + local GetEntityCoords = GetEntityCoords + local GetClosestObjectOfType = GetClosestObjectOfType + local DoesEntityExist = DoesEntityExist + local playerCoords = GetEntityCoords(ESX.PlayerData.ped) + + local closestDistance = -1 + local closestEntity = nil + + for i = 1, #trackedEntities, 1 do + local object = GetClosestObjectOfType(playerCoords, 3.0, trackedEntities[i], false, false, false) + + if DoesEntityExist(object) then + Sleep = 500 + local objCoords = GetEntityCoords(object) + local distance = #(playerCoords - objCoords) + + if closestDistance == -1 or closestDistance > distance then + closestDistance = distance + closestEntity = object end end + end - if closestDistance ~= -1 and closestDistance <= 3.0 then - if LastEntity ~= closestEntity then - TriggerEvent('esx_policejob:hasEnteredEntityZone', closestEntity) - LastEntity = closestEntity - end - else - if LastEntity then - TriggerEvent('esx_policejob:hasExitedEntityZone', LastEntity) - LastEntity = nil - end + if closestDistance ~= -1 and closestDistance <= 3.0 then + if LastEntity ~= closestEntity then + TriggerEvent("esx_policejob:hasEnteredEntityZone", closestEntity) + LastEntity = closestEntity + end + else + if LastEntity then + TriggerEvent("esx_policejob:hasExitedEntityZone", LastEntity) + LastEntity = nil end + end Wait(Sleep) end end) -ESX.RegisterInput("police:interact", "(ESX PoliceJob) " .. TranslateCap('interaction'), "keyboard", "E", function() - if not CurrentAction then - return - end - - if not ESX.PlayerData.job or (ESX.PlayerData.job and not ESX.PlayerData.job.name == 'police') then +ESX.RegisterInput("police:interact", "(ESX PoliceJob) " .. TranslateCap("interaction"), "keyboard", "E", function() + if not CurrentAction then return end - if CurrentAction == 'menu_cloakroom' then + + if CurrentAction == "menu_cloakroom" then OpenCloakroomMenu() - elseif CurrentAction == 'menu_armory' then + elseif CurrentAction == "menu_armory" then if not Config.EnableESXService then OpenArmoryMenu(CurrentActionData.station) elseif playerInService then OpenArmoryMenu(CurrentActionData.station) else - ESX.ShowNotification(TranslateCap('service_not')) + ESX.ShowNotification(TranslateCap("service_not")) end - elseif CurrentAction == 'menu_vehicle_spawner' then + elseif CurrentAction == "menu_vehicle_spawner" then if not Config.EnableESXService then - OpenVehicleSpawnerMenu('car', CurrentActionData.station, CurrentActionData.part, CurrentActionData.partNum) + OpenVehicleSpawnerMenu("car", CurrentActionData.station, CurrentActionData.part, CurrentActionData.partNum) elseif playerInService then - OpenVehicleSpawnerMenu('car', CurrentActionData.station, CurrentActionData.part, CurrentActionData.partNum) + OpenVehicleSpawnerMenu("car", CurrentActionData.station, CurrentActionData.part, CurrentActionData.partNum) else - ESX.ShowNotification(TranslateCap('service_not')) + ESX.ShowNotification(TranslateCap("service_not")) end - elseif CurrentAction == 'Helicopters' then + elseif CurrentAction == "Helicopters" then if not Config.EnableESXService then - OpenVehicleSpawnerMenu('helicopter', CurrentActionData.station, CurrentActionData.part, CurrentActionData.partNum) + OpenVehicleSpawnerMenu( + "helicopter", + CurrentActionData.station, + CurrentActionData.part, + CurrentActionData.partNum + ) elseif playerInService then - OpenVehicleSpawnerMenu('helicopter', CurrentActionData.station, CurrentActionData.part, CurrentActionData.partNum) + OpenVehicleSpawnerMenu( + "helicopter", + CurrentActionData.station, + CurrentActionData.part, + CurrentActionData.partNum + ) else - ESX.ShowNotification(TranslateCap('service_not')) + ESX.ShowNotification(TranslateCap("service_not")) end - elseif CurrentAction == 'delete_vehicle' then + elseif CurrentAction == "delete_vehicle" then ESX.Game.DeleteVehicle(CurrentActionData.vehicle) - elseif CurrentAction == 'menu_boss_actions' then + elseif CurrentAction == "menu_boss_actions" then ESX.CloseContext() - TriggerEvent('esx_society:openBossMenu', 'police', function(data, menu) + TriggerEvent("esx_society:openBossMenu", "police", function(data, menu) ESX.CloseContext() - CurrentAction = 'menu_boss_actions' - CurrentActionMsg = TranslateCap('open_bossmenu') + CurrentAction = "menu_boss_actions" + CurrentActionMsg = TranslateCap("open_bossmenu") CurrentActionData = {} end, { wash = false }) -- disable washing money - elseif CurrentAction == 'remove_entity' then + elseif CurrentAction == "remove_entity" then DeleteEntity(CurrentActionData.entity) end + if not ESX.PlayerData.job or (ESX.PlayerData.job and not ESX.PlayerData.job.name == "police") then + return + end + CurrentAction = nil end) -ESX.RegisterInput("police:quickactions", "(ESX PoliceJob) "..TranslateCap('quick_actions'), "keyboard", "F6", function() - if not ESX.PlayerData.job or (ESX.PlayerData.job.name ~= 'police') or isDead then - return - end +ESX.RegisterInput( + "police:quickactions", + "(ESX PoliceJob) " .. TranslateCap("quick_actions"), + "keyboard", + "F6", + function() + if not ESX.PlayerData.job or (ESX.PlayerData.job.name ~= "police") or isDead then + return + end - if not Config.EnableESXService then - OpenPoliceActionsMenu() - elseif playerInService then - OpenPoliceActionsMenu() - else - ESX.ShowNotification(TranslateCap('service_not')) + if not Config.EnableESXService then + OpenPoliceActionsMenu() + elseif playerInService then + OpenPoliceActionsMenu() + else + ESX.ShowNotification(TranslateCap("service_not")) + end end -end) +) CreateThread(function() while true do @@ -1482,7 +1710,7 @@ CreateThread(function() Sleep = 0 ESX.ShowHelpNotification(CurrentActionMsg) end - Wait(Sleep) + Wait(Sleep) end end) @@ -1504,11 +1732,10 @@ function createBlip(id) end end -RegisterNetEvent('esx_policejob:updateBlip') -AddEventHandler('esx_policejob:updateBlip', function() - +RegisterNetEvent("esx_policejob:updateBlip") +AddEventHandler("esx_policejob:updateBlip", function() -- Refresh all blips - for k, existingBlip in pairs(blipsCops) do + for _, existingBlip in pairs(blipsCops) do RemoveBlip(existingBlip) end @@ -1525,10 +1752,10 @@ AddEventHandler('esx_policejob:updateBlip', function() end -- Is the player a cop? In that case show all the blips for other cops - if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' then - ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players) - for i=1, #players, 1 do - if players[i].job.name == 'police' then + if ESX.PlayerData.job and ESX.PlayerData.job.name == "police" then + ESX.TriggerServerCallback("esx_society:getOnlinePlayers", function(players) + for i = 1, #players, 1 do + if players[i].job.name == "police" then local id = GetPlayerFromServerId(players[i].source) if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then createBlip(id) @@ -1537,30 +1764,29 @@ AddEventHandler('esx_policejob:updateBlip', function() end end) end - end) -AddEventHandler('esx:onPlayerSpawn', function(spawn) +AddEventHandler("esx:onPlayerSpawn", function(spawn) isDead = false - TriggerEvent('esx_policejob:unrestrain') + TriggerEvent("esx_policejob:unrestrain") if not hasAlreadyJoined then - TriggerServerEvent('esx_policejob:spawned') + TriggerServerEvent("esx_policejob:spawned") end hasAlreadyJoined = true end) -AddEventHandler('esx:onPlayerDeath', function(data) +AddEventHandler("esx:onPlayerDeath", function(data) isDead = true end) -AddEventHandler('onResourceStop', function(resource) +AddEventHandler("onResourceStop", function(resource) if resource == GetCurrentResourceName() then - TriggerEvent('esx_policejob:unrestrain') - TriggerEvent('esx_phone:removeSpecialContact', 'police') + TriggerEvent("esx_policejob:unrestrain") + TriggerEvent("esx_phone:removeSpecialContact", "police") if Config.EnableESXService then - TriggerServerEvent('esx_service:disableService', 'police') + TriggerServerEvent("esx_service:disableService", "police") end if Config.EnableHandcuffTimer and handcuffTimer.active then @@ -1578,8 +1804,8 @@ function StartHandcuffTimer() handcuffTimer.active = true handcuffTimer.task = ESX.SetTimeout(Config.HandcuffTimer, function() - ESX.ShowNotification(TranslateCap('unrestrained_timer')) - TriggerEvent('esx_policejob:unrestrain') + ESX.ShowNotification(TranslateCap("unrestrained_timer")) + TriggerEvent("esx_policejob:unrestrain") handcuffTimer.active = false end) end @@ -1588,14 +1814,13 @@ end -- - return to garage if owned -- - message owner that his vehicle has been impounded function ImpoundVehicle(vehicle) - --local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))) ESX.Game.DeleteVehicle(vehicle) - ESX.ShowNotification(TranslateCap('impound_successful')) + ESX.ShowNotification(TranslateCap("impound_successful")) currentTask.busy = false end -if ESX.PlayerLoaded and ESX.PlayerData.job == 'police' then +if ESX.PlayerLoaded and ESX.PlayerData.job == "police" then SetTimeout(1000, function() - TriggerServerEvent('esx_policejob:forceBlip') + TriggerServerEvent("esx_policejob:forceBlip") end) end diff --git a/server-data/resources/[esx_addons]/esx_policejob/client/vehicle.lua b/server-data/resources/[esx_addons]/esx_policejob/client/vehicle.lua index 9ac134a31..924a1fb3c 100644 --- a/server-data/resources/[esx_addons]/esx_policejob/client/vehicle.lua +++ b/server-data/resources/[esx_addons]/esx_policejob/client/vehicle.lua @@ -1,16 +1,15 @@ - local spawnedVehicles = {} function OpenVehicleSpawnerMenu(type, station, part, partNum) local playerCoords = GetEntityCoords(PlayerPedId()) local elements = { - {unselectable = true, icon = "fas fa-car", title = TranslateCap('garage_title')}, - {icon = "fas fa-car", title = TranslateCap('garage_storeditem'), action = 'garage'}, - {icon = "fas fa-car", title = TranslateCap('garage_storeitem'), action = 'store_garage'}, - {icon = "fas fa-car", title = TranslateCap('garage_buyitem'), action = 'buy_vehicle'} + { unselectable = true, icon = "fas fa-car", title = TranslateCap("garage_title") }, + { icon = "fas fa-car", title = TranslateCap("garage_storeditem"), action = "garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_storeitem"), action = "store_garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_buyitem"), action = "buy_vehicle" }, } - ESX.OpenContext("right", elements, function(menu,element) + ESX.OpenContext("right", elements, function(menu, element) if element.action == "buy_vehicle" then local shopElements = {} local shopCoords = Config.PoliceStations[station][part][partNum].InsideShop @@ -18,18 +17,21 @@ function OpenVehicleSpawnerMenu(type, station, part, partNum) if authorizedVehicles then if #authorizedVehicles > 0 then - for k,vehicle in ipairs(authorizedVehicles) do + for _, vehicle in ipairs(authorizedVehicles) do if IsModelInCdimage(vehicle.model) then local vehicleLabel = GetLabelText(GetDisplayNameFromVehicleModel(vehicle.model)) - shopElements[#shopElements+1] = { - icon = 'fas fa-car', - title = ('%s - %s'):format(vehicleLabel, TranslateCap('shop_item', ESX.Math.GroupDigits(vehicle.price))), - name = vehicleLabel, + shopElements[#shopElements + 1] = { + icon = "fas fa-car", + title = ('%s - %s'):format( + vehicleLabel, + TranslateCap("shop_item", ESX.Math.GroupDigits(vehicle.price)) + ), + name = vehicleLabel, model = vehicle.model, price = vehicle.price, props = vehicle.props, - type = type + type = type, } end end @@ -37,42 +39,49 @@ function OpenVehicleSpawnerMenu(type, station, part, partNum) if #shopElements > 0 then OpenShopMenu(shopElements, playerCoords, shopCoords) else - ESX.ShowNotification(TranslateCap('garage_notauthorized')) + ESX.ShowNotification(TranslateCap("garage_notauthorized")) end else - ESX.ShowNotification(TranslateCap('garage_notauthorized')) + ESX.ShowNotification(TranslateCap("garage_notauthorized")) end else - ESX.ShowNotification(TranslateCap('garage_notauthorized')) + ESX.ShowNotification(TranslateCap("garage_notauthorized")) end elseif element.action == "garage" then local garage = { - {unselectable = true, icon = "fas fa-car", title = "Garage"} + { unselectable = true, icon = "fas fa-car", title = "Garage" }, } - ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles) + ESX.TriggerServerCallback("esx_vehicleshop:retrieveJobVehicles", function(jobVehicles) if #jobVehicles > 0 then local allVehicleProps = {} - for k,v in ipairs(jobVehicles) do + for _, v in ipairs(jobVehicles) do local props = json.decode(v.vehicle) if IsModelInCdimage(props.model) then local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(props.model)) - local label = ('%s - %s: '):format(vehicleName, props.plate) + local label = ('%s - %s: '):format( + vehicleName, + props.plate + ) if v.stored == 1 or v.stored == true then - label = label .. ('%s'):format(TranslateCap('garage_stored')) + label = label + .. ('%s'):format(TranslateCap("garage_stored")) elseif v.stored == 0 or v.stored == false then - label = label .. ('%s'):format(TranslateCap('garage_notstored')) + label = label + .. ('%s'):format( + TranslateCap("garage_notstored") + ) end - garage[#garage+1] = { - icon = 'fas fa-car', + garage[#garage + 1] = { + icon = "fas fa-car", title = label, stored = v.stored, model = props.model, - plate = props.plate + plate = props.plate, } allVehicleProps[props.plate] = props @@ -80,30 +89,39 @@ function OpenVehicleSpawnerMenu(type, station, part, partNum) end if #garage > 0 then - ESX.OpenContext("right", garage, function(menuG,elementG) + ESX.OpenContext("right", garage, function(menuG, elementG) if elementG.stored == 1 or elementG.stored == true then local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(station, part, partNum) if foundSpawn then ESX.CloseContext() - ESX.Game.SpawnVehicle(elementG.model, spawnPoint.coords, spawnPoint.heading, function(vehicle) - local vehicleProps = allVehicleProps[elementG.plate] - ESX.Game.SetVehicleProperties(vehicle, vehicleProps) - - TriggerServerEvent('esx_vehicleshop:setJobVehicleState', elementG.plate, false) - ESX.ShowNotification(TranslateCap('garage_released')) - end) + ESX.Game.SpawnVehicle( + elementG.model, + spawnPoint.coords, + spawnPoint.heading, + function(vehicle) + local vehicleProps = allVehicleProps[elementG.plate] + ESX.Game.SetVehicleProperties(vehicle, vehicleProps) + + TriggerServerEvent( + "esx_vehicleshop:setJobVehicleState", + elementG.plate, + false + ) + ESX.ShowNotification(TranslateCap("garage_released")) + end + ) end else - ESX.ShowNotification(TranslateCap('garage_notavailable')) + ESX.ShowNotification(TranslateCap("garage_notavailable")) end end) else - ESX.ShowNotification(TranslateCap('garage_empty')) + ESX.ShowNotification(TranslateCap("garage_empty")) end else - ESX.ShowNotification(TranslateCap('garage_empty')) + ESX.ShowNotification(TranslateCap("garage_empty")) end end, type) elseif element.action == "store_garage" then @@ -118,7 +136,7 @@ function StoreNearbyVehicle(playerCoords) if next(vehicles) then for i = 1, #vehicles do local vehicle = vehicles[i] - + -- Make sure the vehicle we're saving is empty, or else it won't be deleted if GetVehicleNumberOfPassengers(vehicle) == 0 and IsVehicleSeatFree(vehicle, -1) then local plate = ESX.Math.Trim(GetVehicleNumberPlateText(vehicle)) @@ -127,11 +145,11 @@ function StoreNearbyVehicle(playerCoords) end end else - ESX.ShowNotification(TranslateCap('garage_store_nearby')) + ESX.ShowNotification(TranslateCap("garage_store_nearby")) return end - ESX.TriggerServerCallback('esx_policejob:storeNearbyVehicle', function(plate) + ESX.TriggerServerCallback("esx_policejob:storeNearbyVehicle", function(plate) if plate then local vehicleId = index[plate] local attempts = 0 @@ -139,8 +157,8 @@ function StoreNearbyVehicle(playerCoords) local isBusy = true CreateThread(function() - BeginTextCommandBusyspinnerOn('STRING') - AddTextComponentSubstringPlayerName(TranslateCap('garage_storing')) + BeginTextCommandBusyspinnerOn("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("garage_storing")) EndTextCommandBusyspinnerOn(4) while isBusy do @@ -173,9 +191,9 @@ function StoreNearbyVehicle(playerCoords) end isBusy = false - ESX.ShowNotification(TranslateCap('garage_has_stored')) + ESX.ShowNotification(TranslateCap("garage_has_stored")) else - ESX.ShowNotification(TranslateCap('garage_has_notstored')) + ESX.ShowNotification(TranslateCap("garage_has_notstored")) end end, plates) end @@ -184,7 +202,7 @@ function GetAvailableVehicleSpawnPoint(station, part, partNum) local spawnPoints = Config.PoliceStations[station][part][partNum].SpawnPoints local found, foundSpawnPoint = false, nil - for i=1, #spawnPoints, 1 do + for i = 1, #spawnPoints, 1 do if ESX.Game.IsSpawnPointClear(spawnPoints[i].coords, spawnPoints[i].radius) then found, foundSpawnPoint = true, spawnPoints[i] break @@ -194,7 +212,7 @@ function GetAvailableVehicleSpawnPoint(station, part, partNum) if found then return true, foundSpawnPoint else - ESX.ShowNotification(TranslateCap('vehicle_blocked')) + ESX.ShowNotification(TranslateCap("vehicle_blocked")) return false end end @@ -202,13 +220,13 @@ end function OpenShopMenu(elements, restoreCoords, shopCoords) local playerPed = PlayerPedId() isInShopMenu = true - ESX.OpenContext("right", elements, function(menu,element) + ESX.OpenContext("right", elements, function(menu, element) local elements2 = { - {unselectable = true, icon = "fas fa-car", title = element.title}, - {icon = "fas fa-eye", title = TranslateCap('view'), value = "view"} + { unselectable = true, icon = "fas fa-car", title = element.title }, + { icon = "fas fa-eye", title = TranslateCap("view"), value = "view" }, } - ESX.OpenContext("right", elements2, function(menu2,element2) + ESX.OpenContext("right", elements2, function(menu2, element2) if element2.value == "view" then DeleteSpawnedVehicles() WaitForVehicleToLoad(element.model) @@ -225,13 +243,13 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) end) local elements3 = { - {unselectable = true, icon = "fas fa-car", title = element.title}, - {icon = "fas fa-check-double", title = TranslateCap('buy_car'), value = "buy"}, - {icon = "fas fa-eye", title = TranslateCap('stop_view'), value = "stop"} + { unselectable = true, icon = "fas fa-car", title = element.title }, + { icon = "fas fa-check-double", title = TranslateCap("buy_car"), value = "buy" }, + { icon = "fas fa-eye", title = TranslateCap("stop_view"), value = "stop" }, } - ESX.OpenContext("right", elements3, function(menu3,element3) - if element3.value == 'stop' then + ESX.OpenContext("right", elements3, function(menu3, element3) + if element3.value == "stop" then isInShopMenu = false ESX.CloseContext() @@ -241,14 +259,20 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) ESX.Game.Teleport(playerPed, restoreCoords) elseif element3.value == "buy" then - local newPlate = exports['esx_vehicleshop']:GeneratePlate() - local vehicle = GetVehiclePedIsIn(playerPed, false) - local props = ESX.Game.GetVehicleProperties(vehicle) - props.plate = newPlate + local newPlate = exports["esx_vehicleshop"]:GeneratePlate() + local vehicle = GetVehiclePedIsIn(playerPed, false) + local props = ESX.Game.GetVehicleProperties(vehicle) + props.plate = newPlate - ESX.TriggerServerCallback('esx_policejob:buyJobVehicle', function (bought) + ESX.TriggerServerCallback("esx_policejob:buyJobVehicle", function(bought) if bought then - ESX.ShowNotification(TranslateCap('vehicleshop_bought', element.name, ESX.Math.GroupDigits(element.price))) + ESX.ShowNotification( + TranslateCap( + "vehicleshop_bought", + element.name, + ESX.Math.GroupDigits(element.price) + ) + ) isInShopMenu = false ESX.CloseContext() @@ -258,7 +282,7 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) ESX.Game.Teleport(playerPed, restoreCoords) else - ESX.ShowNotification(TranslateCap('vehicleshop_money')) + ESX.ShowNotification(TranslateCap("vehicleshop_money")) ESX.CloseContext() end end, props, element.type) @@ -278,13 +302,12 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) end) end - CreateThread(function() while true do Wait(0) if isInShopMenu then - DisableControlAction(0, 75, true) -- Disable exit vehicle + DisableControlAction(0, 75, true) -- Disable exit vehicle DisableControlAction(27, 75, true) -- Disable exit vehicle else Wait(500) @@ -301,13 +324,13 @@ function DeleteSpawnedVehicles() end function WaitForVehicleToLoad(modelHash) - modelHash = (type(modelHash) == 'number' and modelHash or joaat(modelHash)) + modelHash = (type(modelHash) == "number" and modelHash or joaat(modelHash)) if not HasModelLoaded(modelHash) then RequestModel(modelHash) - BeginTextCommandBusyspinnerOn('STRING') - AddTextComponentSubstringPlayerName(TranslateCap('vehicleshop_awaiting_model')) + BeginTextCommandBusyspinnerOn("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("vehicleshop_awaiting_model")) EndTextCommandBusyspinnerOn(4) while not HasModelLoaded(modelHash) do diff --git a/server-data/resources/[esx_addons]/esx_policejob/server/main.lua b/server-data/resources/[esx_addons]/esx_policejob/server/main.lua index 7545fc353..cb0ba2fad 100644 --- a/server-data/resources/[esx_addons]/esx_policejob/server/main.lua +++ b/server-data/resources/[esx_addons]/esx_policejob/server/main.lua @@ -1,166 +1,186 @@ if Config.EnableESXService then if Config.MaxInService ~= -1 then - TriggerEvent('esx_service:activateService', 'police', Config.MaxInService) + TriggerEvent("esx_service:activateService", "police", Config.MaxInService) end end -TriggerEvent('esx_phone:registerNumber', 'police', TranslateCap('alert_police'), true, true) -TriggerEvent('esx_society:registerSociety', 'police', TranslateCap('society_police'), 'society_police', 'society_police', 'society_police', {type = 'public'}) - -RegisterNetEvent('esx_policejob:confiscatePlayerItem') -AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount) +TriggerEvent("esx_phone:registerNumber", "police", TranslateCap("alert_police"), true, true) +TriggerEvent( + "esx_society:registerSociety", + "police", + TranslateCap("society_police"), + "society_police", + "society_police", + "society_police", + { type = "public" } +) + +RegisterNetEvent("esx_policejob:confiscatePlayerItem") +AddEventHandler("esx_policejob:confiscatePlayerItem", function(target, itemType, itemName, amount) local source = source local sourceXPlayer = ESX.GetPlayerFromId(source) local targetXPlayer = ESX.GetPlayerFromId(target) - if sourceXPlayer.job.name ~= 'police' then - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Exploit The Confuscation System!'):format(sourceXPlayer.source)) + if sourceXPlayer.job.name ~= "police" then + print( + ("[^3WARNING^7] Player ^5%s^7 Attempted To Exploit The Confuscation System!"):format(sourceXPlayer.source) + ) return end - if itemType == 'item_standard' then + if itemType == "item_standard" then local targetItem = targetXPlayer.getInventoryItem(itemName) local sourceItem = sourceXPlayer.getInventoryItem(itemName) -- does the target player have enough in their inventory? if targetItem.count > 0 and targetItem.count <= amount then - -- can the player carry the said amount of x item? if sourceXPlayer.canCarryItem(itemName, sourceItem.count) then targetXPlayer.removeInventoryItem(itemName, amount) - sourceXPlayer.addInventoryItem (itemName, amount) - sourceXPlayer.showNotification(TranslateCap('you_confiscated', amount, sourceItem.label, targetXPlayer.name)) - targetXPlayer.showNotification(TranslateCap('got_confiscated', amount, sourceItem.label, sourceXPlayer.name)) + sourceXPlayer.addInventoryItem(itemName, amount) + sourceXPlayer.showNotification( + TranslateCap("you_confiscated", amount, sourceItem.label, targetXPlayer.name) + ) + targetXPlayer.showNotification( + TranslateCap("got_confiscated", amount, sourceItem.label, sourceXPlayer.name) + ) else - sourceXPlayer.showNotification(TranslateCap('quantity_invalid')) + sourceXPlayer.showNotification(TranslateCap("quantity_invalid")) end else - sourceXPlayer.showNotification(TranslateCap('quantity_invalid')) + sourceXPlayer.showNotification(TranslateCap("quantity_invalid")) end - - elseif itemType == 'item_account' then + elseif itemType == "item_account" then local targetAccount = targetXPlayer.getAccount(itemName) -- does the target player have enough money? if targetAccount.money >= amount then targetXPlayer.removeAccountMoney(itemName, amount, "Confiscated") - sourceXPlayer.addAccountMoney (itemName, amount, "Confiscated") - - sourceXPlayer.showNotification(TranslateCap('you_confiscated_account', amount, itemName, targetXPlayer.name)) - targetXPlayer.showNotification(TranslateCap('got_confiscated_account', amount, itemName, sourceXPlayer.name)) + sourceXPlayer.addAccountMoney(itemName, amount, "Confiscated") + + sourceXPlayer.showNotification( + TranslateCap("you_confiscated_account", amount, itemName, targetXPlayer.name) + ) + targetXPlayer.showNotification( + TranslateCap("got_confiscated_account", amount, itemName, sourceXPlayer.name) + ) else - sourceXPlayer.showNotification(TranslateCap('quantity_invalid')) + sourceXPlayer.showNotification(TranslateCap("quantity_invalid")) + end + elseif itemType == "item_weapon" then + if amount == nil then + amount = 0 end - - elseif itemType == 'item_weapon' then - if amount == nil then amount = 0 end -- does the target player have weapon? if targetXPlayer.hasWeapon(itemName) then targetXPlayer.removeWeapon(itemName) - sourceXPlayer.addWeapon (itemName, amount) - - sourceXPlayer.showNotification(TranslateCap('you_confiscated_weapon', ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount)) - targetXPlayer.showNotification(TranslateCap('got_confiscated_weapon', ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name)) + sourceXPlayer.addWeapon(itemName, amount) + + sourceXPlayer.showNotification( + TranslateCap("you_confiscated_weapon", ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount) + ) + targetXPlayer.showNotification( + TranslateCap("got_confiscated_weapon", ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name) + ) else - sourceXPlayer.showNotification(TranslateCap('quantity_invalid')) + sourceXPlayer.showNotification(TranslateCap("quantity_invalid")) end end end) -RegisterNetEvent('esx_policejob:handcuff') -AddEventHandler('esx_policejob:handcuff', function(target) +RegisterNetEvent("esx_policejob:handcuff") +AddEventHandler("esx_policejob:handcuff", function(target) local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx_policejob:handcuff', target) + if xPlayer.job.name == "police" then + TriggerClientEvent("esx_policejob:handcuff", target) else - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Handcuffs!'):format(xPlayer.source)) + print(("[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Handcuffs!"):format(xPlayer.source)) end end) -RegisterNetEvent('esx_policejob:drag') -AddEventHandler('esx_policejob:drag', function(target) +RegisterNetEvent("esx_policejob:drag") +AddEventHandler("esx_policejob:drag", function(target) local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx_policejob:drag', target, source) + if xPlayer.job.name == "police" then + TriggerClientEvent("esx_policejob:drag", target, source) else - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Dragging!'):format(xPlayer.source)) + print(("[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Dragging!"):format(xPlayer.source)) end end) -RegisterNetEvent('esx_policejob:putInVehicle') -AddEventHandler('esx_policejob:putInVehicle', function(target) +RegisterNetEvent("esx_policejob:putInVehicle") +AddEventHandler("esx_policejob:putInVehicle", function(target) local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx_policejob:putInVehicle', target) + if xPlayer.job.name == "police" then + TriggerClientEvent("esx_policejob:putInVehicle", target) else - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Garage!'):format(xPlayer.source)) + print(("[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Garage!"):format(xPlayer.source)) end end) -RegisterNetEvent('esx_policejob:OutVehicle') -AddEventHandler('esx_policejob:OutVehicle', function(target) +RegisterNetEvent("esx_policejob:OutVehicle") +AddEventHandler("esx_policejob:OutVehicle", function(target) local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx_policejob:OutVehicle', target) + if xPlayer.job.name == "police" then + TriggerClientEvent("esx_policejob:OutVehicle", target) else - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Dragging Out Of Vehicle!'):format(xPlayer.source)) + print(("[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Dragging Out Of Vehicle!"):format(xPlayer.source)) end end) -RegisterNetEvent('esx_policejob:getStockItem') -AddEventHandler('esx_policejob:getStockItem', function(itemName, count) +RegisterNetEvent("esx_policejob:getStockItem") +AddEventHandler("esx_policejob:getStockItem", function(itemName, count) local source = source local xPlayer = ESX.GetPlayerFromId(source) - TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory) + TriggerEvent("esx_addoninventory:getSharedInventory", "society_police", function(inventory) local inventoryItem = inventory.getItem(itemName) -- is there enough in the society? if count > 0 and inventoryItem.count >= count then - -- can the player carry the said amount of x item? if xPlayer.canCarryItem(itemName, count) then inventory.removeItem(itemName, count) xPlayer.addInventoryItem(itemName, count) - xPlayer.showNotification(TranslateCap('have_withdrawn', count, inventoryItem.name)) + xPlayer.showNotification(TranslateCap("have_withdrawn", count, inventoryItem.name)) else - xPlayer.showNotification(TranslateCap('quantity_invalid')) + xPlayer.showNotification(TranslateCap("quantity_invalid")) end else - xPlayer.showNotification(TranslateCap('quantity_invalid')) + xPlayer.showNotification(TranslateCap("quantity_invalid")) end end) end) -RegisterNetEvent('esx_policejob:putStockItems') -AddEventHandler('esx_policejob:putStockItems', function(itemName, count) +RegisterNetEvent("esx_policejob:putStockItems") +AddEventHandler("esx_policejob:putStockItems", function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) local sourceItem = xPlayer.getInventoryItem(itemName) - TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory) + TriggerEvent("esx_addoninventory:getSharedInventory", "society_police", function(inventory) local inventoryItem = inventory.getItem(itemName) -- does the player have enough of the item? if sourceItem.count >= count and count > 0 then xPlayer.removeInventoryItem(itemName, count) inventory.addItem(itemName, count) - xPlayer.showNotification(TranslateCap('have_deposited', count, inventoryItem.name)) + xPlayer.showNotification(TranslateCap("have_deposited", count, inventoryItem.name)) else - xPlayer.showNotification(TranslateCap('quantity_invalid')) + xPlayer.showNotification(TranslateCap("quantity_invalid")) end end) end) -ESX.RegisterServerCallback('esx_policejob:getOtherPlayerData', function(source, cb, target, notify) +ESX.RegisterServerCallback("esx_policejob:getOtherPlayerData", function(source, cb, target, notify) local xPlayer = ESX.GetPlayerFromId(target) if notify then - xPlayer.showNotification(TranslateCap('being_searched')) + xPlayer.showNotification(TranslateCap("being_searched")) end if xPlayer then @@ -170,24 +190,28 @@ ESX.RegisterServerCallback('esx_policejob:getOtherPlayerData', function(source, grade = xPlayer.job.grade_label, inventory = xPlayer.getInventory(), accounts = xPlayer.getAccounts(), - weapons = xPlayer.getLoadout() + weapons = xPlayer.getLoadout(), } if Config.EnableESXIdentity then - data.dob = xPlayer.get('dateofbirth') - data.height = xPlayer.get('height') + data.dob = xPlayer.get("dateofbirth") + data.height = xPlayer.get("height") - if xPlayer.get('sex') == 'm' then data.sex = 'male' else data.sex = 'female' end + if xPlayer.get("sex") == "m" then + data.sex = "male" + else + data.sex = "female" + end end - TriggerEvent('esx_status:getStatus', target, 'drunk', function(status) + TriggerEvent("esx_status:getStatus", target, "drunk", function(status) if status then data.drunk = ESX.Math.Round(status.percent) end end) if Config.EnableLicenses then - TriggerEvent('esx_license:getLicenses', target, function(licenses) + TriggerEvent("esx_license:getLicenses", target, function(licenses) data.licenses = licenses cb(data) end) @@ -198,10 +222,9 @@ ESX.RegisterServerCallback('esx_policejob:getOtherPlayerData', function(source, end) local fineList = {} -ESX.RegisterServerCallback('esx_policejob:getFineList', function(source, cb, category) +ESX.RegisterServerCallback("esx_policejob:getFineList", function(source, cb, category) if not fineList[category] then - MySQL.query('SELECT * FROM fine_types WHERE category = ?', {category}, - function(fines) + MySQL.query("SELECT * FROM fine_types WHERE category = ?", { category }, function(fines) fineList[category] = fines cb(fines) @@ -211,22 +234,23 @@ ESX.RegisterServerCallback('esx_policejob:getFineList', function(source, cb, cat end end) - -ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb, plate) +ESX.RegisterServerCallback("esx_policejob:getVehicleInfos", function(source, cb, plate) local retrivedInfo = { - plate = plate + plate = plate, } if Config.EnableESXIdentity then - MySQL.single('SELECT users.firstname, users.lastname FROM owned_vehicles JOIN users ON owned_vehicles.owner = users.identifier WHERE plate = ?', {plate}, - function(result) - if result then - retrivedInfo.owner = ('%s %s'):format(result.firstname, result.lastname) + MySQL.single( + "SELECT users.firstname, users.lastname FROM owned_vehicles JOIN users ON owned_vehicles.owner = users.identifier WHERE plate = ?", + { plate }, + function(result) + if result then + retrivedInfo.owner = ("%s %s"):format(result.firstname, result.lastname) + end + cb(retrivedInfo) end - cb(retrivedInfo) - end) + ) else - MySQL.scalar('SELECT owner FROM owned_vehicles WHERE plate = ?', {plate}, - function(owner) + MySQL.scalar("SELECT owner FROM owned_vehicles WHERE plate = ?", { plate }, function(owner) if owner then local xPlayer = ESX.GetPlayerFromIdentifier(owner) if xPlayer then @@ -238,9 +262,9 @@ ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb, end end) -ESX.RegisterServerCallback('esx_policejob:getArmoryWeapons', function(source, cb) - TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store) - local weapons = store.get('weapons') +ESX.RegisterServerCallback("esx_policejob:getArmoryWeapons", function(source, cb) + TriggerEvent("esx_datastore:getSharedDataStore", "society_police", function(store) + local weapons = store.get("weapons") if weapons == nil then weapons = {} @@ -250,18 +274,18 @@ ESX.RegisterServerCallback('esx_policejob:getArmoryWeapons', function(source, cb end) end) -ESX.RegisterServerCallback('esx_policejob:addArmoryWeapon', function(source, cb, weaponName, removeWeapon) +ESX.RegisterServerCallback("esx_policejob:addArmoryWeapon", function(source, cb, weaponName, removeWeapon) local xPlayer = ESX.GetPlayerFromId(source) if removeWeapon then xPlayer.removeWeapon(weaponName) end - TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store) - local weapons = store.get('weapons') or {} + TriggerEvent("esx_datastore:getSharedDataStore", "society_police", function(store) + local weapons = store.get("weapons") or {} local foundWeapon = false - for i=1, #weapons, 1 do + for i = 1, #weapons, 1 do if weapons[i].name == weaponName then weapons[i].count = weapons[i].count + 1 foundWeapon = true @@ -271,26 +295,26 @@ ESX.RegisterServerCallback('esx_policejob:addArmoryWeapon', function(source, cb, if not foundWeapon then table.insert(weapons, { - name = weaponName, - count = 1 + name = weaponName, + count = 1, }) end - store.set('weapons', weapons) + store.set("weapons", weapons) cb() - end) + end) end) -ESX.RegisterServerCallback('esx_policejob:removeArmoryWeapon', function(source, cb, weaponName) +ESX.RegisterServerCallback("esx_policejob:removeArmoryWeapon", function(source, cb, weaponName) local xPlayer = ESX.GetPlayerFromId(source) xPlayer.addWeapon(weaponName, 500) - TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store) - local weapons = store.get('weapons') or {} + TriggerEvent("esx_datastore:getSharedDataStore", "society_police", function(store) + local weapons = store.get("weapons") or {} local foundWeapon = false - for i=1, #weapons, 1 do + for i = 1, #weapons, 1 do if weapons[i].name == weaponName then weapons[i].count = (weapons[i].count > 0 and weapons[i].count - 1 or 0) foundWeapon = true @@ -301,20 +325,20 @@ ESX.RegisterServerCallback('esx_policejob:removeArmoryWeapon', function(source, if not foundWeapon then table.insert(weapons, { name = weaponName, - count = 0 + count = 0, }) end - store.set('weapons', weapons) + store.set("weapons", weapons) cb() end) end) -ESX.RegisterServerCallback('esx_policejob:buyWeapon', function(source, cb, weaponName, type, componentNum) +ESX.RegisterServerCallback("esx_policejob:buyWeapon", function(source, cb, weaponName, type, componentNum) local xPlayer = ESX.GetPlayerFromId(source) local authorizedWeapons, selectedWeapon = Config.AuthorizedWeapons[xPlayer.job.grade_name] - for k,v in ipairs(authorizedWeapons) do + for _, v in ipairs(authorizedWeapons) do if v.weapon == weaponName then selectedWeapon = v break @@ -322,7 +346,7 @@ ESX.RegisterServerCallback('esx_policejob:buyWeapon', function(source, cb, weapo end if not selectedWeapon then - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Buy Invalid Weapon - ^5%s^7!'):format(source, weaponName)) + print(("[^3WARNING^7] Player ^5%s^7 Attempted To Buy Invalid Weapon - ^5%s^7!"):format(source, weaponName)) cb(false) else -- Weapon @@ -339,7 +363,7 @@ ESX.RegisterServerCallback('esx_policejob:buyWeapon', function(source, cb, weapo -- Weapon Component elseif type == 2 then local price = selectedWeapon.components[componentNum] - local weaponNum, weapon = ESX.GetWeapon(weaponName) + local _, weapon = ESX.GetWeapon(weaponName) local component = weapon.components[componentNum] if component then @@ -352,49 +376,68 @@ ESX.RegisterServerCallback('esx_policejob:buyWeapon', function(source, cb, weapo cb(false) end else - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Buy Invalid Weapon Component - ^5%s^7!'):format(source, componentNum)) + print( + ("[^3WARNING^7] Player ^5%s^7 Attempted To Buy Invalid Weapon Component - ^5%s^7!"):format( + source, + componentNum + ) + ) cb(false) end end end end) -ESX.RegisterServerCallback('esx_policejob:buyJobVehicle', function(source, cb, vehicleProps, type) +ESX.RegisterServerCallback("esx_policejob:buyJobVehicle", function(source, cb, vehicleProps, type) local xPlayer = ESX.GetPlayerFromId(source) local price = getPriceFromHash(vehicleProps.model, xPlayer.job.grade_name, type) -- vehicle model not found if price == 0 then - print(('[^3WARNING^7] Player ^5%s^7 Attempted To Buy Invalid Vehicle - ^5%s^7!'):format(source, vehicleProps.model)) + print( + ("[^3WARNING^7] Player ^5%s^7 Attempted To Buy Invalid Vehicle - ^5%s^7!"):format( + source, + vehicleProps.model + ) + ) cb(false) else if xPlayer.getMoney() >= price then xPlayer.removeMoney(price, "Job Vehicle Bought") - MySQL.insert('INSERT INTO owned_vehicles (owner, vehicle, plate, type, job, `stored`) VALUES (?, ?, ?, ?, ?, ?)', { xPlayer.identifier, json.encode(vehicleProps), vehicleProps.plate, type, xPlayer.job.name, true}, - function (rowsChanged) - cb(true) - end) + MySQL.insert( + "INSERT INTO owned_vehicles (owner, vehicle, plate, type, job, `stored`) VALUES (?, ?, ?, ?, ?, ?)", + { xPlayer.identifier, json.encode(vehicleProps), vehicleProps.plate, type, xPlayer.job.name, true }, + function(rowsChanged) + cb(true) + end + ) else cb(false) end end end) -ESX.RegisterServerCallback('esx_policejob:storeNearbyVehicle', function(source, cb, plates) +ESX.RegisterServerCallback("esx_policejob:storeNearbyVehicle", function(source, cb, plates) local xPlayer = ESX.GetPlayerFromId(source) - local plate = MySQL.scalar.await('SELECT plate FROM owned_vehicles WHERE owner = ? AND plate IN (?) AND job = ?', {xPlayer.identifier, plates, xPlayer.job.name}) + local plate = MySQL.scalar.await( + "SELECT plate FROM owned_vehicles WHERE owner = ? AND plate IN (?) AND job = ?", + { xPlayer.identifier, plates, xPlayer.job.name } + ) if plate then - MySQL.update('UPDATE owned_vehicles SET `stored` = true WHERE owner = ? AND plate = ? AND job = ?', {xPlayer.identifier, plate, xPlayer.job.name}, - function(rowsChanged) - if rowsChanged == 0 then - cb(false) - else - cb(plate) + MySQL.update( + "UPDATE owned_vehicles SET `stored` = true WHERE owner = ? AND plate = ? AND job = ?", + { xPlayer.identifier, plate, xPlayer.job.name }, + function(rowsChanged) + if rowsChanged == 0 then + cb(false) + else + cb(plate) + end end - end) + ) else cb(false) end @@ -413,60 +456,60 @@ function getPriceFromHash(vehicleHash, jobGrade, type) return 0 end -ESX.RegisterServerCallback('esx_policejob:getStockItems', function(source, cb) - TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory) +ESX.RegisterServerCallback("esx_policejob:getStockItems", function(source, cb) + TriggerEvent("esx_addoninventory:getSharedInventory", "society_police", function(inventory) cb(inventory.items) end) end) -ESX.RegisterServerCallback('esx_policejob:getPlayerInventory', function(source, cb) +ESX.RegisterServerCallback("esx_policejob:getPlayerInventory", function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) - local items = xPlayer.inventory + local items = xPlayer.inventory - cb({items = items}) + cb({ items = items }) end) -AddEventHandler('playerDropped', function() +AddEventHandler("playerDropped", function() local playerId = source if playerId then local xPlayer = ESX.GetPlayerFromId(playerId) - if xPlayer and xPlayer.job.name == 'police' then + if xPlayer and xPlayer.job.name == "police" then Wait(5000) - TriggerClientEvent('esx_policejob:updateBlip', -1) + TriggerClientEvent("esx_policejob:updateBlip", -1) end end end) -RegisterNetEvent('esx_policejob:spawned') -AddEventHandler('esx_policejob:spawned', function() +RegisterNetEvent("esx_policejob:spawned") +AddEventHandler("esx_policejob:spawned", function() local playerId = source local xPlayer = ESX.GetPlayerFromId(playerId) - if xPlayer and xPlayer.job.name == 'police' then + if xPlayer and xPlayer.job.name == "police" then Wait(5000) - TriggerClientEvent('esx_policejob:updateBlip', -1) + TriggerClientEvent("esx_policejob:updateBlip", -1) end end) -RegisterNetEvent('esx_policejob:forceBlip') -AddEventHandler('esx_policejob:forceBlip', function() - for _, xPlayer in pairs(ESX.GetExtendedPlayers('job', 'police')) do - TriggerClientEvent('esx_policejob:updateBlip', xPlayer.source) +RegisterNetEvent("esx_policejob:forceBlip") +AddEventHandler("esx_policejob:forceBlip", function() + for _, xPlayer in pairs(ESX.GetExtendedPlayers("job", "police")) do + TriggerClientEvent("esx_policejob:updateBlip", xPlayer.source) end end) -AddEventHandler('onResourceStart', function(resource) +AddEventHandler("onResourceStart", function(resource) if resource == GetCurrentResourceName() then Wait(5000) - for _, xPlayer in pairs(ESX.GetExtendedPlayers('job', 'police')) do - TriggerClientEvent('esx_policejob:updateBlip', xPlayer.source) + for _, xPlayer in pairs(ESX.GetExtendedPlayers("job", "police")) do + TriggerClientEvent("esx_policejob:updateBlip", xPlayer.source) end end end) -AddEventHandler('onResourceStop', function(resource) +AddEventHandler("onResourceStop", function(resource) if resource == GetCurrentResourceName() then - TriggerEvent('esx_phone:removeNumber', 'police') + TriggerEvent("esx_phone:removeNumber", "police") end end) diff --git a/server-data/resources/[phone]/esx-radio/client.lua b/server-data/resources/[phone]/esx-radio/client.lua index 0a71360f2..ba924db29 100644 --- a/server-data/resources/[phone]/esx-radio/client.lua +++ b/server-data/resources/[phone]/esx-radio/client.lua @@ -1,4 +1,4 @@ -local radioMenu, onRadio = false, false +local radioMenu, onRadio, radioProp = false, false, {} local RadioChannel = 0 local RadioVolume = 50 diff --git a/server-data/resources/[phone]/esx-radio/fxmanifest.lua b/server-data/resources/[phone]/esx-radio/fxmanifest.lua index 4ae9f7463..01d3b068e 100644 --- a/server-data/resources/[phone]/esx-radio/fxmanifest.lua +++ b/server-data/resources/[phone]/esx-radio/fxmanifest.lua @@ -2,7 +2,7 @@ fx_version("cerulean") game("gta5") description("Cool Radio for ESX, Coverted By Mycroft & Benzo") -version("1.0.0") +version("1.0.1") lua54("yes") shared_scripts({