Client
x
local Framework = nilif Config.Framework == 'esx' then Framework = exports['es_extended']:getSharedObject()elseif Config.Framework == 'qb' then Framework = exports['qb-core']:GetCoreObject()endfunction ProgressBar() if lib.progressCircle({ duration = 3000, position = 'bottom', useWhileDead = false, canCancel = true, disable = { car = true, }, anim = { dict = 'mp_player_intdrink', clip = 'loop_bottle' } }) then return true else return false endendfunction CreateSpeedRadarBlips() for _, radar in pairs(Config.MomentalSpeedRadars) do if radar.blip.enabled then local blip = AddBlipForCoord(radar.coords) SetBlipSprite(blip, radar.blip.sprite) -- Set the blip icon SetBlipColour(blip, radar.blip.color) -- Set the blip color SetBlipScale(blip, radar.blip.size) -- Set the blip size SetBlipAsShortRange(blip, true) -- Make the blip short range BeginTextCommandSetBlipName("STRING") AddTextComponentString("<font face=\'Roboto\'>"..radar.blip.label) -- Delete this to use native font --AddTextComponentString(radar.blip.label) -- Set the blip label -- Uncomment this to use native font EndTextCommandSetBlipName(blip) end endendfunction CreateAverageZoneRadarBlips() for _, radar in pairs(Config.AverageZoneRadars) do if radar.blip and radar.blip.enabled then local blip = AddBlipForCoord(radar.blip.coords) SetBlipSprite(blip, radar.blip.sprite) SetBlipDisplay(blip, 4) SetBlipScale(blip, radar.blip.size) SetBlipColour(blip, radar.blip.color) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") AddTextComponentString("<font face=\'Roboto\'>"..radar.blip.label) -- Delete this to use native font --AddTextComponentString(radar.blip.label) -- Set the blip label -- Uncomment this to use native font EndTextCommandSetBlipName(blip) end endendfunction Notify(text, type) lib.notify({ title = 'Domas Scripts', description = text, type = type })endRegisterNetEvent('Domas_Radar:Notify')AddEventHandler('Domas_Radar:Notify', function(text, type) Notify(text, type)end)-- Get player jobfunction getPlayerJob() if Config.Framework == 'esx' then local xPlayer = Framework.GetPlayerData() Debug(xPlayer.job.name) return xPlayer.job.name elseif Config.Framework == 'qb' then local playerData = Framework.Functions.GetPlayerData() Debug(playerData.job.name) return playerData.job.name else return nil endend-- Get player gradefunction getPlayerGrade() if Config.Framework == 'esx' then local xPlayer = Framework.GetPlayerData() return xPlayer.job.grade -- Return the job grade elseif Config.Framework == 'qb' then local playerData = Framework.Functions.GetPlayerData() return playerData.job.grade.level else return nil endendfunction InitializeCameraInteractions() Debug('Creating interactions') for id, radar in pairs(Config.MomentalSpeedRadars) do -- Ensure interactions are enabled for the radar if radar.interaction then -- Define interaction coordinates (fallback to radar.coords if prop coordinates are not available) local interactionCoords = radar.prop.coords and vector3(radar.prop.coords.x, radar.prop.coords.y, radar.prop.coords.z) or radar.coords -- Add the target zone for interactions exports.ox_target:addBoxZone({ coords = interactionCoords, size = vec3(1.0, 1.0, 3.0), rotation = radar.prop.coords and radar.prop.coords.w, debug = Config.Debug, -- Enable debug if necessary options = { -- Break Camera option (available to all players) { name = 'break_camera_' .. id, label = 'Break Radar', icon = 'fas fa-bolt', -- Icon for breaking radar canInteract = function(entity, distance, data) -- Check if breakable is enabled for the camera return radar.interaction.breakable.enable end, onSelect = function(data) BreakRadar(id) -- Call function to break the radar end, }, -- Access Camera option (only for players who meet job/grade criteria) { name = 'access_camera_' .. id, label = 'Access Radar', icon = 'fas fa-camera', -- Icon for accessing radar canInteract = function(entity, distance, data) -- Only allow if access is enabled and the player meets job/grade local playerJob = GetPlayerJob() -- Fetch player's job and grade return radar.interaction.access.enabled and playerJob.name == next(radar.interaction.access.jobs) and playerJob.grade >= radar.interaction.access.jobs[next(radar.interaction.access.jobs)] end, onSelect = function(data) AccessRadar(id) -- Call function to access the radar end, }, }, }) end endendfunction GetPlayerJob() local PlayerData = Framework.Functions.GetPlayerData() local playerJob = { name = PlayerData.job.name, -- Player's job name grade = PlayerData.job.grade.level, -- Player's job grade level } return playerJobendAddEventHandler('onResourceStart', function(resourceName) if resourceName == GetCurrentResourceName() then InitializeCameraInteractions() endend)-- Function to initiate the radar break skill checkfunction BreakRadar(id) -- Set up the skill check with different difficulty levels local success = lib.skillCheck({ 'hard', -- First level (easy difficulty) 'hard', -- Second level (easy difficulty) {areaSize = 60, speedMultiplier = 2.0}, -- Third level (medium difficulty with custom parameters) 'hard' -- Fourth level (hard difficulty) }, {'w', 'w', 'w', 'w'}) -- Player inputs: 'w', 'a', 's', 'd' for movement keys -- Check if the skill check was successful if success then -- If the player passed all levels of the skill check, trigger the server event to break the radar TriggerServerEvent('radar:break', id) else -- If the player failed the skill check, print a failure message (optional) Notify("Skill check failed! Radar not broken.", 'error') endendfunction AccessRadar(radarId) -- Show the main menu with options when radar is accessed local options = { { title = 'Review Recent Data', icon = 'fas fa-search', onSelect = function() TriggerServerEvent('Domas:ReviewRecentData', radarId, cache.serverId) end, }, { title = 'Toggle Radar Off/On', icon = 'fas fa-power-off', onSelect = function() TriggerServerEvent('Domas:ToggleRadar', radarId, cache.serverId) end, }, } -- Register the context menu with the options lib.registerContext({ id = 'radar_main_menu_' .. radarId, title = 'Radar Options', options = options, }) -- Show the context menu to the player lib.showContext('radar_main_menu_' .. radarId)endWas this page helpful?