Domas Scripts
v1.0
Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Client
Copy Markdown
Open in ChatGPT
Open in Claude
local Framework = nil
if Config.Framework == 'esx' then
Framework = exports['es_extended']:getSharedObject()
elseif Config.Framework == 'qb' then
Framework = exports['qb-core']:GetCoreObject()
end
function 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
end
end
function 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
end
end
function 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
end
end
function Notify(text, type)
lib.notify({
title = 'Domas Scripts',
description = text,
type = type
})
end
RegisterNetEvent('Domas_Radar:Notify')
AddEventHandler('Domas_Radar:Notify', function(text, type)
Notify(text, type)
end)
-- Get player job
function 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
end
end
-- Get player grade
function 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
end
end
function 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
end
end
function 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 playerJob
end
AddEventHandler('onResourceStart', function(resourceName)
if resourceName == GetCurrentResourceName() then
InitializeCameraInteractions()
end
end)
-- Function to initiate the radar break skill check
function 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')
end
end
function 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)
end
›
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
Last updated on
Was this page helpful?
Next to read:
Servernull
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message