diff --git a/client/job.lua b/client/job.lua index f0e25b5..9fdde78 100644 --- a/client/job.lua +++ b/client/job.lua @@ -21,7 +21,7 @@ local FingerPrintSessionId = nil function CreatePrompts() for k,v in pairs(Config.Locations['duty']) do - exports['qbr-core']:createPrompt('duty_prompt_' .. k, v, 0xF3830D8E, 'Toggle duty status', { + exports['qbr-core']:createPrompt('duty_prompt_' .. k, v, 0xF3830D8E, Lang:t('prompt.toggle_duty_status'), { type = 'client', event = 'qb-policejob:ToggleDuty', args = {}, @@ -29,7 +29,7 @@ function CreatePrompts() end for k,v in pairs(Config.Locations['evidence']) do - exports['qbr-core']:createPrompt('evidence_prompt_' .. k, v, 0xF3830D8E, 'Open Evidence Stash', { + exports['qbr-core']:createPrompt('evidence_prompt_' .. k, v, 0xF3830D8E, Lang:t('prompt.open_evidence_stash'), { type = 'client', event = 'police:client:EvidenceStashDrawer', args = { k }, @@ -37,7 +37,7 @@ function CreatePrompts() end for k,v in pairs(Config.Locations['stash']) do - exports['qbr-core']:createPrompt('stash_prompt_' .. k, v, 0xF3830D8E, 'Open Personal Stash', { + exports['qbr-core']:createPrompt('stash_prompt_' .. k, v, 0xF3830D8E, Lang:t('prompt.open_personal_stash'), { type = 'client', event = 'police:client:OpenPersonalStash', args = {}, @@ -45,7 +45,7 @@ function CreatePrompts() end for k,v in pairs(Config.Locations['armory']) do - exports['qbr-core']:createPrompt('armory_prompt_' .. k, v, 0xF3830D8E, 'Open Armory', { + exports['qbr-core']:createPrompt('armory_prompt_' .. k, v, 0xF3830D8E, Lang:t('prompt.open_armory'), { type = 'client', event = 'police:client:OpenArmory', args = {}, @@ -91,13 +91,18 @@ local function IsArmoryWhitelist() -- being removed end local function SetWeaponSeries() - for k, v in pairs(Config.Items.items) do + for k, v in ipairs(Config.Items.items) do if k < 6 then - Config.Items.items[k].info.serie = tostring(exports['qbr-core']:RandomInt(2) .. exports['qbr-core']:RandomStr(3) .. exports['qbr-core']:RandomInt(1) .. exports['qbr-core']:RandomStr(2) .. exports['qbr-core']:RandomInt(3) .. exports['qbr-core']:RandomStr(4)) + local randomInt = exports['qbr-core']:RandomInt + local randomStr = exports['qbr-core']:RandomStr + + local serie = tostring(randomInt(2) .. randomStr(3) .. randomInt(1) .. randomStr(2) .. randomInt(3) .. randomStr(4)) + Config.Items.items[k].info.serie = serie end end end + RegisterNetEvent('police:client:ImpoundVehicle', function(fullImpound, price) local vehicle = exports['qbr-core']:GetClosestVehicle() local bodyDamage = math.ceil(GetVehicleBodyHealth(vehicle)) @@ -181,20 +186,22 @@ RegisterNetEvent('police:client:OpenArmory', function() slots = 30, items = {} } - -- local index = 1 - for index, armoryItem in pairs(Config.Items.items) do - for i=1, #armoryItem.authorizedJobGrades do - if armoryItem.authorizedJobGrades[i] == PlayerJob.grade.level then - authorizedItems.items[index] = armoryItem - authorizedItems.items[index].slot = index - -- index = index + 1 + + for index, armoryItem in ipairs(Config.Items.items) do + for _, authorizedJobGrade in ipairs(armoryItem.authorizedJobGrades) do + if authorizedJobGrade == PlayerJob.grade.level then + armoryItem.slot = index + table.insert(authorizedItems.items, armoryItem) + break -- Exit the loop after finding a match end end end + SetWeaponSeries() TriggerServerEvent("inventory:server:OpenInventory", "shop", "police", authorizedItems) end) + -- Threads -- Toggle Duty diff --git a/client/main.lua b/client/main.lua index bfef93a..98c1c13 100644 --- a/client/main.lua +++ b/client/main.lua @@ -9,60 +9,62 @@ onDuty = false local DutyBlips = {} -- Functions -local function CreateDutyBlips(playerId, playerLabel, playerJob, playerLocation) +local function CreateDutyBlip(playerId, playerLabel, playerJob, playerLocation) local ped = GetPlayerPed(playerId) local blip = GetBlipFromEntity(ped) + if not DoesBlipExist(blip) then if NetworkIsPlayerActive(playerId) then blip = Citizen.InvokeNative(0x30822554, ped) else blip = Citizen.InvokeNative(0x554D9D53F696D002, 1664425300, playerLocation.x, playerLocation.y, playerLocation.z) end + SetBlipSprite(blip, 54149631, 1) SetBlipScale(blip, 0.7) Citizen.InvokeNative(0x9CB1A1623062F402, blip, playerLabel) - DutyBlips[#DutyBlips+1] = blip + + table.insert(DutyBlips, blip) end - if GetBlipFromEntity(PlayerPedId()) == blip then - -- Ensure we remove our own blip. + local playerBlip = GetBlipFromEntity(PlayerPedId()) + if playerBlip and playerBlip == blip then RemoveBlip(blip) end end function LocalInput(text, number, window) AddTextEntry('FMMC_MPM_NA', text) - DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "", windows or "", "", "", "", number or 30) + DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "", window or "", "", "", "", number or 30) - while (UpdateOnscreenKeyboard() == 0) do + while UpdateOnscreenKeyboard() == 0 do DisableAllControlActions(0) Wait(0) end - if (GetOnscreenKeyboardResult()) then - local result = GetOnscreenKeyboardResult() - return result + local result = nil + if GetOnscreenKeyboardResult() then + result = GetOnscreenKeyboardResult() end + + return result end + -- Events AddEventHandler('QBCore:Client:OnPlayerLoaded', function() local player = exports['qbr-core']:GetPlayerData() PlayerJob = player.job onDuty = player.job.onduty isHandcuffed = false + TriggerServerEvent("QBCore:Server:SetMetaData", "ishandcuffed", false) TriggerServerEvent("police:server:SetHandcuffStatus", false) TriggerServerEvent("police:server:UpdateBlips") TriggerServerEvent("police:server:UpdateCurrentCops") if PlayerJob and PlayerJob.name ~= "police" then - if DutyBlips then - for k, v in pairs(DutyBlips) do - RemoveBlip(v) - end - end - DutyBlips = {} + ClearDutyBlips() end if PlayerJob and PlayerJob.name == 'police' then @@ -70,6 +72,16 @@ AddEventHandler('QBCore:Client:OnPlayerLoaded', function() end end) +function ClearDutyBlips() + if DutyBlips then + for _, blip in pairs(DutyBlips) do + RemoveBlip(blip) + end + DutyBlips = {} + end +end + + RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() TriggerServerEvent('police:server:UpdateBlips') TriggerServerEvent("police:server:SetHandcuffStatus", false) @@ -136,7 +148,7 @@ RegisterNetEvent('police:client:UpdateBlips', function(players) if players then for k, data in pairs(players) do local id = GetPlayerFromServerId(data.source) - CreateDutyBlips(id, data.label, data.job, data.location) + CreateDutyBlip(id, data.label, data.job, data.location) end end end @@ -156,15 +168,14 @@ RegisterNetEvent('police:client:policeAlert', function(coords, text) Citizen.InvokeNative(0x662D364ABF16DE2F, blip2, GetHashKey('BLIP_MODIFIER_AREA_PULSE')) SetBlipScale(blip, 0.8) SetBlipScale(blip2, 2.0) - Citizen.InvokeNative(0x9CB1A1623062F402, blip, blipText) - while transG ~= 0 do + Citizen.InvokeNative(0x9CB1A1623062F402, blip, blipText) + while transG > 0 do Wait(180 * 4) transG = transG - 1 - if transG == 0 then - RemoveBlip(blip) - return - end end + + RemoveBlip(blip) + RemoveBlip(blip2) end) RegisterNetEvent('police:client:SendToJail', function(time) diff --git a/locales/en.lua b/locales/en.lua index e0d0548..e82ee3e 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -180,6 +180,12 @@ local Translations = { place_object = 'Placing object..', remove_object = 'Removing object..', }, + prompt = { + toggle_duty_status = 'Toggle duty status', + open_evidence_stash = 'Open Evidence Stash', + open_personal_stash = 'Open Personal Stash', + open_armory = 'Open Armory', + }, } Lang = Locale:new({ diff --git a/locales/es.lua b/locales/es.lua index 0bc3c3c..563971b 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -180,6 +180,12 @@ local Translations = { place_object = 'Colocando objeto..', remove_object = 'Eliminando objeto..', }, + prompt = { + toggle_duty_status = 'Alternar estado de servicio', + open_evidence_stash = 'Abrir inventario de pruebas', + open_personal_stash = 'Abrir inventario personal', + open_armory = 'Abrir Armería', + }, } if GetConvar('qbr_locale', 'en') == 'es' then