From 4f1b702ef5d20a0f4dc54296383a255fde03902d Mon Sep 17 00:00:00 2001 From: gononono64 Date: Wed, 24 May 2023 11:56:29 -0500 Subject: [PATCH 1/2] Evidence upload Got evidence working combined addevidence into single server event included forces changes --- client/evidence.lua | 433 ++++++++++++++++++++-------------------- client/interactions.lua | 2 +- client/job.lua | 2 +- client/objects.lua | 120 ----------- config.lua | 24 ++- locales/en.lua | 30 +-- server/main.lua | 294 +++++++++++++-------------- 7 files changed, 381 insertions(+), 524 deletions(-) diff --git a/client/evidence.lua b/client/evidence.lua index 27e7207..9fbbea2 100644 --- a/client/evidence.lua +++ b/client/evidence.lua @@ -1,27 +1,30 @@ -- Variables +Config = Config or {} + + local CurrentStatusList = {} -local Casings = {} -local CurrentCasing = nil -local Blooddrops = {} -local CurrentBlooddrop = nil -local Fingerprints = {} -local CurrentFingerprint = 0 +local Evidences = { + Casings = {}, + Blooddrops = {}, + Fingerprints = {} +} +local CurrentEvidences = nil local shotAmount = 0 local StatusList = { - ['fight'] = Lang:t('evidence.red_hands'), - ['widepupils'] = Lang:t('evidence.wide_pupils'), - ['redeyes'] = Lang:t('evidence.red_eyes'), - ['weedsmell'] = Lang:t('evidence.weed_smell'), - ['gunpowder'] = Lang:t('evidence.gunpowder'), - ['chemicals'] = Lang:t('evidence.chemicals'), - ['heavybreath'] = Lang:t('evidence.heavy_breathing'), - ['sweat'] = Lang:t('evidence.sweat'), - ['handbleed'] = Lang:t('evidence.handbleed'), - ['confused'] = Lang:t('evidence.confused'), - ['alcohol'] = Lang:t('evidence.alcohol'), - ["heavyalcohol"] = Lang:t('evidence.heavy_alcohol'), - ["agitated"] = Lang:t('evidence.agitated') + ["fight"] = Lang:t("evidence.red_hands"), + ["widepupils"] = Lang:t("evidence.wide_pupils"), + ["redeyes"] = Lang:t("evidence.red_eyes"), + ["weedsmell"] = Lang:t("evidence.weed_smell"), + ["gunpowder"] = Lang:t("evidence.gunpowder"), + ["chemicals"] = Lang:t("evidence.chemicals"), + ["heavybreath"] = Lang:t("evidence.heavy_breathing"), + ["sweat"] = Lang:t("evidence.sweat"), + ["handbleed"] = Lang:t("evidence.handbleed"), + ["confused"] = Lang:t("evidence.confused"), + ["alcohol"] = Lang:t("evidence.alcohol"), + ["heavyalcohol"] = Lang:t("evidence.heavy_alcohol"), + ["agitated"] = Lang:t("evidence.agitated") } local WhitelistedWeapons = { @@ -33,19 +36,28 @@ local WhitelistedWeapons = { 0x126210c3, } + +function VarString(txt) + + return +end + +function BgDisplayText(txt, x, y) + return Citizen.InvokeNative(0xd79334a4bb99bad1, Citizen.InvokeNative(0xFA925AC00EB830B9, 10, "LITERAL_STRING", txt, Citizen.ResultAsLong()), x, y) +end -- Functions local function DrawText3D(x, y, z, text) coords = vector3(x, y, z) - local onScreen, x, y = GetScreenCoordFromWorldCoord(coords.x, coords.y, coords.z) - - if (onScreen) then - SetTextScale(0.35, 0.35) - SetTextColor(255, 255, 255, 215) - SetTextFontForCurrentCommand(4) - SetTextDropshadow(0, 0, 0, 255) - SetTextCentre(true) - DisplayText(CreateVarString(10, 'LITERAL_STRING', text), x, y) - end + local onScreen, x, y = GetScreenCoordFromWorldCoord(coords.x, coords.y, coords.z) + if onScreen then + SetTextScale(0.35, 0.35) + SetTextColor(255, 255, 255, 215) + --SetTextFontForCurrentCommand(4) + SetTextDropshadow(0, 0, 0, 255) + --SetTextCentre(true) + + BgDisplayText(text, x * 1.0, y * 1.0) + end end local function WhitelistedWeapon(weapon) @@ -62,19 +74,13 @@ local function DropBulletCasing(weapon, ped) local randX = math.random() + math.random(-1, 1) local randY = math.random() + math.random(-1, 1) local coords = GetOffsetFromEntityInWorldCoords(ped, randX, randY, 0) - TriggerServerEvent('evidence:server:CreateCasing', weapon, coords) + local coords2 = vector3(coords.x, coords.y, coords.z - 0.9) + TriggerServerEvent("evidence:server:CreateCasing", weapon, coords) Wait(300) end -local function DnaHash(s) - local h = string.gsub(s, '.', function(c) - return string.format('%02x', string.byte(c)) - end) - return h -end - -- Events -RegisterNetEvent('evidence:client:SetStatus', function(statusId, time) +RegisterNetEvent("evidence:client:SetStatus", function(statusId, time) if time > 0 and StatusList[statusId] then if (CurrentStatusList == nil or CurrentStatusList[statusId] == nil) or (CurrentStatusList[statusId] and CurrentStatusList[statusId].time < 20) then @@ -82,251 +88,242 @@ RegisterNetEvent('evidence:client:SetStatus', function(statusId, time) text = StatusList[statusId], time = time } - exports['qbr-core']:Notify(9, CurrentStatusList[statusId].text, 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') + exports["qbr-core"]:Notify(9, CurrentStatusList[statusId].text, 5000, 0, "mp_lobby_textures", "cross", "COLOR_WHITE") end elseif StatusList[statusId] then CurrentStatusList[statusId] = nil end - TriggerServerEvent('evidence:server:UpdateStatus', CurrentStatusList) -end) - -RegisterNetEvent('evidence:client:AddBlooddrop', function(bloodId, citizenid, bloodtype, coords) - Blooddrops[bloodId] = { - citizenid = citizenid, - bloodtype = bloodtype, - coords = { - x = coords.x, - y = coords.y, - z = coords.z - 0.9 - } - } + TriggerServerEvent("evidence:server:UpdateStatus", CurrentStatusList) end) -RegisterNetEvent('evidence:client:RemoveBlooddrop', function(bloodId) - Blooddrops[bloodId] = nil - CurrentBlooddrop = 0 -end) +RegisterNetEvent("evidence:client:AddEvidence", function(data) + assert(data, "[Client] [QBR-PoliceJob-evidence:client:AddEvidence] Missing data") + assert(data.coords, "[Client] [QBR-PoliceJob-evidence:client:AddEvidence] Missing coords") + local categoryId = data.categoryId + assert(categoryId, "[Client] [QBR-PoliceJob-evidence:client:AddEvidence] Missing categoryId") + local id = data.id + assert(id, "[Client] [QBR-PoliceJob-evidence:client:AddEvidence] Missing id") -RegisterNetEvent('evidence:client:AddFingerPrint', function(fingerId, fingerprint, coords) - Fingerprints[fingerId] = { - fingerprint = fingerprint, - coords = { - x = coords.x, - y = coords.y, - z = coords.z - 0.9 - } - } + if not Evidences[categoryId] then Evidences[categoryId] = {} end + Evidences[categoryId][id] = data end) -RegisterNetEvent('evidence:client:RemoveFingerprint', function(fingerId) - Fingerprints[fingerId] = nil - CurrentFingerprint = 0 +RegisterNetEvent("evidence:client:RemoveEvidence", function(evidenceCategory, evidenceId ) + if Evidences[evidenceCategory] then + Evidences[evidenceCategory][evidenceId] = nil + end + + if CurrentEvidences[evidenceCategory] then + CurrentEvidences[evidenceCategory][evidenceId] = nil + end end) -RegisterNetEvent('evidence:client:ClearBlooddropsInArea', function() +RegisterNetEvent("evidence:client:ClearBlooddropsInArea", function() local pos = GetEntityCoords(PlayerPedId()) local blooddropList = {} - exports['qbr-core']:Progressbar('clear_blooddrops', Lang:t("progressbar.blood_clear"), 5000, false, true, { + exports["qbr-core"]:Progressbar("clear_blooddrops", Lang:t("progressbar.blood_clear"), 5000, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = true }, {}, {}, {}, function() -- Done - if Blooddrops and next(Blooddrops) then - for bloodId, v in pairs(Blooddrops) do - if #(pos - - vector3(Blooddrops[bloodId].coords.x, Blooddrops[bloodId].coords.y, Blooddrops[bloodId].coords.z)) < - 10.0 then + if Evidences.Blooddrops and next(Evidences.Blooddrops) then + for bloodId, v in pairs(Evidences.Blooddrops) do + if #(pos - vector3(Evidences.Blooddrops[bloodId].coords.x, Evidences.Blooddrops[bloodId].coords.y, Evidences.Blooddrops[bloodId].coords.z)) < 10.0 then blooddropList[#blooddropList+1] = bloodId end end - TriggerServerEvent('evidence:server:ClearBlooddrops', blooddropList) - exports['qbr-core']:Notify(9, Lang:t("success.blood_clear"), 5000, 0, 'hud_textures', 'check', 'COLOR_WHITE') + TriggerServerEvent("evidence:server:ClearBlooddrops", blooddropList) + exports["qbr-core"]:Notify(9, Lang:t("success.blood_clear"), 5000, 0, "hud_textures", "check", "COLOR_WHITE") end end, function() -- Cancel - exports['qbr-core']:Notify(9, Lang:t("error.blood_not_cleared"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') + exports["qbr-core"]:Notify(9, Lang:t("error.blood_not_cleared"), 5000, 0, "mp_lobby_textures", "cross", "COLOR_WHITE") end) end) -RegisterNetEvent('evidence:client:AddCasing', function(casingId, weapon, coords, serie) - Casings[casingId] = { - type = weapon, - serie = serie and serie or Lang:t('evidence.serial_not_visible'), - coords = { - x = coords.x, - y = coords.y, - z = coords.z - 0.9 - } - } -end) - -RegisterNetEvent('evidence:client:RemoveCasing', function(casingId) - Casings[casingId] = nil - CurrentCasing = 0 -end) - -RegisterNetEvent('evidence:client:ClearCasingsInArea', function() +RegisterNetEvent("evidence:client:ClearCasingsInArea", function() local pos = GetEntityCoords(PlayerPedId()) local casingList = {} - exports['qbr-core']:Progressbar('clear_casings', Lang:t("progressbar.bullet_casing"), 5000, false, true, { + exports["qbr-core"]:Progressbar("clear_casings", Lang:t("progressbar.bullet_casing"), 5000, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = true }, {}, {}, {}, function() -- Done - if Casings and next(Casings) then - for casingId, v in pairs(Casings) do - if #(pos - vector3(Casings[casingId].coords.x, Casings[casingId].coords.y, Casings[casingId].coords.z)) < + if Evidences.Casings and next(Evidences.Casings) then + for casingId, v in pairs(Evidences.Casings) do + if #(pos - vector3(Evidences.Casings[casingId].coords.x, Evidences.Casings[casingId].coords.y, Evidences.Casings[casingId].coords.z)) < 10.0 then casingList[#casingList+1] = casingId end end - TriggerServerEvent('evidence:server:ClearCasings', casingList) - exports['qbr-core']:Notify(9, Lang:t("success.bullet_casing_removed"), 5000, 0, 'hud_textures', 'check', 'COLOR_WHITE') + TriggerServerEvent("evidence:server:ClearCasings", casingList) + exports["qbr-core"]:Notify(9, Lang:t("success.bullet_casing_removed"), 5000, 0, "hud_textures", "check", "COLOR_WHITE") end end, function() -- Cancel - exports['qbr-core']:Notify(9, Lang:t("error.bullet_casing_not_removed"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') + exports["qbr-core"]:Notify(9, Lang:t("error.bullet_casing_not_removed"), 5000, 0, "mp_lobby_textures", "cross", "COLOR_WHITE") end) end) -- Threads +local isPickingUp = false +local isChecking = false +local shouldRunEvidences = false +local shouldRunStatus = false -CreateThread(function() - while true do - Wait(10000) - if LocalPlayer.state.isLoggedIn then - if CurrentStatusList and next(CurrentStatusList) then - for k, v in pairs(CurrentStatusList) do - if CurrentStatusList[k].time > 0 then - CurrentStatusList[k].time = CurrentStatusList[k].time - 10 - else - CurrentStatusList[k].time = 0 - end - end - TriggerServerEvent('evidence:server:UpdateStatus', CurrentStatusList) - end - if shotAmount > 0 then - shotAmount = 0 +function NextToEvidence(evidence, categoryId, id) + if not evidence then return end + local pos = GetEntityCoords(PlayerPedId()) + local coords = vector3(evidence.coords.x, evidence.coords.y, evidence.coords.z) + if #(pos - coords ) > Config.EvidenceRange then return end + + local drawtext = evidence.drawtext + if not drawtext then return end + DrawText3D(coords.x, coords.y, coords.z, drawtext) + + if not IsControlJustReleased(0, 0x5415BE48) then return end + if isPickingUp then return end + isPickingUp = true + TriggerServerEvent("evidence:server:AddEvidenceToInventory", categoryId, id, evidence) + CreateThread(function() + Wait(1000) + isPickingUp = false + end) +end + +function DistanceCheckForEvidence() + CreateThread(function() + while isChecking do + Wait(1) + for categoryId, evidences in pairs(CurrentEvidences or {}) do + for id, evidence in pairs(evidences) do + NextToEvidence(evidence, categoryId, id) + end end end - end -end) + end) +end + +function GetPedCurrentHeldWeapon(ped) + return Citizen.InvokeNative(0x8425C5F057012DAB, ped) +end -CreateThread(function() -- Gunpowder Status when shooting - while true do - Wait(1) - local ped = PlayerPedId() - if IsPedShooting(ped) then - local weapon = Citizen.InvokeNative(0x8425C5F057012DAB, ped) - if not WhitelistedWeapon(weapon) then - shotAmount = shotAmount + 1 - if shotAmount > 5 and (CurrentStatusList == nil or CurrentStatusList['gunpowder'] == nil) then - if math.random(1, 10) <= 7 then - TriggerEvent('evidence:client:SetStatus', 'gunpowder', 200) +function UpdateCurrentEvidences() + for index, evidence in pairs(Evidences) do + if next(evidence) then + local pos = GetEntityCoords(PlayerPedId(), true) + for id, data in pairs(evidence) do + local dist = #(pos - vector3(data.coords.x, data.coords.y, data.coords.z)) + if dist < Config.EvidenceRange then + if not CurrentEvidences then + CurrentEvidences = {} end + if not CurrentEvidences[index] then + CurrentEvidences[index] = {} + end + CurrentEvidences[index][id] = data + elseif CurrentEvidences and CurrentEvidences[index] and CurrentEvidences[index][id] then + CurrentEvidences[index][id] = nil end - DropBulletCasing(weapon, ped) end end end -end) +end -CreateThread(function() - while true do - Wait(1) - if CurrentCasing and CurrentCasing ~= 0 then - local pos = GetEntityCoords(PlayerPedId()) - if #(pos -vector3(Casings[CurrentCasing].coords.x, Casings[CurrentCasing].coords.y, Casings[CurrentCasing].coords.z)) < 1.5 then - local weaponHash = Casings[CurrentCasing].type - DrawText3D(Casings[CurrentCasing].coords.x, Casings[CurrentCasing].coords.y, Casings[CurrentCasing].coords.z, Lang:t('info.bullet_casing', {value = Config.WeaponHashes[Casings[CurrentCasing].type].weaponAmmoLabel})) - if IsControlJustReleased(0, 0x5415BE48) then - local info = { - label = Lang:t('info.casing'), - type = 'casing', - ammolabel = Config.WeaponHashes[Casings[CurrentCasing].type].weaponAmmoLabel, - ammotype = Config.WeaponHashes[Casings[CurrentCasing].type].weaponAmmo, - serie = Casings[CurrentCasing].serie - } - TriggerServerEvent('evidence:server:AddCasingToInventory', CurrentCasing, info) - end +function SetupEvidencesLoops() + --Loop for checking closest evidence for types. + CreateThread(function() + while shouldRunEvidences do + Wait(10) + if GetPedCurrentHeldWeapon(PlayerPedId()) == `WEAPON_MELEE_LANTERN` then + UpdateCurrentEvidences() + if not isChecking then + isChecking = true + DistanceCheckForEvidence() + end + elseif isChecking then + isChecking = false end end + end) +end - if CurrentBlooddrop and CurrentBlooddrop ~= 0 then - local pos = GetEntityCoords(PlayerPedId()) - if #(pos - vector3(Blooddrops[CurrentBlooddrop].coords.x, Blooddrops[CurrentBlooddrop].coords.y, - Blooddrops[CurrentBlooddrop].coords.z)) < 1.5 then - DrawText3D(Blooddrops[CurrentBlooddrop].coords.x, Blooddrops[CurrentBlooddrop].coords.y, Blooddrops[CurrentBlooddrop].coords.z, Lang:t('blood_text', {value = DnaHash(Blooddrops[CurrentBlooddrop].citizenid)})) - if IsControlJustReleased(0, 0x5415BE48) then - local info = { - label = Lang:t('info.blood'), - type = 'blood', - dnalabel = DnaHash(Blooddrops[CurrentBlooddrop].citizenid), - bloodtype = Blooddrops[CurrentBlooddrop].bloodtype - } - TriggerServerEvent('evidence:server:AddBlooddropToInventory', CurrentBlooddrop, info) +function StartStatusLoop() + CreateThread(function() -- Player Status Thread + while shouldRunStatus do + Wait(10000) + if LocalPlayer.state.isLoggedIn then + if CurrentStatusList and next(CurrentStatusList) then + for k, v in pairs(CurrentStatusList) do + if CurrentStatusList[k].time > 0 then + CurrentStatusList[k].time = CurrentStatusList[k].time - 10 + else + CurrentStatusList[k].time = 0 + end + end + TriggerServerEvent("evidence:server:UpdateStatus", CurrentStatusList) end - end - end - - if CurrentFingerprint and CurrentFingerprint ~= 0 then - local pos = GetEntityCoords(PlayerPedId()) - if #(pos - vector3(Fingerprints[CurrentFingerprint].coords.x, Fingerprints[CurrentFingerprint].coords.y, - Fingerprints[CurrentFingerprint].coords.z)) < 1.5 then - DrawText3D(Fingerprints[CurrentFingerprint].coords.x, Fingerprints[CurrentFingerprint].coords.y, Fingerprints[CurrentFingerprint].coords.z, Lang:t('info.fingerprint_text')) - if IsControlJustReleased(0, 0x5415BE48) then - local info = { - label = Lang:t('info.fingerprint'), - type = 'fingerprint', - fingerprint = Fingerprints[CurrentFingerprint].fingerprint - } - TriggerServerEvent('evidence:server:AddFingerprintToInventory', CurrentFingerprint, info) + if shotAmount > 0 then + shotAmount = 0 end end end - end -end) + end) +end -CreateThread(function() - while true do - Wait(10) - if LocalPlayer.state.isLoggedIn then - if PlayerJob.name == 'police' and onDuty then - if Citizen.InvokeNative(0x8425C5F057012DAB, PlayerPedId()) == -164645981 then - if next(Casings) then - local pos = GetEntityCoords(PlayerPedId(), true) - for k, v in pairs(Casings) do - local dist = #(pos - vector3(v.coords.x, v.coords.y, v.coords.z)) - if dist < 1.5 then - CurrentCasing = k - end - end - end - if next(Blooddrops) then - local pos = GetEntityCoords(PlayerPedId(), true) - for k, v in pairs(Blooddrops) do - local dist = #(pos - vector3(v.coords.x, v.coords.y, v.coords.z)) - if dist < 1.5 then - CurrentBlooddrop = k - end - end - end - if next(Fingerprints) then - local pos = GetEntityCoords(PlayerPedId(), true) - for k, v in pairs(Fingerprints) do - local dist = #(pos - vector3(v.coords.x, v.coords.y, v.coords.z)) - if dist < 1.5 then - CurrentFingerprint = k - end + +function StartGunpowderLoop() + CreateThread(function() -- Gunpowder Status when shooting + while shouldRunStatus do + Wait(1) + local ped = PlayerPedId() + + if IsPedShooting(ped) then + local weapon = GetPedCurrentHeldWeapon(ped) + if not WhitelistedWeapon(weapon) then + shotAmount = shotAmount + 1 + if shotAmount > 5 and (CurrentStatusList == nil or CurrentStatusList["gunpowder"] == nil) then + if math.random(1, 10) <= 7 then + TriggerEvent("evidence:client:SetStatus", "gunpowder", 200) end end - else - Wait(1000) + DropBulletCasing(weapon, ped) end - else - Wait(5000) end end + end) +end + +RegisterNetEvent("QBCore:Client:OnPlayerUnloaded", function() + shouldRunStatus = false +end) + +RegisterNetEvent('QBCore:Player:SetPlayerData', function(playerData) + print("Job Update") + PlayerJob = playerData.job + local name = PlayerJob.name + local onduty = PlayerJob.onduty + + if not shouldRunStatus then + shouldRunStatus = true + StartGunpowderLoop() + StartStatusLoop() + end + + if Config.EvidenceJobs[name] and onduty then + if shouldRunEvidences then return end + shouldRunEvidences = true + SetupEvidencesLoops() -- Check if + else + shouldRunEvidences = false end -end) \ No newline at end of file +end) + +-- RegisterCommand("ammo", function(source, args, rawCommand) +-- local ped = PlayerPedId() + +-- local _, weapon = GetCurrentPedWeapon(ped) +-- print(source,ped, weapon) +-- SetPedInfiniteAmmo(ped, true, weapon) +-- end, false) \ No newline at end of file diff --git a/client/interactions.lua b/client/interactions.lua index 3834f53..1c26ff7 100644 --- a/client/interactions.lua +++ b/client/interactions.lua @@ -327,7 +327,7 @@ RegisterNetEvent('police:client:GetCuffed', function(playerId, isSoftcuff) TriggerServerEvent("police:server:SetHandcuffStatus", true) ClearPedTasksImmediately(ped) if Citizen.InvokeNative(0x8425C5F057012DAB,ped) ~= GetHashKey("WEAPON_UNARMED") then - SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true) + SetCurrentPedWeapon(ped, "WEAPON_UNARMED", true) end if not isSoftcuff then cuffType = 16 diff --git a/client/job.lua b/client/job.lua index 61035a2..56b906e 100644 --- a/client/job.lua +++ b/client/job.lua @@ -56,7 +56,7 @@ end local function loadAnimDict(dict) -- interactions, job, while (not HasAnimDictLoaded(dict)) do RequestAnimDict(dict) - Citizen.Wait(10) + Wait(10) end end diff --git a/client/objects.lua b/client/objects.lua index 9dcf558..73f4303 100644 --- a/client/objects.lua +++ b/client/objects.lua @@ -1,8 +1,5 @@ -- Variables local ObjectList = {} -local SpawnedSpikes = {} -local spikemodel = `P_ld_stinger_s` -local ClosestSpike = nil -- Functions local function GetClosestPoliceObject() @@ -25,23 +22,6 @@ local function GetClosestPoliceObject() return current, dist end -function GetClosestSpike() - local pos = GetEntityCoords(PlayerPedId(), true) - local current = nil - - for id, data in pairs(SpawnedSpikes) do - if current then - if #(pos - vector3(SpawnedSpikes[id].coords.x, SpawnedSpikes[id].coords.y, SpawnedSpikes[id].coords.z)) < dist then - current = id - end - else - dist = #(pos - vector3(SpawnedSpikes[id].coords.x, SpawnedSpikes[id].coords.y, SpawnedSpikes[id].coords.z)) - current = id - end - end - ClosestSpike = current -end - local function DrawText3D(x, y, z, text) SetTextScale(0.35, 0.35) SetTextFont(4) @@ -195,104 +175,4 @@ RegisterNetEvent('police:client:spawnObject', function(objectId, type, player) object = spawnedObj, coords = vector3(x, y, z - 0.3), } -end) - -RegisterNetEvent('police:client:SpawnSpikeStrip', function() - if #SpawnedSpikes + 1 < Config.MaxSpikes then - if PlayerJob.name == "police" and PlayerJob.onduty then - local spawnCoords = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 2.0, 0.0) - local spike = CreateObject(spikemodel, spawnCoords.x, spawnCoords.y, spawnCoords.z, 1, 1, 1) - local netid = NetworkGetNetworkIdFromEntity(spike) - SetNetworkIdExistsOnAllMachines(netid, true) - SetNetworkIdCanMigrate(netid, false) - SetEntityHeading(spike, GetEntityHeading(PlayerPedId())) - PlaceObjectOnGroundProperly(spike) - SpawnedSpikes[#SpawnedSpikes+1] = { - coords = vector3(spawnCoords.x, spawnCoords.y, spawnCoords.z), - netid = netid, - object = spike, - } - TriggerServerEvent('police:server:SyncSpikes', SpawnedSpikes) - end - else - exports['qbr-core']:Notify(9, Lang:t("error.no_spikestripe"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') - end -end) - -RegisterNetEvent('police:client:SyncSpikes', function(table) - SpawnedSpikes = table -end) - --- Threads -CreateThread(function() - while true do - if LocalPlayer.state.isLoggedIn then - GetClosestSpike() - end - Wait(500) - end -end) - -CreateThread(function() - while true do - if LocalPlayer.state.isLoggedIn then - if ClosestSpike then - local tires = { - {bone = "wheel_lf", index = 0}, - {bone = "wheel_rf", index = 1}, - {bone = "wheel_lm", index = 2}, - {bone = "wheel_rm", index = 3}, - {bone = "wheel_lr", index = 4}, - {bone = "wheel_rr", index = 5} - } - - for a = 1, #tires do - local vehicle = GetVehiclePedIsIn(PlayerPedId(), false) - local tirePos = GetWorldPositionOfEntityBone(vehicle, GetEntityBoneIndexByName(vehicle, tires[a].bone)) - local spike = GetClosestObjectOfType(tirePos.x, tirePos.y, tirePos.z, 15.0, spikemodel, 1, 1, 1) - local spikePos = GetEntityCoords(spike, false) - local distance = #(tirePos - spikePos) - - if distance < 1.8 then - if not IsVehicleTyreBurst(vehicle, tires[a].index, true) or IsVehicleTyreBurst(vehicle, tires[a].index, false) then - SetVehicleTyreBurst(vehicle, tires[a].index, false, 1000.0) - end - end - end - end - end - - Wait(3) - end -end) - -CreateThread(function() - while true do - local sleep = 1000 - if LocalPlayer.state.isLoggedIn then - if ClosestSpike then - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local dist = #(pos - SpawnedSpikes[ClosestSpike].coords) - if dist < 4 then - if not IsPedInAnyVehicle(PlayerPedId()) then - if PlayerJob.name == "police" and PlayerJob.onduty then - sleep = 0 - DrawText3D(pos.x, pos.y, pos.z, Lang:t('info.delete_spike')) - if IsControlJustPressed(0, 38) then - NetworkRegisterEntityAsNetworked(SpawnedSpikes[ClosestSpike].object) - NetworkRequestControlOfEntity(SpawnedSpikes[ClosestSpike].object) - SetEntityAsMissionEntity(SpawnedSpikes[ClosestSpike].object) - DeleteEntity(SpawnedSpikes[ClosestSpike].object) - SpawnedSpikes[ClosestSpike] = nil - ClosestSpike = nil - TriggerServerEvent('police:server:SyncSpikes', SpawnedSpikes) - end - end - end - end - end - end - Wait(sleep) - end end) \ No newline at end of file diff --git a/config.lua b/config.lua index 4eaeb71..be46da2 100644 --- a/config.lua +++ b/config.lua @@ -2,16 +2,20 @@ Config = {} Config.ShowBlips = true +Config.EvidenceJobs = {police = true} +Config.BlipsJobs = {police = true, ambulance = true} +Config.Law = {police = true, sheriff = true} + +Config.EvidenceRange = 2.5 + Config.Objects = { - ["cone"] = {model = `prop_roadcone02a`, freeze = false}, - ["barrier"] = {model = `prop_barrier_work06a`, freeze = true}, - ["roadsign"] = {model = `prop_snow_sign_road_06g`, freeze = true}, - ["tent"] = {model = `prop_gazebo_03`, freeze = true}, - ["light"] = {model = `prop_worklight_03b`, freeze = true}, + ["cone"] = {model = "prop_roadcone02a", freeze = false}, + ["barrier"] = {model = "prop_barrier_work06a", freeze = true}, + ["roadsign"] = {model = "prop_snow_sign_road_06g", freeze = true}, + ["tent"] = {model = "prop_gazebo_03", freeze = true}, + ["light"] = {model = "prop_worklight_03b", freeze = true}, } -Config.MaxSpikes = 5 - Config.HandCuffItem = 'handcuffs' Config.LicenseRank = 2 @@ -33,14 +37,14 @@ Config.Locations = { ["armory"] = { [1] = vector3(1361.16, -1305.7, 77.76), [2] = vector3(2494.53, -1304.32, 48.95), - [3] = vector3(-764.86, -1272.4, 44.04), - [4] = vector3(-1814.01, -354.93, 164.65), + [3] = vector3(-764.86, -1272.43, 44.04), + [4] = vector3(-1813.93, -354.78, 164.65), }, ["evidence"] = { [1] = vector3(1361.39, -1303.77, 77.77), [2] = vector3(2494.44, -1313.39, 48.95), [3] = vector3(-761.98, -1272.62, 44.05), - [4] = vector3(-1812.43, -355.87, 164.65) + [4] = vector3(-1807.17, -348.29, 164.66) }, ["stations"] = { [1] = {label = "Sheriff", coords = vector3(1360.88, -1301.53, 77.77)}, diff --git a/locales/en.lua b/locales/en.lua index a880313..e0d0548 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -84,29 +84,29 @@ local Translations = { evidence_stash = 'Evidence Stash | %{value}', slot = 'Slot no. (1,2,3)', current_evidence = '%{value} | Drawer %{value2}', - on_duty = '[~g~E~s~] - Go on duty', - off_duty = '[~r~E~s~] - Go off duty', - onoff_duty = '~g~On~s~/~r~Off~s~ Duty', + on_duty = '[~COLOR_YELLOWSTRONG~E~q~] - Go on duty', + off_duty = '[~COLOR_YELLOWSTRONG~E~q~] - Go off duty', + onoff_duty = '~COLOR_YELLOWSTRONG~On~q~/~COLOR_YELLOWSTRONG~Off~q~ Duty', stash = 'Stash %{value}', - delete_spike = '[~r~E~s~] Delete Spike Strip', + delete_spike = '[~COLOR_YELLOWSTRONG~E~q~] Delete Spike Strip', close_camera = 'Close Camera', - bullet_casing = '[~g~G~s~] Bullet Casing %{value}', + bullet_casing = '[~COLOR_YELLOWSTRONG~G~q~] Bullet Casing %{value}', casing = 'Bullet Casing', blood = 'Blood', - blood_text = '[~g~G~s~] Blood %{value}', - fingerprint_text = '[~g~G~s~] Fingerprint', + blood_text = '[~COLOR_YELLOWSTRONG~G~q~] ~COLOR_RED~Blood %{value}', + fingerprint_text = '[~COLOR_YELLOWSTRONG~G~q~] Fingerprint', fingerprint = 'Fingerprint', - store_heli = '[~g~E~s~] Store Helicopter', - take_heli = '[~g~E~s~] Take Helicopter', - impound_veh = '[~g~E~s~] - Impound Vehicle', - store_veh = '[~g~E~s~] - Store Vehicle', + store_heli = '[~COLOR_YELLOWSTRONG~E~q~] Store Helicopter', + take_heli = '[~COLOR_YELLOWSTRONG~E~q~] Take Helicopter', + impound_veh = '[~COLOR_YELLOWSTRONG~E~q~] - Impound Vehicle', + store_veh = '[~COLOR_YELLOWSTRONG~E~q~] - Store Vehicle', armory = 'Armory', - enter_armory = '[~g~E~s~] Armory', + enter_armory = '[~COLOR_YELLOWSTRONG~E~q~] Armory', finger_scan = 'Fingerprint Scanning', - scan_fingerprint = '[~g~E~s~] Scan Fingerprint', + scan_fingerprint = '[~COLOR_YELLOWSTRONG~E~q~] Scan Fingerprint', trash = 'Trash', - trash_enter = '[~g~E~s~] Trash Bin', - stash_enter = '[~g~E~s~] Enter Locker', + trash_enter = '[~COLOR_YELLOWSTRONG~E~q~] Trash Bin', + stash_enter = '[~COLOR_YELLOWSTRONG~E~q~] Enter Locker', target_location = 'The location of %{firstname} %{lastname} is marked on your map', anklet_location = 'Anklet location', new_call = 'New Call', diff --git a/server/main.lua b/server/main.lua index e1f7921..3d86793 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,9 +1,7 @@ -- Variables local Plates = {} local PlayerStatus = {} -local Casings = {} -local BloodDrops = {} -local FingerDrops = {} +local Evidences ={} local Objects = {} local sharedItems = exports['qbr-core']:GetItems() @@ -12,7 +10,7 @@ local function UpdateBlips() local dutyPlayers = {} local players = exports['qbr-core']:GetQBPlayers() for k, v in pairs(players) do - if (v.PlayerData.job.name == "police" or v.PlayerData.job.name == "ambulance") and v.PlayerData.job.onduty then + if (Config.BlipsJobs[v.PlayerData.job.name]) and v.PlayerData.job.onduty then local coords = GetEntityCoords(GetPlayerPed(v.PlayerData.source)) local heading = GetEntityHeading(GetPlayerPed(v.PlayerData.source)) dutyPlayers[#dutyPlayers+1] = { @@ -31,56 +29,20 @@ local function UpdateBlips() TriggerClientEvent("police:client:UpdateBlips", -1, dutyPlayers) end -local function CreateBloodId() - if BloodDrops then - local bloodId = math.random(10000, 99999) - while BloodDrops[bloodId] do - bloodId = math.random(10000, 99999) - end - return bloodId - else - local bloodId = math.random(10000, 99999) - return bloodId - end -end - -local function CreateFingerId() - if FingerDrops then - local fingerId = math.random(10000, 99999) - while FingerDrops[fingerId] do - fingerId = math.random(10000, 99999) - end - return fingerId - else - local fingerId = math.random(10000, 99999) - return fingerId - end -end -local function CreateCasingId() - if Casings then - local caseId = math.random(10000, 99999) - while Casings[caseId] do - caseId = math.random(10000, 99999) - end - return caseId - else - local caseId = math.random(10000, 99999) - return caseId +local function CreateUniqueId(_table) + local id = math.random(10000, 99999) + while _table[id] do + id = math.random(10000, 99999) end + return id end -local function CreateObjectId() - if Objects then - local objectId = math.random(10000, 99999) - while Objects[objectId] do - objectId = math.random(10000, 99999) - end - return objectId - else - local objectId = math.random(10000, 99999) - return objectId - end +local function DnaHash(s) + local h = string.gsub(s, '.', function(c) + return string.format('%02x', string.byte(c)) + end) + return h end local function IsVehicleOwned(plate) @@ -92,7 +54,7 @@ local function GetCurrentCops() local amount = 0 local players = exports['qbr-core']:GetQBPlayers() for k, v in pairs(players) do - if v.PlayerData.job.name == "police" and v.PlayerData.job.onduty then + if Config.Law[v.PlayerData.job.name] and v.PlayerData.job.onduty then amount = amount + 1 end end @@ -218,25 +180,25 @@ exports['qbr-core']:AddCommand("sc", Lang:t("commands.softcuff"), {}, false, fun end end) -exports['qbr-core']:AddCommand("takedna", Lang:t("commands.takedna"), {{name = "id", help = Lang:t('info.player_id')}}, true, function(source, args) - local src = source - local Player = exports['qbr-core']:GetPlayer(src) - local OtherPlayer = exports['qbr-core']:GetPlayer(tonumber(args[1])) - if ((Player.PlayerData.job.name == "police") and Player.PlayerData.job.onduty) and OtherPlayer then - if Player.Functions.RemoveItem("satchel", 1) then - local info = { - label = Lang:t('info.dna_sample'), - type = "dna", - dnalabel = DnaHash(OtherPlayer.PlayerData.citizenid) - } - if Player.Functions.AddItem("evidence_satchel", 1, false, info) then - TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add") - end - else - TriggerClientEvent('QBCore:Notify', src, 9, Lang:t("error.have_evidence_bag"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') - end - end -end) +-- exports['qbr-core']:AddCommand("takedna", Lang:t("commands.takedna"), {{name = "id", help = Lang:t('info.player_id')}}, true, function(source, args) +-- local src = source +-- local Player = exports['qbr-core']:GetPlayer(src) +-- local OtherPlayer = exports['qbr-core']:GetPlayer(tonumber(args[1])) +-- if ((Player.PlayerData.job.name == "police") and Player.PlayerData.job.onduty) and OtherPlayer then +-- if Player.Functions.RemoveItem("satchel", 1) then +-- local info = { +-- label = Lang:t('info.dna_sample'), +-- ["_type"] = "dna", +-- dnalabel = DnaHash(OtherPlayer.PlayerData.citizenid) +-- } +-- if Player.Functions.AddItem("evidence_satchel", 1, false, info) then +-- TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add") +-- end +-- else +-- TriggerClientEvent('QBCore:Notify', src, 9, Lang:t("error.have_evidence_bag"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') +-- end +-- end +-- end) -- Items exports['qbr-core']:CreateUseableItem("handcuffs", function(source, item) @@ -264,18 +226,15 @@ end) exports['qbr-core']:CreateUseableItem("evidence_satchel", function(source, item) local src = source local Player = exports['qbr-core']:GetPlayer(src) + if Player.Functions.GetItemByName(item.name) then - if item.info and item.info ~= "" then - if item.info.type == 'dna' then - TriggerClientEvent('chat:addMessage', src, item.info.label .. ' | ' .. item.info.dnalabel) - elseif item.info.type == 'casing' then - TriggerClientEvent('chat:addMessage', src, item.info.label .. ' | ' .. item.info.serie .. ' - ' .. item.info.ammolabel) - elseif item.info.type == 'blood' then - TriggerClientEvent('chat:addMessage', src, item.info.label .. ' | ' .. item.info.dnalabel .. ' (' .. item.info.bloodtype .. ')') - elseif item.info.type == 'fingerprint' then - TriggerClientEvent('chat:addMessage', src, item.info.label .. ' | ' .. item.info.fingerprint) - end - print(json.encode(item.info)) + print("HERDABASDB",json.encode(item.info)) + if item.info and item.info ~= "" then + local revealtext = item.info.revealtext + if not revealtext then return end + print("Hitting",item.info.revealtext) + --3 4 + TriggerClientEvent('QBCore:Notify', src, 4 , revealtext, 2000, 0, 'hud_textures', 'check') end end end) @@ -303,7 +262,7 @@ exports['qbr-core']:CreateCallback('police:GetDutyPlayers', function(source, cb) local dutyPlayers = {} local players = exports['qbr-core']:GetQBPlayers() for k, v in pairs(players) do - if v.PlayerData.job.name == "police" and v.PlayerData.job.onduty then + if Config.Law[v.PlayerData.job.name] and v.PlayerData.job.onduty then dutyPlayers[#dutyPlayers+1] = { source = Player.PlayerData.source, label = Player.PlayerData.metadata["callsign"], @@ -318,7 +277,7 @@ exports['qbr-core']:CreateCallback('police:GetCops', function(source, cb) local amount = 0 local players = exports['qbr-core']:GetQBPlayers() for k, v in pairs(players) do - if v.PlayerData.job.name == "police" and v.PlayerData.job.onduty then + if Config.Law[v.PlayerData.job.name] and v.PlayerData.job.onduty then amount = amount + 1 end end @@ -329,7 +288,7 @@ exports['qbr-core']:CreateCallback('police:server:IsPoliceForcePresent', functio local retval = false local players = exports['qbr-core']:GetQBPlayers() for k, v in pairs(players) do - if v.PlayerData.job.name == "police" and v.PlayerData.job.grade.level >= 2 then + if Config.Law[v.PlayerData.job.name] and v.PlayerData.job.grade.level >= 2 then retval = true break end @@ -352,7 +311,7 @@ RegisterNetEvent('police:server:policeAlert', function(text) local coords = GetEntityCoords(ped) local players = exports['qbr-core']:GetQBPlayers() for k,v in pairs(players) do - if v.PlayerData.job.name == 'police' and v.PlayerData.job.onduty then + if Config.Law[v.PlayerData.job.name] and v.PlayerData.job.onduty then local alertData = {title = Lang:t('info.new_call'), coords = {coords.x, coords.y, coords.z}, description = text} TriggerClientEvent("qb-phone:client:addPoliceAlert", v.PlayerData.source, alertData) TriggerClientEvent('police:client:policeAlert', v.PlayerData.source, coords, text) @@ -507,11 +466,11 @@ RegisterNetEvent('police:server:UpdateBlips', function() -- KEEP FOR REF BUT NOT NEEDED ANYMORE. end) -RegisterNetEvent('police:server:spawnObject', function(type) +RegisterNetEvent('police:server:spawnObject', function(_type) local src = source - local objectId = CreateObjectId() - Objects[objectId] = type - TriggerClientEvent("police:client:spawnObject", src, objectId, type, src) + local objectId = CreateUniqueId(Objects) + Objects[objectId] = _type + TriggerClientEvent("police:client:spawnObject", src, objectId, _type, src) end) RegisterNetEvent('police:server:deleteObject', function(objectId) @@ -523,111 +482,115 @@ RegisterNetEvent('evidence:server:UpdateStatus', function(data) PlayerStatus[src] = data end) +RegisterNetEvent('evidence:server:AddEvidence', function(categoryId, coords, drawtext, revealtext) + assert(categoryId, "[Server] [QBR-PoliceJob-evidence:server:AddEvidence] Missing categoryId") + if not Evidences[categoryId] then Evidences[categoryId] = {} end + + local id = CreateUniqueId(Evidences[categoryId]) + local data, serverdata = {}, {} + data.categoryId, serverdata.categoryId = categoryId, categoryId + data.id, serverdata.id = id, id + data.coords, serverdata.coords = coords, coords + data.drawtext, serverdata.drawtext = drawtext, drawtext + serverdata.revealtext = revealtext + Evidences[categoryId][id] = serverdata + TriggerClientEvent("evidence:client:AddEvidence", -1, data) +end) + + +RegisterNetEvent('evidence:server:CreateCasing', function(weaponHash, coords) + local src = source + local Player = exports['qbr-core']:GetPlayer(src) + local sharedWeapons = exports['qbr-core']:GetWeapons() + local weaponInfo = sharedWeapons[weaponHash] + local serieNumber = nil + if weaponInfo then + local weaponItem = Player.Functions.GetItemByName(weaponInfo["name"]) + if weaponItem and weaponItem.info and weaponItem.info ~= "" then + serieNumber = weaponItem.info.serie + end + end + if not serieNumber then serieNumber = Lang:t("evidence.serial_not_visible") end + local weapConfig = Config.WeaponHashes[weaponHash] + local value = "Unknown" + if weapConfig then value = weapConfig.weaponAmmoLabel end + + local drawtext = Lang:t("info.bullet_casing", {value = value}) + local revealtext = Lang:t("info.casing") .. ' | ' .. serieNumber .. ' - ' .. value + + TriggerEvent('evidence:server:AddEvidence', 'Casings', coords, drawtext, revealtext) +end) + RegisterNetEvent('evidence:server:CreateBloodDrop', function(citizenid, bloodtype, coords) - local bloodId = CreateBloodId() - BloodDrops[bloodId] = { - dna = citizenid, - bloodtype = bloodtype - } - TriggerClientEvent("evidence:client:AddBlooddrop", -1, bloodId, citizenid, bloodtype, coords) + + local label = Lang:t("info.blood") + local dnalabel = DnaHash(citizenid) + local bloodtype = bloodtype + local drawtext = Lang:t("info.blood_text", {value = dnalabel}) + local revealtext = label .. ' | ' .. dnalabel .. ' (' .. bloodtype .. ')' + + TriggerEvent('evidence:server:AddEvidence', 'BloodDrops', coords, drawtext, revealtext) end) RegisterNetEvent('evidence:server:CreateFingerDrop', function(coords) local src = source - local Player = exports['qbr-core']:GetPlayer(src) - local fingerId = CreateFingerId() - FingerDrops[fingerId] = Player.PlayerData.metadata["fingerprint"] - TriggerClientEvent("evidence:client:AddFingerPrint", -1, fingerId, Player.PlayerData.metadata["fingerprint"], coords) + local Player = exports['qbr-core']:GetPlayer(src) + + local lable = Lang:t("info.fingerprint") + local fingerprint = Player.PlayerData.metadata["fingerprint"] + local revealtext = lable .. ' | ' .. fingerprint + local drawtext = Lang:t("fingerprint_text") + + TriggerEvent('evidence:server:AddEvidence', 'FingerDrops', coords, drawtext, revealtext) +end) + +RegisterNetEvent('evidence:server:ClearCasings', function(casingList) + if casingList and next(casingList) then + for k, v in pairs(casingList) do + TriggerClientEvent("evidence:client:RemoveCasing", -1, v) + Evidences.Casings[v] = nil + end + end end) RegisterNetEvent('evidence:server:ClearBlooddrops', function(blooddropList) if blooddropList and next(blooddropList) then for k, v in pairs(blooddropList) do TriggerClientEvent("evidence:client:RemoveBlooddrop", -1, v) - BloodDrops[v] = nil + Evidences.BloodDrops[v] = nil end end end) -RegisterNetEvent('evidence:server:AddBlooddropToInventory', function(bloodId, bloodInfo) +RegisterNetEvent('evidence:server:AddEvidenceToInventory', function(category, id, info) local src = source local Player = exports['qbr-core']:GetPlayer(src) - if Player.Functions.RemoveItem("satchel", 1) then - if Player.Functions.AddItem("evidence_satchel", 1, false, bloodInfo) then - TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add") - TriggerClientEvent("evidence:client:RemoveBlooddrop", -1, bloodId) - BloodDrops[bloodId] = nil - end - else - TriggerClientEvent('QBCore:Notify', src, 9, Lang:t("error.have_evidence_bag"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') - end -end) + local evidences = Evidences[category] + if not evidences then return end + local evidence = evidences[id] + if not evidence then return end -RegisterNetEvent('evidence:server:AddFingerprintToInventory', function(fingerId, fingerInfo) - local src = source - local Player = exports['qbr-core']:GetPlayer(src) if Player.Functions.RemoveItem("satchel", 1) then - if Player.Functions.AddItem("evidence_satchel", 1, false, fingerInfo) then - TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add") - TriggerClientEvent("evidence:client:RemoveFingerprint", -1, fingerId) - FingerDrops[fingerId] = nil + if Player.Functions.AddItem("evidence_satchel", 1, false, evidence) then + TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add") + TriggerClientEvent("evidence:client:RemoveEvidence", -1, category, id) end else TriggerClientEvent('QBCore:Notify', src, 9, Lang:t("error.have_evidence_bag"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') end end) -RegisterNetEvent('evidence:server:CreateCasing', function(weapon, coords) - local src = source - local Player = exports['qbr-core']:GetPlayer(src) - local casingId = CreateCasingId() - local sharedWeapons = exports['qbr-core']:GetWeapons() - local weaponInfo = sharedWeapons[weapon] - local serieNumber = nil - if weaponInfo then - local weaponItem = Player.Functions.GetItemByName(weaponInfo["name"]) - if weaponItem then - if weaponItem.info and weaponItem.info ~= "" then - serieNumber = weaponItem.info.serie - end - end - end - TriggerClientEvent("evidence:client:AddCasing", -1, casingId, weapon, coords, serieNumber) -end) - RegisterNetEvent('police:server:UpdateCurrentCops', function() local amount = 0 local players = exports['qbr-core']:GetQBPlayers() for k, v in pairs(players) do - if v.PlayerData.job.name == "police" and v.PlayerData.job.onduty then + if Config.Law[v.PlayerData.job.name] and v.PlayerData.job.onduty then amount = amount + 1 end end TriggerClientEvent("police:SetCopCount", -1, amount) end) -RegisterNetEvent('evidence:server:ClearCasings', function(casingList) - if casingList and next(casingList) then - for k, v in pairs(casingList) do - TriggerClientEvent("evidence:client:RemoveCasing", -1, v) - Casings[v] = nil - end - end -end) - -RegisterNetEvent('evidence:server:AddCasingToInventory', function(casingId, casingInfo) - local src = source - local Player = exports['qbr-core']:GetPlayer(src) - if Player.Functions.RemoveItem("satchel", 1) then - if Player.Functions.AddItem("evidence_satchel", 1, false, casingInfo) then - TriggerClientEvent("inventory:client:ItemBox", src, sharedItems["evidence_satchel"], "add") - TriggerClientEvent("evidence:client:RemoveCasing", -1, casingId) - Casings[casingId] = nil - end - else - TriggerClientEvent('QBCore:Notify', src, 9, Lang:t("error.have_evidence_bag"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE') - end -end) RegisterNetEvent('police:server:showFingerprint', function(playerId) local src = source @@ -643,6 +606,18 @@ RegisterNetEvent('police:server:showFingerprintId', function(sessionId) TriggerClientEvent('police:client:showFingerprintId', src, fid) end) +-- Hooks + +RegisterNetEvent('hospital:server:SyncInjuries', function(data) + local src = source + BodyParts = data.limbs + if not BodyParts then return end + local playerData = exports['qbr-core']:GetPlayer(src).PlayerData + if not playerData then return end + local coords = GetEntityCoords(GetPlayerPed(src)) + TriggerEvent("evidence:server:CreateBloodDrop", playerData.citizenid, playerData.metadata["bloodtype"], coords) +end) + -- Threads CreateThread(function() while true do @@ -658,3 +633,4 @@ CreateThread(function() UpdateBlips() end end) + From 386e5b88ee19e57d000ae4028eb7bf7671d904d3 Mon Sep 17 00:00:00 2001 From: gononono64 Date: Thu, 25 May 2023 05:57:25 -0500 Subject: [PATCH 2/2] Updated so not to need changes to ambulance job right away Updated so not to need changes to ambulance job right away --- server/main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/main.lua b/server/main.lua index 3d86793..2fc2246 100644 --- a/server/main.lua +++ b/server/main.lua @@ -521,15 +521,15 @@ RegisterNetEvent('evidence:server:CreateCasing', function(weaponHash, coords) TriggerEvent('evidence:server:AddEvidence', 'Casings', coords, drawtext, revealtext) end) -RegisterNetEvent('evidence:server:CreateBloodDrop', function(citizenid, bloodtype, coords) +RegisterNetEvent('evidence:server:CreateBloodDrop', function(citizenid, bloodtype, coords) --this all could be moved into the ambulance job local label = Lang:t("info.blood") local dnalabel = DnaHash(citizenid) local bloodtype = bloodtype local drawtext = Lang:t("info.blood_text", {value = dnalabel}) local revealtext = label .. ' | ' .. dnalabel .. ' (' .. bloodtype .. ')' - - TriggerEvent('evidence:server:AddEvidence', 'BloodDrops', coords, drawtext, revealtext) + local crds = vector3(coords.x, coords.y, coords.z - 0.9) + TriggerEvent('evidence:server:AddEvidence', 'BloodDrops', crds, drawtext, revealtext) end) RegisterNetEvent('evidence:server:CreateFingerDrop', function(coords)