diff --git a/resources/[inventory]/cs_shops/config/config.lua b/resources/[inventory]/cs_shops/config/config.lua index cd58b52b4..bded64345 100644 --- a/resources/[inventory]/cs_shops/config/config.lua +++ b/resources/[inventory]/cs_shops/config/config.lua @@ -1311,8 +1311,18 @@ CodeStudio.Products = { itemPrice = 50, itemInfo = "", }, - - + ['Bodycam'] = { + itemName = "Bodycam", + itemStock = 150, + itemPrice = 50, + itemInfo = "", + }, + ['Dashcam'] = { + itemName = "Dashcam", + itemStock = 150, + itemPrice = 50, + itemInfo = "", + }, } diff --git a/resources/[inventory]/cs_shops/ui/image/bodycam.png b/resources/[inventory]/cs_shops/ui/image/bodycam.png new file mode 100644 index 000000000..3cbd45566 Binary files /dev/null and b/resources/[inventory]/cs_shops/ui/image/bodycam.png differ diff --git a/resources/[inventory]/cs_shops/ui/image/dashcam.png b/resources/[inventory]/cs_shops/ui/image/dashcam.png new file mode 100644 index 000000000..6457a6949 Binary files /dev/null and b/resources/[inventory]/cs_shops/ui/image/dashcam.png differ diff --git a/resources/[inventory]/inventory_images/images/bodycam.png b/resources/[inventory]/inventory_images/images/bodycam.png new file mode 100644 index 000000000..3cbd45566 Binary files /dev/null and b/resources/[inventory]/inventory_images/images/bodycam.png differ diff --git a/resources/[inventory]/inventory_images/images/dashcam.png b/resources/[inventory]/inventory_images/images/dashcam.png new file mode 100644 index 000000000..6457a6949 Binary files /dev/null and b/resources/[inventory]/inventory_images/images/dashcam.png differ diff --git a/resources/[inventory]/tgiann-inventory/items/items.lua b/resources/[inventory]/tgiann-inventory/items/items.lua index e752b096f..307492aa9 100644 --- a/resources/[inventory]/tgiann-inventory/items/items.lua +++ b/resources/[inventory]/tgiann-inventory/items/items.lua @@ -10401,5 +10401,28 @@ itemsData = { image = 'kq_winch.png', name = 'kq_winch', }, + bodycam = { + shouldClose = true, + type = 'item', + description = '', + weight = 500, + label = 'Bodycam', + unique = true, + useable = true, + image = 'bodycam.png', + name = 'bodycam', + }, + dashcam = { + shouldClose = true, + type = 'item', + description = '', + weight = 500, + label = 'Dashcam', + unique = true, + useable = true, + image = 'dashcam.png', + name = 'dashcam', + }, + } diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/client/client.lua b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/client/client.lua new file mode 100644 index 000000000..4104bbc54 --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/client/client.lua @@ -0,0 +1,1223 @@ +PlayerJob = nil +local bodycam = nil +local targetPed = nil +local targetPedId = nil +local goBackCoords = nil +local PlyInCam = false +local PlyInSelfCam = false +local PlyInCarCam = false +local bcamstate = false +local carCam = false +local onRec = false + +-- for prop and ped +local propNetID = nil +local pedProps = {} +local charPed = {} + +--------Resource Start +AddEventHandler('onResourceStart', function(resourceName) + if (GetCurrentResourceName() ~= resourceName) then return end + PlayerJob = GetPlayerDataCore().job +end) +AddEventHandler('onResourceStop', function(resourceName) + if GetCurrentResourceName() == resourceName then + if propNetID and DoesEntityExist(NetworkGetEntityFromNetworkId(propNetID)) then + local propEntity = NetworkGetEntityFromNetworkId(propNetID) + DeleteEntity(propEntity) + propNetID = nil + end + if PlyInCam or PlyInCarCam then + ForceQuitBodyCam() + end + if PlyInSelfCam then + ForceQuitBodyCamSelf() + end + for k,v in pairs(pedProps)do + if v and DoesEntityExist(v) then + DeleteEntity(v) + end + end + for k,v in pairs(charPed)do + if v then + if DoesEntityExist(v) then + DeleteEntity(v) + end + end + end + end +end) + +if Config.Framework == 'qb' then + ---------PlayerLoaded + RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() + PlayerJob = GetPlayerDataCore().job + end) + + ---------Job Update + RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) + PlayerJob = JobInfo + end) +else + -- PlayerLoaded + RegisterNetEvent('esx:playerLoaded') + AddEventHandler('esx:playerLoaded',function(xPlayer, isNew, skin) + PlayerJob = xPlayer.job + end) + + -- Job Update + RegisterNetEvent('esx:setJob') + AddEventHandler('esx:setJob', function(JobInfo) + PlayerJob = JobInfo + end) +end + +RegisterNetEvent('spy-bodycam:startWatchingDashcam',function(netId) + local targetCoords = lib.callback.await('spy-bodycam:servercb:getCarCoords', false, netId) + if not targetCoords then + NotifyPlayer('Car not found!', 'error', 2500) + SetTimeout(3000, function() + OpenWatch(false) + end) + return + end + targetPedId = netId + LocalPlayer.state:set("inv_busy", true, true) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', false) + DoScreenFadeOut(1000) + while not IsScreenFadedOut() do + Wait(100) + end + FreezeEntityPosition(cache.ped, true) + SetEntityVisible(cache.ped, false) -- Set invisible + SetEntityCollision(cache.ped, false, false) -- Set collision + SetEntityInvincible(cache.ped, true) -- Set invincible + NetworkSetEntityInvisibleToNetwork(cache.ped, true) -- Set invisibility + SetEntityCoords(cache.ped, targetCoords.x, targetCoords.y, targetCoords.z - 100.0) + if Config.Framework == 'qb' then + TriggerServerEvent('spy-bodycam:server:ReqDecoyPed',GetPlayerDataCore().citizenid,goBackCoords) + elseif Config.Framework == 'esx' then + TriggerServerEvent('spy-bodycam:server:ReqDecoyPed',GetPlayerDataCore().identifier,goBackCoords) + end + Wait(500) + bodycam = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true) + targetPed = NetworkGetEntityFromNetworkId(netId) + if DoesEntityExist(targetPed) then + local boneIndex = GetEntityBoneIndexByName(vehicle, "windscreen") + local vehOffset = Config.VehCamOffset[GetEntityModel(targetPed)] + if vehOffset then + AttachCamToVehicleBone(bodycam, targetPed, boneIndex, true, 0.0, 0.0, 0.0, vehOffset[1], vehOffset[2], vehOffset[3], true) + else + AttachCamToVehicleBone(bodycam, targetPed, boneIndex, true, 0.0, 0.0, 0.0, 0.000000, 0.350000, 0.790000, true) + end + end + SetCamFov(bodycam,80.0) + PlyInCarCam = true + RenderScriptCams(true, false, 0, 1, 0) + SetTimecycleModifier(Config.CameraEffect.dashcam) + SetTimecycleModifierStrength(1.0) + DoScreenFadeIn(1000) + Citizen.CreateThread(function() + SetPlayerNearTarget() + end) + if Config.DebugCamera then + Citizen.CreateThread(function() + local offsetX, offsetY, offsetZ = 0.000000, 0.350000, 0.790000 + while PlyInCarCam do + Citizen.Wait(0) + DisableAllControlActions(0) + if IsDisabledControlJustReleased(0, 35) then -- A + offsetX = offsetX + 0.01 + end + if IsDisabledControlJustReleased(0, 34) then -- D + offsetX = offsetX - 0.01 + end + if IsDisabledControlJustReleased(0, 44) then -- Q + offsetY = offsetY + 0.01 + end + if IsDisabledControlJustReleased(0, 38) then -- E + offsetY = offsetY - 0.01 + end + if IsDisabledControlJustReleased(0, 32) then -- W + offsetZ = offsetZ + 0.01 + end + if IsDisabledControlJustReleased(0, 33) then -- S + offsetZ = offsetZ - 0.01 + end + AttachCamToVehicleBone(bodycam, targetPed, boneIndex, true, 0.0, 0.0, 0.0, offsetX, offsetY, offsetZ, true) + end + print(string.format("[`putspawncode`] = {%f, %f, %f},", offsetX, offsetY, offsetZ)) + end) + end +end) + +RegisterNetEvent('spy-bodycam:startWatching',function(targetId) + local ownId = GetPlayerServerId(PlayerId()) + if targetId == ownId then return TriggerEvent('spy-bodycam:startSelfWatching',targetId) end + local targetCoords = lib.callback.await('spy-bodycam:servercb:getPedCoords', false, targetId) + if not targetCoords then return NotifyPlayer('Player not found!', 'error', 2500) end + targetPedId = targetId + LocalPlayer.state:set("inv_busy", true, true) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', false) + DoScreenFadeOut(1000) + while not IsScreenFadedOut() do + Wait(100) + end + FreezeEntityPosition(cache.ped, true) + SetEntityVisible(cache.ped, false) -- Set invisible + SetEntityCollision(cache.ped, false, false) -- Set collision + SetEntityInvincible(cache.ped, true) -- Set invincible + NetworkSetEntityInvisibleToNetwork(cache.ped, true) -- Set invisibility + SetEntityCoords(cache.ped, targetCoords.x, targetCoords.y, targetCoords.z - 100.0) + if Config.Framework == 'qb' then + TriggerServerEvent('spy-bodycam:server:ReqDecoyPed',GetPlayerDataCore().citizenid,goBackCoords) + elseif Config.Framework == 'esx' then + TriggerServerEvent('spy-bodycam:server:ReqDecoyPed',GetPlayerDataCore().identifier,goBackCoords) + end + Wait(500) + local targetPlayer = GetPlayerFromServerId(targetId) + targetPed = GetPlayerPed(targetPlayer) + bodycam = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true) + AttachCamToPedBone(bodycam, targetPed, 46240, 0.1, 0.025, 0.1, true) + SetCamFov(bodycam, 100.0) + pedHeading = GetEntityHeading(targetPed) + PlyInCam = true + SetCamRot(bodycam, 0, 0, pedHeading, 2) + RenderScriptCams(true, false, 0, 1, 0) + ShakeCam(bodycam, "HAND_SHAKE", 1.0) + SetCamShakeAmplitude(bodycam, 2.0) + SetTimecycleModifier(Config.CameraEffect.bodycam) + SetTimecycleModifierStrength(0.5) + DoScreenFadeIn(1000) + Citizen.CreateThread(function() + SetPlayerNearTarget() + end) + Citizen.CreateThread(function() + SetCamRotation() + end) + Citizen.CreateThread(function() + SetCarCam() + end) +end) + +RegisterNetEvent('spy-bodycam:startSelfWatching',function(targetId) + targetPed = cache.ped + targetPedId = targetId + LocalPlayer.state:set("inv_busy", true, true) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', false) + DoScreenFadeOut(1000) + while not IsScreenFadedOut() do + Wait(100) + end + PlayWatchAnim(cache.ped,true) + FreezeEntityPosition(targetPed, true) + Wait(500) + bodycam = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true) + AttachCamToPedBone(bodycam, targetPed, 46240, 0.1, 0.025, 0.1, true) + SetCamFov(bodycam, 100.0) + pedHeading = GetEntityHeading(targetPed) + PlyInSelfCam = true + SetCamRot(bodycam, 0, 0, pedHeading, 2) + RenderScriptCams(true, false, 0, 1, 0) + ShakeCam(bodycam, "HAND_SHAKE", 1.0) + SetCamShakeAmplitude(bodycam, 2.0) + SetTimecycleModifier(Config.CameraEffect.bodycam) + SetTimecycleModifierStrength(0.5) + DoScreenFadeIn(1000) +end) + +RegisterNetEvent('spy-bodycam:bodycamstatus',function() + local isJobUse = CheckAllowedJob() + if not isJobUse then return NotifyPlayer('You are not authorized!', 'error', 2500) end + local acvstring + if bcamstate then acvstring = 'Deactivating' else acvstring = 'Activating' end + if Config.Dependency.UseProgress == 'ox' then + if lib.progressBar({ + duration = 2500, + label = acvstring..' Bodycam...', + useWhileDead = false, + canCancel = true, + disable = { + combat = true, + }, + anim = { + dict = 'clothingtie', + clip = 'try_tie_positive_a' + }, + }) then + bcamstate = not bcamstate + BodyOverlay(bcamstate) + TriggerServerEvent('spy-bodycam:server:toggleList',bcamstate) + toggleProp(bcamstate) + if bcamstate then + Citizen.CreateThread(function() + CheckForItem() + end) + else + SendNUIMessage({action = "cancel_rec_force"}) + end + else + NotifyPlayer('Cancelled!', 'error') + end + elseif Config.Dependency.UseProgress == 'qb' then + QBCore.Functions.Progressbar('spy_bdycam', acvstring..' Bodycam...', 2500, false, true, { + disableMovement = false, + disableCarMovement = false, + disableMouse = false, + disableCombat = true, + }, { + animDict = 'clothingtie', + anim = 'try_tie_positive_a', + flags = 49 + }, {}, {}, function() -- Done + StopAnimTask(cache.ped, 'clothingtie', 'try_tie_positive_a', 1.0) + bcamstate = not bcamstate + BodyOverlay(bcamstate) + TriggerServerEvent('spy-bodycam:server:toggleList',bcamstate) + toggleProp(bcamstate) + if bcamstate then + Citizen.CreateThread(function() + CheckForItem() + end) + else + SendNUIMessage({action = "cancel_rec_force"}) + end + end, function() + StopAnimTask(cache.ped, 'clothingtie', 'try_tie_positive_a', 1.0) + NotifyPlayer('Cancelled!', 'error') + end) + elseif Config.Dependency.UseProgress == 'esx' then + ESX.Progressbar(acvstring..' Bodycam...', 2500,{ + FreezePlayer = false, + animation ={ + type = "anim", + dict = "clothingtie", + lib ="try_tie_positive_a" + }, + onFinish = function() + StopAnimTask(cache.ped, 'clothingtie', 'try_tie_positive_a', 1.0) + bcamstate = not bcamstate + BodyOverlay(bcamstate) + TriggerServerEvent('spy-bodycam:server:toggleList',bcamstate) + toggleProp(bcamstate) + if bcamstate then + Citizen.CreateThread(function() + CheckForItem() + end) + else + SendNUIMessage({action = "cancel_rec_force"}) + end + end, onCancel = function() + StopAnimTask(cache.ped, 'clothingtie', 'try_tie_positive_a', 1.0) + NotifyPlayer('Cancelled!', 'error') + end + }) + end +end) + +RegisterNetEvent('spy-bodycam:toggleCarCam', function() + local isJobUse = CheckAllowedJob() + if not isJobUse then return NotifyPlayer('You are not authorized!', 'error', 2500) end + if not IsPedInAnyVehicle(cache.ped, false) then return NotifyPlayer('Not in a vehicle!', 'error') end + local veh = GetVehiclePedIsIn(cache.ped, false) + local driverPed = GetPedInVehicleSeat(veh, -1) + if driverPed ~= cache.ped then return NotifyPlayer('Not in the driver\'s seat!', 'error') end + if not isCarAuth(veh) then return NotifyPlayer('Vehicle not authorized!', 'error') end + if DoesEntityExist(veh) then + local netId = NetworkGetNetworkIdFromEntity(veh) + local acvstring = GlobalState.CarsOnBodycam[netId] and 'Deactivating' or 'Activating' + local donestr = GlobalState.CarsOnBodycam[netId] and 'Deactivated' or 'Activated' + + if Config.Dependency.UseProgress == 'ox' then + if lib.progressBar({ + duration = 2500, + label = acvstring .. ' Dashcam...', + useWhileDead = false, + canCancel = true, + disable = { + car = true, + move = true, + combat = true, + sprint = true, + }, + anim = { + dict = 'veh@submersible@ds@base', + clip = 'change_station', + flags = 49 + }, + }) then + ToggleCarCam(netId, veh) + NotifyPlayer('Dashcam '..donestr, 'success') + else + NotifyPlayer('Cancelled!', 'error') + end + elseif Config.Dependency.UseProgress == 'qb' then + QBCore.Functions.Progressbar('spy_bdycam', acvstring .. ' Dashcam...', 2500, false, true, { + disableMovement = true, + disableCarMovement = true, + disableMouse = false, + disableCombat = true, + }, { + animDict = 'veh@submersible@ds@base', + anim = 'change_station', + flags = 49 + }, {}, {}, function() + ToggleCarCam(netId, veh) + StopAnimTask(cache.ped, 'veh@submersible@ds@base', 'change_station', 1.0) + NotifyPlayer('Dashcam '..donestr, 'success') + end, function() + StopAnimTask(cache.ped, 'veh@submersible@ds@base', 'change_station', 1.0) + NotifyPlayer('Cancelled!', 'error') + end) + elseif Config.Dependency.UseProgress == 'esx' then + ESX.Progressbar(acvstring .. ' Dashcam...', 2500,{ + FreezePlayer = false, + animation ={ + type = "anim", + dict = "veh@submersible@ds@base", + lib ="change_station" + }, + onFinish = function() + ToggleCarCam(netId, veh) + StopAnimTask(cache.ped, 'veh@submersible@ds@base', 'change_station', 1.0) + NotifyPlayer('Dashcam '..donestr, 'success') + end, onCancel = function() + StopAnimTask(cache.ped, 'veh@submersible@ds@base', 'change_station', 1.0) + NotifyPlayer('Cancelled!', 'error') + end + }) + + end + end +end) + +RegisterNetEvent('spy-bodycam:updatelisteffect',function() + if PlyInSelfCam or PlyInCam then + if (not GlobalState.PlayerOnBodycam[targetPedId]) then + if PlyInSelfCam then + QuitBodyCamSelf() + elseif PlyInCam then + QuitBodyCam() + end + end + end +end) + +RegisterNetEvent('spy-bodycam:updatelisteffectcar',function() + if PlyInCarCam then + if (not GlobalState.CarsOnBodycam[targetPedId]) then + QuitBodyCam() + end + end +end) + +RegisterNetEvent('spy-bodycam:openActiveMenu', function(locId) + local optionsMenu = {} + if Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { header = 'Camera Portal',isMenuHeader = true} + optionsMenu[#optionsMenu+1] = { icon = "fas fa-circle-xmark", header = "Close", params = { event = "spy:close" } } + end + if Config.Dependency.UseMenu == 'ox' then + optionsMenu[#optionsMenu+1] = { + title = 'Active Bodycams', + icon = 'user', + onSelect = function() + TriggerEvent('spy-bodycam:openActiveMenuJob', locId) + end + } + optionsMenu[#optionsMenu+1] = { + title = 'Active Dashcams', + icon = 'car', + onSelect = function() + TriggerEvent('spy-bodycam:openActiveMenuCars', locId) + end + } + elseif Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { + header = 'Active Bodycams', + icon = 'fas fa-user', + params = { + isAction = true, + event = function() + TriggerEvent('spy-bodycam:openActiveMenuJob', locId) + end + } + } + optionsMenu[#optionsMenu+1] = { + header = 'Active Dashcams', + icon = 'fas fa-car', + params = { + isAction = true, + event = function() + TriggerEvent('spy-bodycam:openActiveMenuCars', locId) + end + } + } + elseif Config.Dependency.UseMenu == 'esx' then + optionsMenu[#optionsMenu+1] = {unselectable= true, title="Camera Portal", name = 'e1'} + optionsMenu[#optionsMenu+1] = {icon="fas fa-user", title="Active Bodycams", name = 'e2'} + optionsMenu[#optionsMenu+1] = {icon="fas fa-car", title="Active Dashcams", name = 'e3'} + ESX.OpenContext("right" , optionsMenu, + function(menu,element) + if element.name == "e2" then + TriggerEvent('spy-bodycam:openActiveMenuJob', locId) + end + if element.name == "e3" then + TriggerEvent('spy-bodycam:openActiveMenuCars', locId) + end + end) + end + if Config.Dependency.UseMenu == 'ox' then + lib.registerContext({ + id = 'spy_bdcam_list', + title = 'Camera Portal', + options = optionsMenu + }) + lib.showContext('spy_bdcam_list') + elseif Config.Dependency.UseMenu == 'qb' then + exports['qb-menu']:openMenu(optionsMenu) + end +end) + +RegisterNetEvent('spy-bodycam:openActiveMenuJob', function(locId) + local optionsMenu = {} + if Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { header = 'Active Bodycams',isMenuHeader = true} + optionsMenu[#optionsMenu+1] = { icon = "fas fa-circle-xmark", header = "Close", params = { event = "spy:close" } } + optionsMenu[#optionsMenu+1] = { + icon = "fas fa-left-long", + header = "Go Back", + params = { + isAction = true, + event = function() + TriggerEvent('spy-bodycam:openActiveMenu',locId) + end + } + } + elseif Config.Dependency.UseMenu == 'ox' then + optionsMenu[#optionsMenu+1] = { + title = 'Go Back', + icon = 'left-long', + onSelect = function() + TriggerEvent('spy-bodycam:openActiveMenu',locId) + end + } + elseif Config.Dependency.UseMenu == 'esx' then + optionsMenu[#optionsMenu+1] = {unselectable= true, title="Active Bodycams", name = 'e1'} + optionsMenu[#optionsMenu+1] = {icon="fas fa-left-long", title="Go Back", name = 'back'} + end + for k, v in pairs(GlobalState.PlayerOnBodycam) do + if Config.WatchLoc[locId].jobCam then + if isLocFilterTrue(locId,v.jobkey) then + if Config.Dependency.UseMenu == 'ox' then + optionsMenu[#optionsMenu+1] = { + title = v.name, + description = v.job.." | "..v.rank, + icon = 'video', + onSelect = function() + TriggerEvent('spy-bodycam:startWatching',k) + local coord = GetEntityCoords(cache.ped) + goBackCoords = vector4(coord.x, coord.y, coord.z -1 , GetEntityHeading(cache.ped)) + SetTimeout(2000, function() + OpenWatch(true,k,v.name,true) + end) + end + } + elseif Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { + header = v.name, + txt = v.job.." | "..v.rank, + icon = 'fas fa-video', + params = { + isAction = true, + event = function() + TriggerEvent('spy-bodycam:startWatching',k) + local coord = GetEntityCoords(cache.ped) + goBackCoords = vector4(coord.x, coord.y, coord.z -1 , GetEntityHeading(cache.ped)) + SetTimeout(2000, function() + OpenWatch(true,k,v.name,true) + end) + end + } + } + elseif Config.Dependency.UseMenu == 'esx' then + optionsMenu[#optionsMenu+1] = { + icon="fas fa-video", + title = v.name, + description = v.job.." | "..v.rank, + name = k + } + end + end + else + if Config.Dependency.UseMenu == 'ox' then + optionsMenu[#optionsMenu+1] = { + title = v.name, + description = v.job.." | "..v.rank, + icon = 'video', + onSelect = function() + TriggerEvent('spy-bodycam:startWatching',k) + local coord = GetEntityCoords(cache.ped) + goBackCoords = vector4(coord.x, coord.y, coord.z -1 , GetEntityHeading(cache.ped)) + SetTimeout(2000, function() + OpenWatch(true,k,v.name,true) + end) + end + } + elseif Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { + header = v.name, + txt = v.job.." | "..v.rank, + icon = 'fas fa-video', + params = { + isAction = true, + event = function() + TriggerEvent('spy-bodycam:startWatching',k) + local coord = GetEntityCoords(cache.ped) + goBackCoords = vector4(coord.x, coord.y, coord.z -1 , GetEntityHeading(cache.ped)) + SetTimeout(2000, function() + OpenWatch(true,k,v.name,true) + end) + end + } + } + elseif Config.Dependency.UseMenu == 'esx' then + optionsMenu[#optionsMenu+1] = { + icon="fas fa-video", + title = v.name, + description = v.job.." | "..v.rank, + name = k + } + end + end + end + if Config.Dependency.UseMenu == 'ox' then + lib.registerContext({ + id = 'spy_bcam_list', + title = 'Active Bodycams', + options = optionsMenu + }) + lib.showContext('spy_bcam_list') + elseif Config.Dependency.UseMenu == 'qb' then + exports['qb-menu']:openMenu(optionsMenu) + elseif Config.Dependency.UseMenu == 'esx' then + ESX.OpenContext("right" , optionsMenu, + function(menu,element) + if element.name == 'back' then TriggerEvent('spy-bodycam:openActiveMenu',locId) return end + TriggerEvent('spy-bodycam:startWatching',element.name) + local coord = GetEntityCoords(cache.ped) + goBackCoords = vector4(coord.x, coord.y, coord.z -1 , GetEntityHeading(cache.ped)) + SetTimeout(2000, function() + OpenWatch(true,element.name,element.title,true) + end) + ESX.CloseContext() + end) + end +end) + +RegisterNetEvent('spy-bodycam:openActiveMenuCars', function(locId) + local optionsMenu = {} + if Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { header = 'Active Dashcams',isMenuHeader = true} + optionsMenu[#optionsMenu+1] = { icon = "fas fa-circle-xmark", header = "Close", params = { event = "spy:close" } } + optionsMenu[#optionsMenu+1] = { + icon = "fas fa-left-long", + header = "Go Back", + params = { + isAction = true, + event = function() + TriggerEvent('spy-bodycam:openActiveMenu',locId) + end + } + } + elseif Config.Dependency.UseMenu == 'ox' then + optionsMenu[#optionsMenu+1] = { + title = 'Go Back', + icon = 'left-long', + onSelect = function() + TriggerEvent('spy-bodycam:openActiveMenu',locId) + end + } + elseif Config.Dependency.UseMenu == 'esx' then + optionsMenu[#optionsMenu+1] = {unselectable= true, title="Active Dashcams", name = 'e1'} + optionsMenu[#optionsMenu+1] = {icon="fas fa-left-long", title="Go Back", name = 'back'} + end + for k, v in pairs(GlobalState.CarsOnBodycam) do + if Config.WatchLoc[locId].carCam then + if isCarCamJobTrue(locId,v.jobkey) or isCarCamClassTrue(locId,v.carclass) then + if Config.Dependency.UseMenu == 'ox' then + optionsMenu[#optionsMenu+1] = { + title = v.carname, + description = "Plate: "..v.plate.." | "..v.name, + icon = 'car', + onSelect = function() + StartDashCamWatch(k,v.plate,v.carname) + end + } + elseif Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { + header = v.carname, + txt = "Plate: "..v.plate.." | "..v.name, + icon = 'fas fa-car', + params = { + isAction = true, + event = function() + StartDashCamWatch(k,v.plate,v.carname) + end + } + } + elseif Config.Dependency.UseMenu == 'esx' then + optionsMenu[#optionsMenu+1] = { + icon="fas fa-car", + title = v.carname, + description = "Plate: "..v.plate.." | "..v.name, + value = {k,v.plate,v.carname} + } + end + end + else + if Config.Dependency.UseMenu == 'ox' then + optionsMenu[#optionsMenu+1] = { + title = v.carname, + description = "Plate: "..v.plate.." | "..v.name, + icon = 'car', + onSelect = function() + StartDashCamWatch(k,v.plate,v.carname) + end + } + elseif Config.Dependency.UseMenu == 'qb' then + optionsMenu[#optionsMenu+1] = { + header = v.carname, + txt = "Plate: "..v.plate.." | "..v.name, + icon = 'fas fa-car', + params = { + isAction = true, + event = function() + StartDashCamWatch(k,v.plate,v.carname) + end + } + } + elseif Config.Dependency.UseMenu == 'esx' then + optionsMenu[#optionsMenu+1] = { + icon="fas fa-car", + title = v.carname, + description = "Plate: "..v.plate.." | "..v.name, + value = {k,v.plate,v.carname} + } + end + end + end + if Config.Dependency.UseMenu == 'ox' then + lib.registerContext({ + id = 'spy_dcam_list', + title = 'Active Dashcams', + options = optionsMenu + }) + lib.showContext('spy_dcam_list') + elseif Config.Dependency.UseMenu == 'qb' then + exports['qb-menu']:openMenu(optionsMenu) + elseif Config.Dependency.UseMenu == 'esx' then + ESX.OpenContext("right" , optionsMenu, + function(menu,element) + if element.name == 'back' then TriggerEvent('spy-bodycam:openActiveMenu',locId) return end + StartDashCamWatch(element.value[1],element.value[2],element.value[3]) + ESX.CloseContext() + end) + end +end) + +RegisterNetEvent('spy-bodycam:client:createDecoyPed', function(model, data, pVec4, plyId) + if not Config.Dependency.UseAppearance then return end + RequestModel(model) + local timeout = 0 + while not HasModelLoaded(model) and timeout < 500 do + Wait(10) + timeout = timeout + 1 + end + if not HasModelLoaded(model) then + print('Error: Model could not be loaded:', model) + return + end + -- Create the ped + charPed[plyId] = CreatePed(2, model, pVec4.x, pVec4.y, pVec4.z, pVec4.w, false, true) + if not DoesEntityExist(charPed[plyId]) then + print('Error: Ped could not be created.') + return + end + SetPedComponentVariation(charPed[plyId], 0, 0, 0, 2) + FreezeEntityPosition(charPed[plyId], true) + SetEntityInvincible(charPed[plyId], true) + SetBlockingOfNonTemporaryEvents(charPed[plyId], true) + if data then + if Config.Dependency.UseAppearance == 'qb' then + TriggerEvent('qb-clothing:client:loadPlayerClothing', data, charPed[plyId]) + elseif Config.Dependency.UseAppearance == 'illenium' then + exports['illenium-appearance']:setPedAppearance(charPed[plyId], data) + end + end + PlayWatchAnim(charPed[plyId],false) +end) + +RegisterNetEvent('spy-bodycam:client:deleteDecoyPed',function(plyId) + if not Config.Dependency.UseAppearance then return end + if charPed[plyId] then + if DoesEntityExist(charPed[plyId]) then + StopWatchAnim(charPed[plyId]) + DeleteEntity(charPed[plyId]) + charPed[plyId] = nil + end + end +end) + +RegisterNetEvent('spy-bodycam:client:startRec',function(webhook,serviceUsed) + SendNUIMessage({ + action = "toggle_record", + hook = webhook, + service = serviceUsed, + recTiming = Config.RecordTime, + }) + if Config.ForceViewCam then + SetTimecycleModifier(Config.CameraEffect.bodycam) + SetTimecycleModifierStrength(0.5) + CreateThread(function() + onRec = true + while onRec do + SetFollowPedCamViewMode(4) + Wait(0) + end + end) + end +end) + +RegisterNetEvent('spy-bodycam:client:openRecords',function(records,jobTitle,isBoss) + SetNuiFocus(true, true) + PlayWatchAnim(cache.ped,true) + SendNUIMessage({ + action = "show_records", + recordData = records, + jobTitle = jobTitle, + isBoss = isBoss + }) +end) + +RegisterNetEvent('spy-bodycam:client:refreshRecords',function(records,isBoss) + SendNUIMessage({ + action = "refreshrec", + recordData = records, + isBoss = isBoss + }) +end) + +RegisterKeyMapping('bodycamexit', 'Exit bodycam spectate', 'keyboard', Config.ExitCamKey) +RegisterCommand('bodycamexit', function() + if PlyInCam or PlyInCarCam then + QuitBodyCam() + elseif PlyInSelfCam then + QuitBodyCamSelf() + end +end) + +RegisterNUICallback('exitBodyCam', function(data, cb) + if not Config.ForceViewCam then return end + onRec = false + SetFollowPedCamViewMode(1) + SetTimecycleModifier('default') + SetTimecycleModifierStrength(1.0) +end) + +RegisterNUICallback('videoLog', function(data, cb) + if data then + local videoUrl = data.vidurl + local pos = GetEntityCoords(cache.ped) + local s1, s2 = GetStreetNameAtCoord(pos.x, pos.y, pos.z) + TriggerServerEvent('spy-bodycam:server:logVideoDetails', videoUrl,GetStreetNameFromHashKey(s1)) + end +end) + +RegisterNUICallback('deleteVideo', function(data, cb) + if data then + local videoUrl = data.vidurl + TriggerServerEvent('spy-bodycam:server:deleteVideoDB', videoUrl) + end +end) + +RegisterNUICallback('closeRecUI', function(data, cb) + StopWatchAnim(cache.ped) + SetNuiFocus(false, false) +end) + +--- STANDALONE FUNCTIONS +function StartDashCamWatch(k,plate,carname) + local targetCoords = lib.callback.await('spy-bodycam:servercb:getCarCoords', false, k) + if not targetCoords then NotifyPlayer('Car not found!', 'error', 2500) return end + TriggerEvent('spy-bodycam:startWatchingDashcam',k) + local coord = GetEntityCoords(cache.ped) + goBackCoords = vector4(coord.x, coord.y, coord.z -1 , GetEntityHeading(cache.ped)) + SetTimeout(2000, function() + OpenWatch(true,plate,carname,false) + end) +end + +function isCarAuth(veh) + local vehClass = GetVehicleClass(veh) + for k,v in ipairs(Config.AllowedClass) do + if tonumber(vehClass) == tonumber(v) then return true end + end + return false +end + +function ToggleCarCam(netId, veh) + if not GlobalState.CarsOnBodycam[netId] then + local carPlate = GetVehicleNumberPlateText(veh) + local carName = GetVehDisplayName(GetEntityModel(veh)) + local carClass = GetVehicleClass(veh) + TriggerServerEvent('spy-bodycam:server:toggleListCars', true, netId, carPlate, carName,carClass) + else + TriggerServerEvent('spy-bodycam:server:toggleListCars', false, netId) + end +end + +function GetVehDisplayName(model) + local vehName = GetLabelText(GetDisplayNameFromVehicleModel(model)) + if vehName == 'NULL' then + vehName = GetDisplayNameFromVehicleModel(model) + end + return vehName +end + +function SetCamRotation() + while PlyInCam do + SetCamRot(bodycam, 0, 0, GetEntityHeading(targetPed), 2) + Wait(1) + end +end + +function SetCarCam() + while PlyInCam or PlyInSelfCam do + if (IsPedInAnyVehicle(targetPed,false) and not carCam) then + AttachCamToPedBone(bodycam, targetPed, 46240, 0.1, 0.25, -0.1, true) + carCam = true + elseif (not IsPedInAnyVehicle(targetPed,false) and carCam) then + AttachCamToPedBone(bodycam, targetPed, 46240, 0.1, 0.025, 0.1, true) + carCam = false + end + Wait(2000) + end +end + +function SetPlayerNearTarget() + while PlyInCam or PlyInCarCam do + local ownCoords = GetEntityCoords(cache.ped) + if DoesEntityExist(targetPed) then + local targetCoords = GetEntityCoords(targetPed) + local distance = #(ownCoords - targetCoords) + + if distance > 150 then + SetEntityCoords(cache.ped, targetCoords.x, targetCoords.y, targetCoords.z - 100.0, false, false, false, true) + end + else + QuitBodyCam() + end + Wait(2500) -- Check the distance every given second + end +end + +function QuitBodyCamSelf() + DoScreenFadeOut(1000) + while not IsScreenFadedOut() do + Wait(100) + end + SetTimeout(1000, function() + OpenWatch(false) + end) + StopWatchAnim(cache.ped) + FreezeEntityPosition(cache.ped, false) + RenderScriptCams(false, false, 0, 1, 0) + SetTimecycleModifier('default') + SetTimecycleModifierStrength(1.0) + PlyInSelfCam = false + DoScreenFadeIn(1000) + LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', true) +end + +function QuitBodyCam() + DoScreenFadeOut(1000) + while not IsScreenFadedOut() do + Wait(100) + end + SetTimeout(1000, function() + OpenWatch(false) + end) + TriggerServerEvent('spy-bodycam:server:ReqDeleteDecoyPed') + SetEntityVisible(cache.ped, true) -- Set invisible + SetEntityCollision(cache.ped, true, true) -- Set collision + SetEntityInvincible(cache.ped, false) -- Set invincible + NetworkSetEntityInvisibleToNetwork(cache.ped, false) -- Set invisibility + FreezeEntityPosition(cache.ped, false) + SetEntityCoords(cache.ped, goBackCoords.x, goBackCoords.y, goBackCoords.z) + SetEntityHeading(cache.ped, goBackCoords.w) + RenderScriptCams(false, false, 0, 1, 0) + SetTimecycleModifier('default') + SetTimecycleModifierStrength(1.0) + PlyInCam = false + PlyInCarCam = false + DoScreenFadeIn(1000) + LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', true) +end + +function ForceQuitBodyCamSelf() + OpenWatch(false) + StopWatchAnim(cache.ped) + FreezeEntityPosition(cache.ped, false) + RenderScriptCams(false, false, 0, 1, 0) + SetTimecycleModifier('default') + SetTimecycleModifierStrength(1.0) + LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', true) +end + +function ForceQuitBodyCam() + SetEntityVisible(cache.ped, true) -- Set invisible + SetEntityCollision(cache.ped, true, true) -- Set collision + SetEntityInvincible(cache.ped, false) -- Set invincible + NetworkSetEntityInvisibleToNetwork(cache.ped, false) -- Set invisibility + FreezeEntityPosition(cache.ped, false) + SetEntityCoords(cache.ped, goBackCoords.x, goBackCoords.y, goBackCoords.z) + SetEntityHeading(cache.ped, goBackCoords.w) + RenderScriptCams(false, false, 0, 1, 0) + SetTimecycleModifier('default') + SetTimecycleModifierStrength(1.0) + LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', true) +end + +function BodyOverlay(bool) + if bool then + if Config.Framework == 'qb' then + local bodyId = GetPlayerServerId(PlayerId()) + local playerName = GetPlayerDataCore().charinfo.firstname .. " " .. GetPlayerDataCore().charinfo.lastname + local randomBodyNum = "BODY "..bodyId.. " | ".."X"..tostring(math.random(100000, 999999)) .. "N" + local callsign = "("..GetPlayerDataCore().metadata["callsign"]..") " .. playerName + SendNUIMessage({ + action = 'open', + bodyname = randomBodyNum, + callsign = callsign, + }) + else + local bodyId = GetPlayerServerId(PlayerId()) + local playerName = lib.callback.await('spy-bodycam:servercb:getNamESX', true) + local randomBodyNum = "BODY "..bodyId.. " | ".."X"..tostring(math.random(100000, 999999)) .. "N" + local callsign = "("..GetPlayerDataCore().job.grade_label..") " .. playerName + SendNUIMessage({ + action = 'open', + bodyname = randomBodyNum, + callsign = callsign, + }) + end + else + SendNUIMessage({ + action = 'close' + }) + end +end + +function OpenWatch(bool,bodyId,name,isbodycam) + if bool then + SendNUIMessage({ + action = 'openWatch', + bodyId = bodyId, + name = name, + isbodycam = isbodycam, + exitKey = Config.ExitCamKey, + debug = Config.DebugCamera, + }) + else + SendNUIMessage({ + action = 'closeWatch' + }) + end +end + +function PlayWatchAnim(ped,isNet) + local x, y, z = table.unpack(GetEntityCoords(ped)) + local tabletprop = `prop_cs_tablet` + RequestModel(tabletprop) + while not HasModelLoaded(tabletprop) do + Citizen.Wait(10) + end + local prop = CreateObject(tabletprop, x, y, z + 0.2, isNet, true, false) + AttachEntityToEntity(prop, ped, GetPedBoneIndex(ped, 28422), -0.05, 0.0, 0.0, 0.0, 0.0, 0.0, true, true, false, true, 1, true) + local animDict = 'amb@code_human_in_bus_passenger_idles@female@tablet@idle_a' + RequestAnimDict(animDict) + while not HasAnimDictLoaded(animDict) do + Citizen.Wait(10) + end + TaskPlayAnim(ped, animDict, "idle_a", 3.0, -8.0, -1, 49, 0, false, false, false) + pedProps[ped] = prop +end + +function StopWatchAnim(ped) + local prop = pedProps[ped] + ClearPedTasks(ped) + if prop and DoesEntityExist(prop) then + DetachEntity(prop, true, true) + DeleteEntity(prop) + else + print("Error: Prop does not exist or is not attached to the ped.") + end + pedProps[ped] = nil +end + +function toggleProp(state) + local gender = nil + local coords = nil + local rotation = nil + local boneId = nil + local propName = "rj_bodycam" + if Config.Framework == 'qb' then + local Player = GetPlayerDataCore() + gender = Player.charinfo.gender + else + local xPlayer = GetPlayerDataCore() + gender = xPlayer.sex + end + if gender == 0 or gender == 'm' then + coords = Config.PropLoc.male.pos + rotation = Config.PropLoc.male.rot + boneId = Config.PropLoc.male.bone + else + coords = Config.PropLoc.female.pos + rotation = Config.PropLoc.female.rot + boneId = Config.PropLoc.female.bone + end + if state then + if not propNetID or not DoesEntityExist(NetworkGetEntityFromNetworkId(propNetID)) then + RequestModel(propName) + while not HasModelLoaded(propName) do + Wait(1) + end + local propEntity = CreateObject(GetHashKey(propName), 0.0, 0.0, 0.0, true, true, true) + AttachEntityToEntity(propEntity, cache.ped, GetPedBoneIndex(cache.ped, boneId), coords.x, coords.y, coords.z, rotation.x, rotation.y, rotation.z, true, true, false, true, 1, true) + propNetID = NetworkGetNetworkIdFromEntity(propEntity) + SetNetworkIdExistsOnAllMachines(propNetID, true) + end + else + if propNetID and DoesEntityExist(NetworkGetEntityFromNetworkId(propNetID)) then + local propEntity = NetworkGetEntityFromNetworkId(propNetID) + DeleteEntity(propEntity) + propNetID = nil + end + end +end + +--- FRAMEWORK FUNCTIONS +function isCarCamJobTrue(locId, jobKey) + if not Config.WatchLoc[locId].carCam.job then return false end + for _, v in ipairs(Config.WatchLoc[locId].carCam.job) do + if jobKey == v then + return true + end + end + return false +end + +function isCarCamClassTrue(locId, vehClass) + if not Config.WatchLoc[locId].carCam.class then return false end + for _, v in ipairs(Config.WatchLoc[locId].carCam.class) do + if tonumber(vehClass) == tonumber(v) then + return true + end + end + return false +end + +function CheckForItem() + while bcamstate do + local hasItem = HasItemsCheck('bodycam') + if not hasItem then + TriggerServerEvent('spy-bodycam:server:toggleList',false) + BodyOverlay(false) + toggleProp(false) + bcamstate = false + SendNUIMessage({action = "cancel_rec_force"}) + break + end + Wait(2500) + end +end + +function CheckAllowedJob() + for k,v in ipairs(Config.AllowedJobs) do + if PlayerJob.name == v then return true end + end + return false +end + +function isLocFilterTrue(locId,jobkey) + if not Config.WatchLoc[locId].jobCam then return true end + for k,v in ipairs(Config.WatchLoc[locId].jobCam) do + if jobkey == v then return true end + end + return false +end + +function targetAuth(locId,jobkey) + if not Config.WatchLoc[locId].targetAuth then return true end + for k,v in ipairs(Config.WatchLoc[locId].targetAuth) do + if jobkey == v then return true end + end + return false +end + +function NotifyPlayer(msg,type,time) + if Config.Dependency.UseNotify == 'ox' then + lib.notify({ + title = '', + description = msg, + duration = time, + type = type + }) + elseif Config.Dependency.UseNotify == 'qb' then + QBCore.Functions.Notify(msg,type,time) + elseif Config.Dependency.UseNotify == 'esx' then + ESX.ShowNotification(msg, type, time) + end +end + +function GetPlayerDataCore() + if Config.Framework == 'qb' then + if QBCore.Functions.GetPlayerData() then + return QBCore.Functions.GetPlayerData() + else + return false + end + elseif Config.Framework == 'esx' then + if ESX.GetPlayerData() then + return ESX.GetPlayerData() + else + return false + end + end +end + +function HasItemsCheck(itemname) + if Config.Dependency.UseInventory == 'qb' then + return QBCore.Functions.HasItem(itemname) + elseif Config.Dependency.UseInventory == 'esx' then + local hasItem = ESX.SearchInventory(itemname, 1) + if hasItem >= 1 then + return true + else + return false + end + elseif Config.Dependency.UseInventory == 'ox' then + local chkItem = exports.ox_inventory:Search('count', itemname) + if type(chkItem) == 'table' then + for _, v in pairs(chkItem) do + if v >= 1 then + return true + end + end + else + return chkItem >= 1 + end + end + return false +end + + diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/client/target.lua b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/client/target.lua new file mode 100644 index 000000000..1ab85d92e --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/client/target.lua @@ -0,0 +1,86 @@ +CreateThread(function() + if Config.Dependency.UseTarget == 'qb' then + for k,v in ipairs(Config.WatchLoc) do + exports['qb-target']:AddCircleZone("spycam_watch"..k,v.coords,v.rad, { + name = "spycam_watch"..k, + useZ=true, + debugPoly = v.debug, + }, { + options = { + { + type = "client", + icon = "fas fa-sign-in-alt", + label = 'Open Camera Portal', + action = function(entity) + TriggerEvent('spy-bodycam:openActiveMenu',k) + end, + canInteract = function(entity) + return targetAuth(k,PlayerJob.name) + end, + + }, + { + type = "client", + icon = "fas fa-list", + label = 'Records Database', + action = function(entity) + TriggerServerEvent('spy-bodycam:server:showrecordingUI') + end, + canInteract = function(entity) + return targetAuth(k,PlayerJob.name) + end, + + }, + }, + distance = 2.5 + }) + end + else + for k,v in ipairs(Config.WatchLoc) do + exports.ox_target:addSphereZone( + { + coords = v.coords, + radius = v.rad, + debug = v.debug, + drawSprite = false, + options = { + { + name = "spycam_watch"..k, + label = 'Open Camera Portal', + icon = "fas fa-sign-in-alt", + distance = 2.5, + onSelect = function(data) + TriggerEvent('spy-bodycam:openActiveMenu',k) + end, + canInteract = function(entity, distance, coords, name, bone) + return targetAuth(k,PlayerJob.name) + end, + }, + { + name = "spycam_watch"..k, + label = 'Records Database', + icon = "fas fa-list", + distance = 2.5, + onSelect = function(data) + TriggerServerEvent('spy-bodycam:server:showrecordingUI') + end, + canInteract = function(entity, distance, coords, name, bone) + return targetAuth(k,PlayerJob.name) + end, + }, + } + } + ) + end + end +end) + +AddEventHandler('onResourceStop', function(resourceName) + if GetCurrentResourceName() == resourceName then + if Config.Dependency.UseTarget == 'qb' then + for k,v in ipairs(Config.WatchLoc) do + exports['qb-target']:RemoveZone("spycam_watch"..k) + end + end + end +end) \ No newline at end of file diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/config.lua b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/config.lua new file mode 100644 index 000000000..50915256f --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/config.lua @@ -0,0 +1,102 @@ +-- ███████╗██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ █████╗ ███╗ ███╗ +-- ██╔════╝██╔══██╗╚██╗ ██╔╝ ██╔══██╗██╔═══██╗██╔══██╗╚██╗ ██╔╝██╔════╝██╔══██╗████╗ ████║ +-- ███████╗██████╔╝ ╚████╔╝ ██████╔╝██║ ██║██║ ██║ ╚████╔╝ ██║ ███████║██╔████╔██║ +-- ╚════██║██╔═══╝ ╚██╔╝ ██╔══██╗██║ ██║██║ ██║ ╚██╔╝ ██║ ██╔══██║██║╚██╔╝██║ +-- ███████║██║ ██║ ██████╔╝╚██████╔╝██████╔╝ ██║ ╚██████╗██║ ██║██║ ╚═╝ ██║ +-- ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ + +Config = Config or {} + +Config.Framework = 'qb' -- qb | esx + +if Config.Framework == 'qb' then -- Dont touch this part + QBCore = exports["qb-core"]:GetCoreObject() +elseif Config.Framework == 'esx' then + ESX = exports.es_extended:getSharedObject() +end + +Config.Dependency = { + UseTarget = 'qb', -- qb | ox + UseInventory = 'qb', -- qb | ox | esx + UseProgress = 'qb', -- qb | ox | esx + UseMenu = 'qb', -- qb | ox | esx + UseNotify = 'qb', -- qb | ox | esx + UseAppearance = 'illenium', -- qb | illenium | false +} + +Config.ExitCamKey = 'BACK' + +Config.CameraEffect = { + bodycam = 'Island_CCTV_ChannelFuzz', + dashcam = 'TinyRacerMoBlur', +} + +Config.ForceViewCam = false -- Forces cam view to first person when recording. +Config.RecordTime = 30 --Recording Time | 30 = 30 seconds | [*note: Dont increase the time too much or it may not upload to any service you are using for example - discord.] + +Config.PropLoc = { -- Change prop position according to ur clothing pack. + male = { + bone = 24818, + pos = vector3(0.16683200771922, 0.11320925137666, 0.11986595654326), + rot = vector3(-14.502323044318, 82.191095946679, -164.22066869048), + }, + female = { + bone = 24818, + pos = vector3(0.16683200771922, 0.11320925137666, 0.11986595654326), + rot = vector3(-14.502323044318, 82.191095946679, -164.22066869048), + }, +} + +Config.AllowedJobs = { -- Only these jobs can use bodycam/dashcam item. + 'police', + 'ambulance', +} + +Config.AllowedClass = {18} -- Vehicle classes allowed to use the dashcam feature. + +Config.WatchLoc = { + [1] = { + coords = vector3(440.149445, -979.437378, 30.453491), + rad = 1.5, + debug = false, + jobCam = {'police','ambulance'}, -- jobs mentioned here are shown in the list | false = able to view all the bodycams + carCam = { -- false = able to view all the dashcams + job = {'police'}, -- Jobs that activate dashcams shown in the list | false excludes. + class = {18} -- Dashcam activated on these vehicleclass shown in the list | false excludes. + }, + targetAuth = {'police'}, -- jobs mentioned here can use this location from target | false = everyone can access this location + + }, -- You can add more locations +} + +Config.DebugCamera = false -- Make it true if you want to get new camera offset for some vehicle. +Config.VehCamOffset = { + [`police2`] = {0.000000, 0.330000, 0.530000}, + -- [`18chgr2`] = {0.000000, 0.510000, 0.630000}, -- Example vehicle. The script comes with its own offset finder just set DebugCamera to true and get the offset. + -- [`vehiclespawncode`] = {0.000000, 0.510000, 0.630000}, +} + +-- Vehicle Classes: +-- 0: Compacts +-- 1: Sedans +-- 2: SUVs +-- 3: Coupes +-- 4: Muscle +-- 5: Sports Classics +-- 6: Sports +-- 7: Super +-- 8: Motorcycles +-- 9: Off-road +-- 10: Industrial +-- 11: Utility +-- 12: Vans +-- 13: Cycles +-- 14: Boats +-- 15: Helicopters +-- 16: Planes +-- 17: Service +-- 18: Emergency +-- 19: Military +-- 20: Commercial +-- 21: Trains +-- 22: Open Wheel \ No newline at end of file diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/fxmanifest.lua b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/fxmanifest.lua new file mode 100644 index 000000000..11c675e65 --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/fxmanifest.lua @@ -0,0 +1,29 @@ +fx_version 'cerulean' + +game "gta5" + +author "Spy-Script" +version '2.5.6' + +lua54 'yes' + +ui_page 'web/index.html' + +shared_script { + "config.lua", + '@ox_lib/init.lua', +} + +server_script { + "server/**", + '@oxmysql/lib/MySQL.lua', +} + +client_script { + 'client/**', +} + +files { + 'web/**', + "node_modules/fivem-game-view/**/*", +} diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/inv_images/bodycam.png b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/inv_images/bodycam.png new file mode 100644 index 000000000..3cbd45566 Binary files /dev/null and b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/inv_images/bodycam.png differ diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/inv_images/dashcam.png b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/inv_images/dashcam.png new file mode 100644 index 000000000..6457a6949 Binary files /dev/null and b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/inv_images/dashcam.png differ diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/spy_bodycam.sql b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/spy_bodycam.sql new file mode 100644 index 000000000..49cc76c78 --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/installfiles/spy_bodycam.sql @@ -0,0 +1,24 @@ +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +CREATE TABLE IF NOT EXISTS `spy_bodycam` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `job` varchar(255) NOT NULL, + `videolink` longtext NOT NULL, + `street` varchar(255) NOT NULL, + `date` varchar(255) NOT NULL, + `playername` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; + +/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */; +/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; +/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */; diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/server/server.lua b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/server/server.lua new file mode 100644 index 000000000..bf4ee74dc --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/server/server.lua @@ -0,0 +1,373 @@ +PlayerOnBodycam = {} +GlobalState.PlayerOnBodycam = PlayerOnBodycam +CarsOnBodycam = {} +GlobalState.CarsOnBodycam = CarsOnBodycam + +lib.callback.register('spy-bodycam:servercb:getPedCoords', function(source, targetId) + local targetPed = GetPlayerPed(targetId) + if targetPed == 0 then return false end + local targetCoords = GetEntityCoords(targetPed) + if targetCoords then return targetCoords end + +end) + +lib.callback.register('spy-bodycam:servercb:getCarCoords', function(source, netId) + local veh = NetworkGetEntityFromNetworkId(netId) + if DoesEntityExist(veh) then + local targetCoords = GetEntityCoords(veh) + if targetCoords then return targetCoords end + else + CarsOnBodycam[netId] = nil + GlobalState.CarsOnBodycam = CarsOnBodycam + return false + end +end) + +lib.callback.register('spy-bodycam:servercb:getNamESX', function(source) + local xPlayer = ESX.GetPlayerFromId(source) + local Name = xPlayer.getName() + if Name then return Name end +end) + +RegisterNetEvent('spy-bodycam:server:toggleList',function(bool) + local src = source + if bool then + if Config.Framework == 'qb' then + local Player = QBCore.Functions.GetPlayer(src) + local Name = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname + local Job = Player.PlayerData.job.label + local Rank = Player.PlayerData.job.grade.name + PlayerOnBodycam[src] = { + name = Name, + jobkey = Player.PlayerData.job.name, + job = Job, + rank = Rank, + } + else + local xPlayer = ESX.GetPlayerFromId(src) + local Name = xPlayer.getName() + local Job = xPlayer.getJob().label + local Rank = xPlayer.getJob().grade_label + PlayerOnBodycam[src] = { + name = Name, + jobkey = xPlayer.getJob().name, + job = Job, + rank = Rank, + } + end + + GlobalState.PlayerOnBodycam = PlayerOnBodycam + else + PlayerOnBodycam[src] = nil + GlobalState.PlayerOnBodycam = PlayerOnBodycam + end + SetTimeout(1000, function() + TriggerClientEvent('spy-bodycam:updatelisteffect',-1) + end) + +end) + +RegisterNetEvent('spy-bodycam:server:toggleListCars',function(bool,entityId,carPlate,carName,carClass) + local src = source + if bool then + local veh = NetworkGetEntityFromNetworkId(entityId) + if DoesEntityExist(veh) then + local jobkey + local Name + if Config.Framework == 'qb' then + local Player = QBCore.Functions.GetPlayer(src) + jobkey = Player.PlayerData.job.name + Name = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname + else + local xPlayer = ESX.GetPlayerFromId(src) + jobkey = xPlayer.getJob().name + Name = xPlayer.getName() + end + CarsOnBodycam[entityId] = { + plate = carPlate, + carname = carName, + name = Name, + jobkey = jobkey, + carclass = carClass, + } + GlobalState.CarsOnBodycam = CarsOnBodycam + else + CarsOnBodycam[entityId] = nil + GlobalState.CarsOnBodycam = CarsOnBodycam + end + else + CarsOnBodycam[entityId] = nil + GlobalState.CarsOnBodycam = CarsOnBodycam + end + SetTimeout(1000, function() + TriggerClientEvent('spy-bodycam:updatelisteffectcar',-1) + end) +end) + +RegisterNetEvent('spy-bodycam:server:ReqDeleteDecoyPed',function() + if not Config.Dependency.UseAppearance then return end + local src = source + TriggerClientEvent('spy-bodycam:client:deleteDecoyPed',-1,src) +end) + +RegisterNetEvent('spy-bodycam:server:ReqDecoyPed', function(cid, pedCoords) + if not Config.Dependency.UseAppearance then return end + local src = source + local result + local function handleDecoyPed(model, skin, pedCoords, src) + local nPlayers = lib.getNearbyPlayers(vector3(pedCoords.x, pedCoords.y, pedCoords.z), 150) + if nPlayers then + for i = 1, #nPlayers do + TriggerClientEvent('spy-bodycam:client:createDecoyPed', nPlayers[i].id, model, skin, pedCoords, src) + end + end + end + if Config.Framework == 'qb' then + result = MySQL.query.await('SELECT * FROM playerskins WHERE citizenid = ? AND active = ?', {cid, 1}) + if result[1] ~= nil then + local skinData = json.decode(result[1].skin) + if Config.Dependency.UseAppearance == 'qb' then + handleDecoyPed(tonumber(result[1].model), skinData, pedCoords, src) + elseif Config.Dependency.UseAppearance == 'illenium' then + handleDecoyPed(joaat(skinData.model), skinData, pedCoords, src) + end + end + elseif Config.Framework == 'esx' then + result = MySQL.single.await("SELECT skin FROM users WHERE identifier = ?", {cid}) + if result then + local skinData = json.decode(result.skin) + if Config.Dependency.UseAppearance == 'illenium' then + handleDecoyPed(joaat(skinData.model), skinData, pedCoords, src) + end + end + end +end) + +Citizen.CreateThread(function() + if Config.Dependency.UseInventory == 'qb' then + QBCore.Functions.CreateUseableItem('bodycam', function(source, item) + TriggerClientEvent('spy-bodycam:bodycamstatus',source) + end) + QBCore.Functions.CreateUseableItem('dashcam', function(source, item) + TriggerClientEvent('spy-bodycam:toggleCarCam',source) + end) + elseif Config.Dependency.UseInventory == 'esx' then + ESX.RegisterUsableItem('bodycam', function(playerId) + TriggerClientEvent('spy-bodycam:bodycamstatus', playerId) + end) + ESX.RegisterUsableItem('dashcam', function(playerId) + TriggerClientEvent('spy-bodycam:toggleCarCam', playerId) + end) + end +end) + +RegisterNetEvent('spy-bodycam:server:logVideoDetails', function(videoUrl,streetName) + local src = source + local offName + local offJob + local offRank + local jobKey + local date = os.date('%Y-%m-%d') + + if Config.Framework == 'qb' then + local Player = QBCore.Functions.GetPlayer(src) + offName = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname + offJob = Player.PlayerData.job.label + offRank = Player.PlayerData.job.grade.name + jobKey = Player.PlayerData.job.name + else + local xPlayer = ESX.GetPlayerFromId(src) + offName = xPlayer.getName() + offJob = xPlayer.getJob().label + offRank = xPlayer.getJob().grade_label + jobKey = xPlayer.getJob().name + end + + ---SQL UPLOAD + MySQL.Async.execute('INSERT INTO spy_bodycam (job, videolink, street, date, playername) VALUES (@job, @videolink, @street, @date, @playername)', { + ['@job'] = jobKey, + ['@videolink'] = videoUrl, + ['@street'] = streetName, + ['@date'] = date, + ['@playername'] = offName + }, function(rowsChanged) end) + + if Upload.DiscordLogs.Enabled then + local defwebhook + local author + if Upload.JobUploads[jobKey] then + defwebhook = Upload.JobUploads[jobKey].webhook + author = Upload.JobUploads[jobKey].author + else + defwebhook = Upload.DefaultUploads.webhook + author = Upload.DefaultUploads.author + end + local embedData = { + { + title = Upload.DiscordLogs.Title, + color = 16761035, + fields = { + { name = "Name:", value = offName, inline = false }, + { name = "Job:", value = offJob, inline = false }, + { name = "Job Rank:", value = offRank, inline = false }, + }, + footer = { + text = "Date: " .. os.date("!%Y-%m-%d %H:%M:%S", os.time()), + icon_url = "https://i.imgur.com/CuSyeZT.png", + }, + author = author + } + } + PerformHttpRequest(defwebhook, function() end, 'POST', json.encode({ username = Upload.DiscordLogs.Username, embeds = embedData}), { ['Content-Type'] = 'application/json' }) + end +end) + +RegisterNetEvent('spy-bodycam:server:deleteVideoDB', function(videoUrl) + local src = source + if not videoUrl or videoUrl == '' then return end + MySQL.Async.execute('DELETE FROM spy_bodycam WHERE videolink = @videolink', { + ['@videolink'] = videoUrl + }, function(rowsChanged) + if rowsChanged > 0 then + local jobKey + local isBoss + if Config.Framework == 'qb' then + local Player = QBCore.Functions.GetPlayer(src) + jobKey = Player.PlayerData.job.name + isBoss = Player.PlayerData.job.isboss + else + local xPlayer = ESX.GetPlayerFromId(src) + jobKey = xPlayer.getJob().name + isBoss = (xPlayer.getJob().grade_name == 'boss') + end + MySQL.Async.fetchAll('SELECT * FROM spy_bodycam WHERE job = @job ORDER BY id DESC', { + ['@job'] = jobKey + }, function(records) + TriggerClientEvent('spy-bodycam:client:refreshRecords', src, records, isBoss) + end) + end + end) +end) + +RegisterNetEvent('spy-bodycam:server:showrecordingUI', function() + local src = source + local offJob + local jobKey + local isBoss + if Config.Framework == 'qb' then + local Player = QBCore.Functions.GetPlayer(src) + offJob = Player.PlayerData.job.label + jobKey = Player.PlayerData.job.name + isBoss = Player.PlayerData.job.isboss + else + local xPlayer = ESX.GetPlayerFromId(src) + offJob = xPlayer.getJob().label + jobKey = xPlayer.getJob().name + if xPlayer.getJob().grade_name == 'boss' then isBoss = true else isBoss = false end + end + MySQL.Async.fetchAll('SELECT * FROM spy_bodycam WHERE job = @job ORDER BY id DESC', { + ['@job'] = jobKey + }, function(records) + TriggerClientEvent('spy-bodycam:client:openRecords', src, records, offJob, isBoss) + end) +end) + +lib.addCommand('recordcam', { + help = 'Record bodycam footage.', + restricted = false +}, function(source, args, raw) + local src = source + if PlayerOnBodycam[src] then + local defwebhook + if Upload.ServiceUsed == 'discord' then + local jobKey + if Config.Framework == 'qb' then + local Player = QBCore.Functions.GetPlayer(src) + jobKey = Player.PlayerData.job.name + else + local xPlayer = ESX.GetPlayerFromId(src) + jobKey = xPlayer.getJob().name + end + if Upload.JobUploads[jobKey] then + defwebhook = Upload.JobUploads[jobKey].webhook + else + defwebhook = Upload.DefaultUploads.webhook + end + elseif Upload.ServiceUsed == 'fivemanage' or Upload.ServiceUsed == 'fivemerr' then + defwebhook = Upload.Token + end + TriggerClientEvent('spy-bodycam:client:startRec',src,defwebhook,Upload.ServiceUsed) + else + NotifyPlayerSv('Bodycam not turned on!','error',3000,src) + end +end) + +function NotifyPlayerSv(msg,type,time,src) + if Config.Dependency.UseNotify == 'ox' then + TriggerClientEvent('ox_lib:notify', src, { type = type or "success", title = '', description = msg, duration = time }) + elseif Config.Dependency.UseNotify == 'qb' then + TriggerClientEvent("QBCore:Notify", src, msg, type,time) + elseif Config.Dependency.UseNotify == 'esx' then + TriggerClientEvent("esx:showNotification", src, msg, type) + end +end + +-- You can remove this if u want more optimization from the script. +-- If the vehicle is deleted or send to garage it removes it from the list. +Citizen.CreateThread(function() + while true do + for entityId, _ in pairs(CarsOnBodycam) do + local veh = NetworkGetEntityFromNetworkId(entityId) + if not DoesEntityExist(veh) then + CarsOnBodycam[entityId] = nil + GlobalState.CarsOnBodycam = CarsOnBodycam + end + end + Citizen.Wait(60000) -- Wait for 1 min before checking again + end +end) + +-- Script Version Checker +local localVersion = GetResourceMetadata(GetCurrentResourceName(), 'version') +local fxManifestUrl = "https://raw.githubusercontent.com/Your-Spy/spy-bodycam/main/%5Bspy-bodycam%5D/spy-bodycam/fxmanifest.lua" + +local function extractVersion(fxManifestContent) + for line in string.gmatch(fxManifestContent, "[^\r\n]+") do + if line:find("^version%s+'(.-)'$") then + return line:match("^version%s+'(.-)'$") + end + end + return nil +end + +local function checkForUpdates() + PerformHttpRequest(fxManifestUrl, function(statusCode, response, headers) + print([[^4 +╔───────────────────────────────────────────────────────────────────────╗ + ____ ______ __ ____ ___ ______ ______ _ __ __ + / ___|| _ \ \ / / | __ ) / _ \| _ \ \ / / ___| / \ | \/ | + \___ \| |_) \ V / _____ | _ \| | | | | | \ V / | / _ \ | |\/| | + ___) | __/ | | |_____| | |_) | |_| | |_| || || |___ / ___ \| | | | + |____/|_| |_| |____/ \___/|____/ |_| \____/_/ \_\_| |_| + +╚───────────────────────────────────────────────────────────────────────╝ + ]]) + if statusCode == 200 then + local remoteVersion = extractVersion(response) + if remoteVersion and remoteVersion ~= localVersion then + print("^2NEW UPDATE: ^2" .. remoteVersion .. "^3 | ^1CURRENT: " .. localVersion.." ^9>> Download new version from github") + else + print("^2You are on latest version: ^2" .. localVersion) + end + else + print("^1Failed to check for updates. Status code: " .. statusCode) + end + end, "GET", "", {["Content-Type"] = "text/plain"}) +end + +AddEventHandler('onResourceStart', function(resourceName) + if GetCurrentResourceName() == resourceName then + checkForUpdates() + end +end) + diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/server/upload_config.lua b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/server/upload_config.lua new file mode 100644 index 000000000..686be0e1a --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/server/upload_config.lua @@ -0,0 +1,32 @@ +Upload = Upload or {} + +-- U have to start the recording using /recordcam and the recording will be uploaded to any of the service below. + +Upload.ServiceUsed = 'fivemanage' -- discord | fivemanage | fivemerr +Upload.Token = 'c6sTqXXzOJksi7hKs0vMFuN8yUmJfcb1' -- fivemanage or fivemerr | [*note - for discord webhook is to be changed below not here] + +-- FOR DISCORD LOGS +Upload.DiscordLogs = { + Enabled = false, + Username = 'Spy Bodycam Records', -- Bot Username + Title = 'Bodycam Records', -- Message Title +} + +-- Upload Hooks if Upload.ServiceUsed = discord +Upload.DefaultUploads = { -- Default Upload of log if job not mentioned in Upload.JobUploads. + webhook = 'YOUR_WEBHOOK', + author = { + name = "Spy Bodycam", + icon_url = "https://i.imgur.com/tMyAdkz.png" + } +} + +Upload.JobUploads = { -- Job Speific Uploads + ['police'] = { + webhook = 'YOUR_WEBHOOK', + author = { + name = "Police Department", + icon_url = "https://i.imgur.com/tMyAdkz.png" + } + }, -- Add more here +} diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/audio/off_sound.mp3 b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/audio/off_sound.mp3 new file mode 100644 index 000000000..d2f7cfdd7 Binary files /dev/null and b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/audio/off_sound.mp3 differ diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/audio/on_sound.mp3 b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/audio/on_sound.mp3 new file mode 100644 index 000000000..29e2cbc92 Binary files /dev/null and b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/audio/on_sound.mp3 differ diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/images/brand_logo.png b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/images/brand_logo.png new file mode 100644 index 000000000..8eef6d556 Binary files /dev/null and b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/images/brand_logo.png differ diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/index.html b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/index.html new file mode 100644 index 000000000..23ade29bb --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/index.html @@ -0,0 +1,87 @@ + + + + + + Spy Bodycam + + + + + +
+
+
+
08-04 23:58:45-0500
+
BODY 22 X6070511N
+
(222) Spy Dev
+
+ +
+
+
+
+
+
Recording Started
+
+
+
+
+
+ + Bodycam +
+ Plate : 726G21 +
+ Car : Crown Vic +
+
+
+
E
+
+
+
+
+
+
Bodycam Recordings
+
POLICE DATABASE
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+

Are you sure?

+
+
Yes
+
No
+
+
+
+ + + + + + \ No newline at end of file diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/app.js b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/app.js new file mode 100644 index 000000000..ff0b16b3d --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/app.js @@ -0,0 +1,394 @@ +import { GameView } from './gameview.js'; +const gameview = new GameView(); +let isRecording = false; +let recordingTimeout; + +$(document).ready(function () { + $('.overlayCont').hide(); + $('.currWatchCont').hide(); + $('.RecordInfo').hide(); + $('.recCont').hide(); + $('.askMain').hide(); + $('.vidplaycont').hide(); + const beepSound = document.getElementById('beep-sound'); + const offSound = document.getElementById('off-sound'); + + function updateTime() { + const date = new Date(); + date.setUTCHours(date.getUTCHours() - 5); + + const month = ("0" + (date.getMonth() + 1)).slice(-2); + const day = ("0" + date.getDate()).slice(-2); + const hours = ("0" + date.getHours()).slice(-2); + const minutes = ("0" + date.getMinutes()).slice(-2); + const seconds = ("0" + date.getSeconds()).slice(-2); + + const gameTime = `${month}-${day} ${hours}:${minutes}:${seconds}-0500`; + + $('.bodyDate').html('' + gameTime); + } + + let interval; + + window.addEventListener('message', function (event) { + const data = event.data; + if (data.action === 'open') { + updateTime(); + interval = setInterval(updateTime, 1000); + $('.bodyNum').text(data.bodyname); + $('.bodyCallsign').text(data.callsign); + $('.overlayCont').removeClass('popOut').addClass('popIn').show(); + beepSound.play(); + } else if (data.action === 'close') { + clearInterval(interval); + $('.overlayCont').removeClass('popIn').addClass('popOut').one('animationend', function () { + $(this).hide(); + $(this).removeClass('popOut'); + }); + offSound.play(); + } + if (data.action === 'openWatch') { + let typeCam; + let plateText; + let carText; + + if (data.debug) { + var controlsHtml = ` + Controls +
+ W -> Up +
+ S -> Down +
+ A -> Left +
+ D -> Right +
+ Q -> Forward +
+ E -> Backward + `; + document.querySelector('.userLaber').innerHTML = controlsHtml; + } else { + if (data.isbodycam) { + typeCam = "BODYCAM"; + plateText = "CamID: " + data.bodyId; + carText = "Name: " + data.name; + } else { + typeCam = "DASHCAM"; + plateText = "Plate: " + data.bodyId; + carText = "Car: " + data.name; + } + document.querySelector('.typeCam').textContent = typeCam; + document.querySelector('.plateText').textContent = plateText; + document.querySelector('.carText').textContent = carText; + } + $('.backInText').text(data.exitKey); + $('.currWatchCont').fadeIn(); + } else if (data.action === 'closeWatch') { + $('.currWatchCont').fadeOut(); + } + if (data.action === 'toggle_record') { + clearTimeout(recordingTimeout); + if (!isRecording) { + // Start recording + isRecording = true; + $('.HeadText').html('' + 'Recording Started'); + $('.RecordInfo').fadeIn(); + startRecording(data.hook, data.service); + recordingTimeout = setTimeout(() => { + if (isRecording) { + // Stop recording automatically after 30 seconds + isRecording = false; + $('.HeadText').html('' + 'Recording Stopped'); + setTimeout(() => { + $('.RecordInfo').fadeOut(); + }, 2000); + stopRecording(); + } + }, data.recTiming * 1000); + } else { + // Stop recording + isRecording = false; + $('.HeadText').html('' + 'Recording Stopped'); + clearTimeout(recordingTimeout); + setTimeout(() => { + $('.RecordInfo').fadeOut(); + }, 2000); + stopRecording(); + } + } + if (data.action === 'cancel_rec_force') { + if (isRecording) { + // Force stop recording + isRecording = false; + $('.HeadText').html('' + 'Recording Stopped'); + clearTimeout(recordingTimeout); + setTimeout(() => { + $('.RecordInfo').fadeOut(); + }, 1000); + stopRecording(); + } + } + + // RECORDS SHOWING + if (data.action === 'show_records') { + $('.recInnerScroll').empty(); + $('.recDesc').text(`${data.jobTitle} Database`); + + if (Array.isArray(data.recordData) && data.recordData.length > 0) { + $.each(data.recordData, function (index, record) { + var camBox = $( + ` +
+
+
${record.playername} [${record.street}]
+
Date: ${record.date}
+
+
+
+ ${data.isBoss ? `
` : ''} +
+
+ ` + ); + $('.recInnerScroll').append(camBox); + }); + $('.recCont').show(); + } else { + $('.recInnerScroll').html('

No records available

'); + $('.recCont').show(); + } + } + + // Refresh Records + if (data.action === 'refreshrec') { + $('.recInnerScroll').empty(); + if (Array.isArray(data.recordData) && data.recordData.length > 0) { + $.each(data.recordData, function (index, record) { + var camBox = $( + ` +
+
+
${record.playername} [${record.street}]
+
Date: ${record.date}
+
+
+
+ ${data.isBoss ? `
` : ''} +
+
+ ` + ); + $('.recInnerScroll').append(camBox); + }); + $('.recCont').show(); + } else { + $('.recInnerScroll').html('

No records available

'); + $('.recCont').show(); + } + } + }); + + let deleteUrl = ''; + + // SEARCH AND DATE FILTERS :) + function updateVisibility(searchText) { + $('.camBox').each(function () { + var camTitleText = $(this).find('.camTitle').text().toLowerCase(); + var camDescDate = $(this).find('.camDesc').text().trim().replace('Date: ', ''); + if ((searchText === '' || camTitleText.includes(searchText)) && + ($(this).css('display') !== 'none' || camDescDate === $('.selectedDate').val()) + ) { + $(this).show(); + } + else if ((searchText === '' || camTitleText.includes(searchText)) && + ($('.selectedDate').val() === '') + ) { + $(this).show(); + } else { + $(this).hide(); + } + }); + } + + $('.searchInput').on('input', function () { + var searchText = $(this).val().toLowerCase(); + updateVisibility(searchText); + }); + + $('.selectedDate').on('change', function () { + var selectedDate = $(this).val(); + $('.camBox').each(function () { + var camDescDate = $(this).find('.camDesc').text().trim().replace('Date: ', ''); + if (selectedDate === '') { + $(this).show(); + } else if (selectedDate === camDescDate) { + $(this).show(); + } else { + $(this).hide(); + } + }); + var searchText = $('.searchInput').val().toLowerCase(); + updateVisibility(searchText); + }); + + $(document).on('click', '.camDelete', function () { + const camBox = $(this).closest('.camBox'); + deleteUrl = camBox.find('.camShow').data('stored'); + $('.askMain').fadeIn(); + }); + + $(document).on('click', '.askBtn:nth-child(1)', function () { + $('.askMain').fadeOut(); + if (deleteUrl) { + $.post(`https://${GetParentResourceName()}/deleteVideo`, JSON.stringify({ + vidurl: deleteUrl + })); + } + }); + + $(document).on('click', '.askBtn:nth-child(2)', function () { + $('.askMain').fadeOut(); + }); + + $(document).on('click', '.camShow', function () { + var videoUrl = $(this).data('stored'); + $('.vidPlayer').attr('src', videoUrl); + $('.vidplaycont').show(); + }); + + $(document).on('click', '.vidPlayerIcon', function () { + $('.vidplaycont').hide(); + $('.vidPlayer').attr('src', ''); + }); + + $(document).on('click', function (event) { + if ($(event.target).is('.vidplaycont')) { + $('.vidplaycont').hide(); + $('.vidPlayer').attr('src', ''); + } + }); + + $(document).on('keydown', function (e) { + if (e.which === 27) { + $('.askMain').hide(); + $('.searchInput').val(''); + $('.selectedDate').val(''); + $('.recCont').hide(); + $('.vidplaycont').hide(); + $('.vidPlayer').attr('src', ''); + $.post(`https://${GetParentResourceName()}/closeRecUI`, '{}'); + } + }); +}); + +let mediaRecorder; +let audioStream; +const canvasElement = document.querySelector('canvas'); + +async function uploadBlob(videoBlob, hook, service) { + $.post(`https://${GetParentResourceName()}/exitBodyCam`, '{}'); + const formData = new FormData(); + try { + let response, responseData; + if (service === 'fivemanage') { + formData.append('video', videoBlob); + response = await fetch('https://api.fivemanage.com/api/video', { + method: 'POST', + headers: { + Authorization: hook, + }, + body: formData, + }); + if (!response.ok) { + throw new Error(`Failed to upload video to FiveManage: ${response.status}`); + } + responseData = await response.json(); + $.post(`https://${GetParentResourceName()}/videoLog`, JSON.stringify({ + vidurl: responseData.url + })); + } else if (service === 'fivemerr') { + formData.append('file', videoBlob, 'video.webm'); + response = await fetch('https://api.fivemerr.com/v1/media/videos', { + method: 'POST', + headers: { + Authorization: hook, + }, + body: formData, + }); + if (!response.ok) { + throw new Error(`Failed to upload video to Fivemerr: ${response.status}`); + } + responseData = await response.json(); + $.post(`https://${GetParentResourceName()}/videoLog`, JSON.stringify({ + vidurl: responseData.url + })); + } else if (service === 'discord') { + formData.append('file', videoBlob, 'video.webm'); + response = await fetch(hook, { + method: 'POST', + body: formData, + }); + if (!response.ok) { + throw new Error(`Failed to upload video to Discord: ${response.status}`); + } + responseData = await response.json(); + $.post(`https://${GetParentResourceName()}/videoLog`, JSON.stringify({ + vidurl: responseData.attachments[0].url + })); + } + } catch (error) { + console.error('^1[ERROR]:^3', error.message); + } +} + +async function startMicrophoneCapture() { + try { + const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + return stream; + } catch (error) { + console.error('Microphone capture failed. Recording video only.'); + return null; + } +} + +async function startRecording(hook, service) { + audioStream = await startMicrophoneCapture(); + if (!isRecording){ + if (audioStream) { + audioStream.getAudioTracks().forEach(track => track.stop()); + } + return + } + console.log('Video Recording Started'); + const gameView = gameview.createGameView(canvasElement); + const canvasStream = canvasElement.captureStream(30); + + // Combine audio and video streams + const combinedStream = new MediaStream([ + ...canvasStream.getVideoTracks(), + ...(audioStream ? audioStream.getAudioTracks() : []) + ]); + + const videoChunks = []; + window.gameView = gameView; + mediaRecorder = new MediaRecorder(combinedStream, { mimeType: 'video/webm;codecs=vp9' }); + mediaRecorder.start(); + mediaRecorder.ondataavailable = (e) => e.data.size > 0 && videoChunks.push(e.data); + mediaRecorder.onstop = async () => { + const videoBlob = new Blob(videoChunks, { type: 'video/webm' }); + if (videoBlob.size > 0) { + uploadBlob(videoBlob, hook, service); + } + if (audioStream) { + audioStream.getAudioTracks().forEach(track => track.stop()); + } + }; +} + +function stopRecording() { + if (mediaRecorder && mediaRecorder.state === 'recording') { + mediaRecorder.stop(); + } +} \ No newline at end of file diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/gameview.js b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/gameview.js new file mode 100644 index 000000000..95fe366da --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/gameview.js @@ -0,0 +1,175 @@ +export class GameView { + constructor() { + this.vertexShaderSrc = ` + attribute vec2 a_position; + attribute vec2 a_texcoord; + uniform mat3 u_matrix; + varying vec2 textureCoordinate; + void main() { + gl_Position = vec4(a_position, 0.0, 1.0); + textureCoordinate = a_texcoord; + } + `; + + this.fragmentShaderSrc = ` + varying highp vec2 textureCoordinate; + uniform sampler2D external_texture; + void main() + { + gl_FragColor = texture2D(external_texture, textureCoordinate); + } + `; + + this.interval = null; + } + + makeShader = (gl, type, src) => { + const shader = gl.createShader(type); + gl.shaderSource(shader, src); + gl.compileShader(shader); + return shader; + } + + createTexture(gl) { + const tex = gl.createTexture(); + + const texPixels = new Uint8Array([0, 0, 255, 255]); + + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.texImage2D( + gl.TEXTURE_2D, + 0, + gl.RGBA, + 1, + 1, + 0, + gl.RGBA, + gl.UNSIGNED_BYTE, + texPixels, + ); + + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + + // Magic hook sequence + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + + // Reset + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + + return tex; + } + + createBuffers = (gl) => { + const vertexBuff = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuff); + gl.bufferData( + gl.ARRAY_BUFFER, + new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), + gl.STATIC_DRAW, + ); + + const texBuff = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, texBuff); + gl.bufferData( + gl.ARRAY_BUFFER, + new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), + gl.STATIC_DRAW, + ); + + return { vertexBuff, texBuff }; + } + + createProgram = (gl) => { + const vertexShader = this.makeShader(gl, gl.VERTEX_SHADER, this.vertexShaderSrc); + const fragmentShader = this.makeShader(gl, gl.FRAGMENT_SHADER, this.fragmentShaderSrc); + + const program = gl.createProgram(); + + gl.attachShader(program, vertexShader); + gl.attachShader(program, fragmentShader); + gl.linkProgram(program); + gl.useProgram(program); + + const vloc = gl.getAttribLocation(program, 'a_position'); + const tloc = gl.getAttribLocation(program, 'a_texcoord'); + + return { program, vloc, tloc }; + } + + createStuff(gl) { + const tex = this.createTexture(gl); + const { program, vloc, tloc } = this.createProgram(gl); + const { vertexBuff, texBuff } = this.createBuffers(gl); + + gl.useProgram(program); + + gl.bindTexture(gl.TEXTURE_2D, tex); + + gl.uniform1i(gl.getUniformLocation(program, 'external_texture'), 0); + + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuff); + gl.vertexAttribPointer(vloc, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(vloc); + + gl.bindBuffer(gl.ARRAY_BUFFER, texBuff); + gl.vertexAttribPointer(tloc, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(tloc); + + gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); + } + + render(gl, gameView) { + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + gl.finish(); + + let render = () => {}; + gameView.animationFrame = requestAnimationFrame(render); + } + + createGameView = (canvas) => { + this.canvas = canvas; + const gl = this.canvas.getContext('webgl', { + antialias: false, + depth: false, + stencil: false, + alpha: false, + desynchronized: true, + failIfMajorPerformanceCaveat: false, + }); + + const gameView = { + canvas, + gl, + animationFrame: undefined, + resize: (width, height) => { + gl.viewport(0, 0, width, height); + gl.canvas.width = width; + gl.canvas.height = height; + }, + }; + + this.createStuff(gl); + + this.interval = setInterval(() => { + this.render(gl, gameView); + }, 0); + + return gameView; + } + + stop() { + if (this.canvas) { + if (this.canvas.style.display != "none") { + this.canvas.style.display = "none"; + } + + if (this.interval) { + clearInterval(this.interval); + } + } + } +} \ No newline at end of file diff --git a/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/jquery-3.7.1.min.js b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/jquery-3.7.1.min.js new file mode 100644 index 000000000..7f37b5d99 --- /dev/null +++ b/resources/[jobs]/[police]/[spy-bodycam]/spy-bodycam/web/js/jquery-3.7.1.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.7.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},C=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||C).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.1",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+ge+")"+ge+"*"),x=new RegExp(ge+"|>"),j=new RegExp(g),A=new RegExp("^"+t+"$"),D={ID:new RegExp("^#("+t+")"),CLASS:new RegExp("^\\.("+t+")"),TAG:new RegExp("^("+t+"|[*])"),ATTR:new RegExp("^"+p),PSEUDO:new RegExp("^"+g),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ge+"*(even|odd|(([+-]|)(\\d*)n|)"+ge+"*(?:([+-]|)"+ge+"*(\\d+)|))"+ge+"*\\)|)","i"),bool:new RegExp("^(?:"+f+")$","i"),needsContext:new RegExp("^"+ge+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ge+"*((?:-\\d)?\\d*)"+ge+"*\\)|)(?=[^-]|$)","i")},N=/^(?:input|select|textarea|button)$/i,q=/^h\d$/i,L=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,H=/[+~]/,O=new RegExp("\\\\[\\da-fA-F]{1,6}"+ge+"?|\\\\([^\\r\\n\\f])","g"),P=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},M=function(){V()},R=J(function(e){return!0===e.disabled&&fe(e,"fieldset")},{dir:"parentNode",next:"legend"});try{k.apply(oe=ae.call(ye.childNodes),ye.childNodes),oe[ye.childNodes.length].nodeType}catch(e){k={apply:function(e,t){me.apply(e,ae.call(t))},call:function(e){me.apply(e,ae.call(arguments,1))}}}function I(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(V(e),e=e||T,C)){if(11!==p&&(u=L.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return k.call(n,a),n}else if(f&&(a=f.getElementById(i))&&I.contains(e,a)&&a.id===i)return k.call(n,a),n}else{if(u[2])return k.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&e.getElementsByClassName)return k.apply(n,e.getElementsByClassName(i)),n}if(!(h[t+" "]||d&&d.test(t))){if(c=t,f=e,1===p&&(x.test(t)||m.test(t))){(f=H.test(t)&&U(e.parentNode)||e)==e&&le.scope||((s=e.getAttribute("id"))?s=ce.escapeSelector(s):e.setAttribute("id",s=S)),o=(l=Y(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+Q(l[o]);c=l.join(",")}try{return k.apply(n,f.querySelectorAll(c)),n}catch(e){h(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return re(t.replace(ve,"$1"),e,n,r)}function W(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function F(e){return e[S]=!0,e}function $(e){var t=T.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function B(t){return function(e){return fe(e,"input")&&e.type===t}}function _(t){return function(e){return(fe(e,"input")||fe(e,"button"))&&e.type===t}}function z(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&R(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function X(a){return F(function(o){return o=+o,F(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function U(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function V(e){var t,n=e?e.ownerDocument||e:ye;return n!=T&&9===n.nodeType&&n.documentElement&&(r=(T=n).documentElement,C=!ce.isXMLDoc(T),i=r.matches||r.webkitMatchesSelector||r.msMatchesSelector,r.msMatchesSelector&&ye!=T&&(t=T.defaultView)&&t.top!==t&&t.addEventListener("unload",M),le.getById=$(function(e){return r.appendChild(e).id=ce.expando,!T.getElementsByName||!T.getElementsByName(ce.expando).length}),le.disconnectedMatch=$(function(e){return i.call(e,"*")}),le.scope=$(function(){return T.querySelectorAll(":scope")}),le.cssHas=$(function(){try{return T.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}}),le.getById?(b.filter.ID=function(e){var t=e.replace(O,P);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(O,P);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},b.find.CLASS=function(e,t){if("undefined"!=typeof t.getElementsByClassName&&C)return t.getElementsByClassName(e)},d=[],$(function(e){var t;r.appendChild(e).innerHTML="",e.querySelectorAll("[selected]").length||d.push("\\["+ge+"*(?:value|"+f+")"),e.querySelectorAll("[id~="+S+"-]").length||d.push("~="),e.querySelectorAll("a#"+S+"+*").length||d.push(".#.+[+~]"),e.querySelectorAll(":checked").length||d.push(":checked"),(t=T.createElement("input")).setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),r.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&d.push(":enabled",":disabled"),(t=T.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||d.push("\\["+ge+"*name"+ge+"*="+ge+"*(?:''|\"\")")}),le.cssHas||d.push(":has"),d=d.length&&new RegExp(d.join("|")),l=function(e,t){if(e===t)return a=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!le.sortDetached&&t.compareDocumentPosition(e)===n?e===T||e.ownerDocument==ye&&I.contains(ye,e)?-1:t===T||t.ownerDocument==ye&&I.contains(ye,t)?1:o?se.call(o,e)-se.call(o,t):0:4&n?-1:1)}),T}for(e in I.matches=function(e,t){return I(e,null,null,t)},I.matchesSelector=function(e,t){if(V(e),C&&!h[t+" "]&&(!d||!d.test(t)))try{var n=i.call(e,t);if(n||le.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){h(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(O,P),e[3]=(e[3]||e[4]||e[5]||"").replace(O,P),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||I.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&I.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return D.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&j.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(O,P).toLowerCase();return"*"===e?function(){return!0}:function(e){return fe(e,t)}},CLASS:function(e){var t=s[e+" "];return t||(t=new RegExp("(^|"+ge+")"+e+"("+ge+"|$)"))&&s(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=I.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function T(e,n,r){return v(n)?ce.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?ce.grep(e,function(e){return e===n!==r}):"string"!=typeof n?ce.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(ce.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||k,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:S.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof ce?t[0]:t,ce.merge(this,ce.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:C,!0)),w.test(r[1])&&ce.isPlainObject(t))for(r in t)v(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=C.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(ce):ce.makeArray(e,this)}).prototype=ce.fn,k=ce(C);var E=/^(?:parents|prev(?:Until|All))/,j={children:!0,contents:!0,next:!0,prev:!0};function A(e,t){while((e=e[t])&&1!==e.nodeType);return e}ce.fn.extend({has:function(e){var t=ce(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,Ce=/^$|^module$|\/(?:java|ecma)script/i;xe=C.createDocumentFragment().appendChild(C.createElement("div")),(be=C.createElement("input")).setAttribute("type","radio"),be.setAttribute("checked","checked"),be.setAttribute("name","t"),xe.appendChild(be),le.checkClone=xe.cloneNode(!0).cloneNode(!0).lastChild.checked,xe.innerHTML="",le.noCloneChecked=!!xe.cloneNode(!0).lastChild.defaultValue,xe.innerHTML="",le.option=!!xe.lastChild;var ke={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function Se(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&fe(e,t)?ce.merge([e],n):n}function Ee(e,t){for(var n=0,r=e.length;n",""]);var je=/<|&#?\w+;/;function Ae(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function Re(e,t){return fe(e,"table")&&fe(11!==t.nodeType?t:t.firstChild,"tr")&&ce(e).children("tbody")[0]||e}function Ie(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function We(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Fe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(_.hasData(e)&&(s=_.get(e).events))for(i in _.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),C.head.appendChild(r[0])},abort:function(){i&&i()}}});var Jt,Kt=[],Zt=/(=)\?(?=&|$)|\?\?/;ce.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Kt.pop()||ce.expando+"_"+jt.guid++;return this[e]=!0,e}}),ce.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Zt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Zt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=v(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Zt,"$1"+r):!1!==e.jsonp&&(e.url+=(At.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||ce.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=ie[r],ie[r]=function(){o=arguments},n.always(function(){void 0===i?ce(ie).removeProp(r):ie[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Kt.push(r)),o&&v(i)&&i(o[0]),o=i=void 0}),"script"}),le.createHTMLDocument=((Jt=C.implementation.createHTMLDocument("").body).innerHTML="
",2===Jt.childNodes.length),ce.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(le.createHTMLDocument?((r=(t=C.implementation.createHTMLDocument("")).createElement("base")).href=C.location.href,t.head.appendChild(r)):t=C),o=!n&&[],(i=w.exec(e))?[t.createElement(i[1])]:(i=Ae([e],t,o),o&&o.length&&ce(o).remove(),ce.merge([],i.childNodes)));var r,i,o},ce.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(ce.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},ce.expr.pseudos.animated=function(t){return ce.grep(ce.timers,function(e){return t===e.elem}).length},ce.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=ce.css(e,"position"),c=ce(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=ce.css(e,"top"),u=ce.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),v(t)&&(t=t.call(e,n,ce.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},ce.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){ce.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===ce.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===ce.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=ce(e).offset()).top+=ce.css(e,"borderTopWidth",!0),i.left+=ce.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-ce.css(r,"marginTop",!0),left:t.left-i.left-ce.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===ce.css(e,"position"))e=e.offsetParent;return e||J})}}),ce.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;ce.fn[t]=function(e){return M(this,function(e,t,n){var r;if(y(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),ce.each(["top","left"],function(e,n){ce.cssHooks[n]=Ye(le.pixelPosition,function(e,t){if(t)return t=Ge(e,n),_e.test(t)?ce(e).position()[n]+"px":t})}),ce.each({Height:"height",Width:"width"},function(a,s){ce.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){ce.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return M(this,function(e,t,n){var r;return y(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?ce.css(e,t,i):ce.style(e,t,n,i)},s,n?e:void 0,n)}})}),ce.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){ce.fn[t]=function(e){return this.on(t,e)}}),ce.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)}}),ce.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){ce.fn[n]=function(e,t){return 0