update
This commit is contained in:
parent
dfc233c1db
commit
caa1a1929c
19 changed files with 584 additions and 134 deletions
|
|
@ -1,23 +1,25 @@
|
|||
-- Initialize config(s)
|
||||
local sh_config = require 'config.shared'
|
||||
local shared = require 'config.shared'
|
||||
|
||||
-- Display a notification
|
||||
--- @param message string
|
||||
--- @param type string
|
||||
function ShowNotification(message, type)
|
||||
if sh_config.setup.notify == 'ox_lib' then
|
||||
lib.notify({ description = message, type = type, position = 'top', icon = 'fas fa-store' })
|
||||
elseif sh_config.setup.notify == 'esx' then
|
||||
if shared.setup.notify == 'lation_ui' then
|
||||
exports.lation_ui:notify({ title = 'Convenience Store', message = message, type = type, icon = 'fas fa-store' })
|
||||
elseif shared.setup.notify == 'ox_lib' then
|
||||
lib.notify({ description = message, type = type, icon = 'fas fa-store' })
|
||||
elseif shared.setup.notify == 'esx' then
|
||||
ESX.ShowNotification(message)
|
||||
elseif sh_config.setup.notify == 'qb' then
|
||||
elseif shared.setup.notify == 'qb' then
|
||||
QBCore.Functions.Notify(message, type)
|
||||
elseif sh_config.setup.notify == 'okok' then
|
||||
elseif shared.setup.notify == 'okok' then
|
||||
exports['okokNotify']:Alert('Convenience Store', message, 5000, type, false)
|
||||
elseif sh_config.setup.notify == 'sd-notify' then
|
||||
elseif shared.setup.notify == 'sd-notify' then
|
||||
exports['sd-notify']:Notify('Convenience Store', message, type)
|
||||
elseif sh_config.setup.notify == 'wasabi_notify' then
|
||||
elseif shared.setup.notify == 'wasabi_notify' then
|
||||
exports.wasabi_notify:notify('Convenience Store', message, 5000, type, false, 'fas fa-store')
|
||||
elseif sh_config.setup.notify == 'custom' then
|
||||
elseif shared.setup.notify == 'custom' then
|
||||
-- Add custom notification export/event here
|
||||
end
|
||||
end
|
||||
|
|
@ -32,8 +34,18 @@ end)
|
|||
-- Display a minigame
|
||||
--- @param data table
|
||||
function Minigame(data)
|
||||
if lib.skillCheck(data.difficulty, data.inputs) then
|
||||
return true
|
||||
if shared.setup.minigame == 'lation_ui' then
|
||||
if exports.lation_ui:skillCheck(nil, data.difficulty, data.inputs) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
elseif shared.setup.minigame == 'ox_lib' then
|
||||
if lib.skillCheck(data.difficulty, data.inputs) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
elseif shared.setup.minigame == 'custom' then
|
||||
-- Add your custom minigame here
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
|
@ -41,7 +53,31 @@ end
|
|||
-- Display a progress bar
|
||||
--- @param data table
|
||||
function ProgressBar(data)
|
||||
if sh_config.setup.progress == 'ox_lib' then
|
||||
if shared.setup.progress == 'lation_ui' then
|
||||
if exports.lation_ui:progressBar({
|
||||
label = data.label,
|
||||
description = data.description or nil,
|
||||
icon = data.icon or nil,
|
||||
duration = data.duration,
|
||||
useWhileDead = data.useWhileDead,
|
||||
canCancel = data.canCancel,
|
||||
disable = data.disable,
|
||||
anim = {
|
||||
dict = data.anim.dict or nil,
|
||||
clip = data.anim.clip or nil,
|
||||
flag = data.anim.flag or nil
|
||||
},
|
||||
prop = {
|
||||
model = data.prop.model or nil,
|
||||
bone = data.prop.bone or nil,
|
||||
pos = data.prop.pos or nil,
|
||||
rot = data.prop.rot or nil
|
||||
}
|
||||
}) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
elseif shared.setup.progress == 'ox_lib' then
|
||||
-- Want to use ox_lib's progress circle instead of bar?
|
||||
-- Change "progressBar" to "progressCircle" below & done!
|
||||
if lib.progressBar({
|
||||
|
|
@ -66,7 +102,7 @@ function ProgressBar(data)
|
|||
return true
|
||||
end
|
||||
return false
|
||||
elseif sh_config.setup.progress == 'qbcore' then
|
||||
elseif shared.setup.progress == 'qbcore' then
|
||||
local p = promise.new()
|
||||
QBCore.Functions.Progressbar(data.label, data.label, data.duration, data.useWhileDead, data.canCancel, {
|
||||
disableMovement = data.disable.move,
|
||||
|
|
@ -95,18 +131,47 @@ function ProgressBar(data)
|
|||
end
|
||||
end
|
||||
|
||||
-- Display an alert dialog
|
||||
--- @param data table
|
||||
function ShowAlert(data)
|
||||
if shared.setup.dialogs == 'lation_ui' then
|
||||
return exports.lation_ui:alert(data)
|
||||
elseif shared.setup.dialogs == 'ox_lib' then
|
||||
return lib.alertDialog(data)
|
||||
elseif shared.setup.dialogs == 'custom' then
|
||||
-- Add your custom alert dialog here
|
||||
end
|
||||
end
|
||||
|
||||
function ShowInput(data)
|
||||
if shared.setup.dialogs == 'lation_ui' then
|
||||
return exports.lation_ui:input({
|
||||
title = data.title,
|
||||
subtitle = data.subtitle,
|
||||
submitText = data.submitText,
|
||||
cancelText = data.cancelText,
|
||||
type = data.type,
|
||||
options = data.options
|
||||
})
|
||||
elseif shared.setup.dialogs == 'ox_lib' then
|
||||
return lib.inputDialog(data.title, data.options)
|
||||
elseif shared.setup.dialogs == 'custom' then
|
||||
-- Add your custom input dialog here
|
||||
end
|
||||
end
|
||||
|
||||
-- Send police dispatch message
|
||||
--- @param data table data.coords, data.street
|
||||
function PoliceDispatch(data)
|
||||
if not data then print('^1[ERROR]: Failed to retrieve dispatch data, cannot proceed^0') return end
|
||||
if sh_config.police.dispatch == 'cd_dispatch' then
|
||||
if shared.police.dispatch == 'cd_dispatch' then
|
||||
local playerData = exports['cd_dispatch']:GetPlayerInfo()
|
||||
if not playerData then
|
||||
print('^1[ERROR]: cd_dispatch failed to return playerData, cannot proceed^0')
|
||||
return
|
||||
end
|
||||
TriggerServerEvent('cd_dispatch:AddNotification', {
|
||||
job_table = sh_config.police.jobs,
|
||||
job_table = shared.police.jobs,
|
||||
coords = playerData.coords,
|
||||
title = '10-88 - Store Robbery',
|
||||
message = 'An alarm has been triggered at 24/7 on ' ..playerData.street,
|
||||
|
|
@ -123,7 +188,7 @@ function PoliceDispatch(data)
|
|||
radius = 0,
|
||||
}
|
||||
})
|
||||
elseif sh_config.police.dispatch == 'ps-dispatch' then
|
||||
elseif shared.police.dispatch == 'ps-dispatch' then
|
||||
local alert = {
|
||||
coords = data.coords,
|
||||
message = 'An alarm has been triggered at 24/7 on ' ..data.street,
|
||||
|
|
@ -136,7 +201,7 @@ function PoliceDispatch(data)
|
|||
length = 3
|
||||
}
|
||||
exports["ps-dispatch"]:CustomAlert(alert)
|
||||
elseif sh_config.police.dispatch == 'qs-dispatch' then
|
||||
elseif shared.police.dispatch == 'qs-dispatch' then
|
||||
local playerData = exports['qs-dispatch']:GetPlayerInfo()
|
||||
if not playerData then
|
||||
print('^1[ERROR]: qs-dispatch failed to return playerData, cannot proceed^0')
|
||||
|
|
@ -144,7 +209,7 @@ function PoliceDispatch(data)
|
|||
end
|
||||
exports['qs-dispatch']:getSSURL(function(image)
|
||||
TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', {
|
||||
job = sh_config.police.jobs,
|
||||
job = shared.police.jobs,
|
||||
callLocation = playerData.coords,
|
||||
callCode = { code = '10-88', snippet = 'Store Robbery' },
|
||||
message = 'An alarm has been triggered at 24/7 on ' ..playerData.street_1,
|
||||
|
|
@ -160,13 +225,13 @@ function PoliceDispatch(data)
|
|||
}
|
||||
})
|
||||
end)
|
||||
elseif sh_config.police.dispatch == 'core_dispatch' then
|
||||
elseif shared.police.dispatch == 'core_dispatch' then
|
||||
local gender = IsPedMale(cache.ped) and 'male' or 'female'
|
||||
TriggerServerEvent('core_dispatch:addCall', '10-88', 'Potential Store Robbery',
|
||||
{{icon = 'fa-venus-mars', info = gender}},
|
||||
{data.coords.x, data.coords.y, data.coords.z},
|
||||
'police', 30000, 52, 1, false)
|
||||
elseif sh_config.police.dispatch == 'rcore_dispatch' then
|
||||
elseif shared.police.dispatch == 'rcore_dispatch' then
|
||||
local playerData = exports['rcore_dispatch']:GetPlayerData()
|
||||
if not playerData then
|
||||
print('^1[ERROR]: rcore_dispatch failed to return playerData, cannot proceed^0')
|
||||
|
|
@ -176,7 +241,7 @@ function PoliceDispatch(data)
|
|||
code = '10-88 - Store Robbery',
|
||||
default_priority = 'low',
|
||||
coords = playerData.coords,
|
||||
job = sh_config.police.jobs,
|
||||
job = shared.police.jobs,
|
||||
text = 'An alarm has been triggered at 24/7 on ' ..playerData.street_1,
|
||||
type = 'alerts',
|
||||
blip_time = 30,
|
||||
|
|
@ -190,9 +255,9 @@ function PoliceDispatch(data)
|
|||
}
|
||||
}
|
||||
TriggerServerEvent('rcore_dispatch:server:sendAlert', alert)
|
||||
elseif sh_config.police.dispatch == 'aty_dispatch' then
|
||||
TriggerEvent('aty_dispatch:SendDispatch', 'Potential Store Robbery', '10-88', 52, sh_config.police.jobs)
|
||||
elseif sh_config.police.dispatch == 'op-dispatch' then
|
||||
elseif shared.police.dispatch == 'aty_dispatch' then
|
||||
TriggerEvent('aty_dispatch:SendDispatch', 'Potential Store Robbery', '10-88', 52, shared.police.jobs)
|
||||
elseif shared.police.dispatch == 'op-dispatch' then
|
||||
local job = 'police'
|
||||
local text = 'An alarm has been triggered at 24/7 on ' ..data.street
|
||||
local coords = data.coords
|
||||
|
|
@ -200,7 +265,7 @@ function PoliceDispatch(data)
|
|||
local title = '10-88 - Store Robbery'
|
||||
local panic = false
|
||||
TriggerServerEvent('Opto_dispatch:Server:SendAlert', job, title, text, coords, panic, id)
|
||||
elseif sh_config.police.dispatch == 'origen_police' then
|
||||
elseif shared.police.dispatch == 'origen_police' then
|
||||
local alert = {
|
||||
coords = data.coords,
|
||||
title = '10-88 - Store Robbery',
|
||||
|
|
@ -209,9 +274,9 @@ function PoliceDispatch(data)
|
|||
job = 'police',
|
||||
}
|
||||
TriggerServerEvent("SendAlert:police", alert)
|
||||
elseif sh_config.police.dispatch == 'emergencydispatch' then
|
||||
elseif shared.police.dispatch == 'emergencydispatch' then
|
||||
TriggerServerEvent('emergencydispatch:emergencycall:new', 'police', '10-88 | Potential Store Robbery', data.coords, true)
|
||||
elseif sh_config.police.dispatch == 'custom' then
|
||||
elseif shared.police.dispatch == 'custom' then
|
||||
-- Add your custom dispatch system here
|
||||
else
|
||||
print('^1[ERROR]: No dispatch system was detected - please visit config/shared.lua "police" section^0')
|
||||
|
|
@ -221,23 +286,23 @@ end
|
|||
-- Add circle target zones
|
||||
--- @param data table
|
||||
function AddCircleZone(data)
|
||||
if sh_config.setup.interact == 'ox_target' then
|
||||
if shared.setup.interact == 'ox_target' then
|
||||
exports.ox_target:addSphereZone(data)
|
||||
elseif sh_config.setup.interact == 'qb-target' then
|
||||
elseif shared.setup.interact == 'qb-target' then
|
||||
exports['qb-target']:AddCircleZone(data.name, data.coords, data.radius, {
|
||||
name = data.name,
|
||||
debugPoly = sh_config.setup.debug}, {
|
||||
debugPoly = shared.setup.debug}, {
|
||||
options = data.options,
|
||||
distance = 2,
|
||||
})
|
||||
elseif sh_config.setup.interact == 'interact' then
|
||||
elseif shared.setup.interact == 'interact' then
|
||||
exports.interact:AddInteraction({
|
||||
coords = data.coords,
|
||||
interactDst = 2.0,
|
||||
id = data.name,
|
||||
options = data.options
|
||||
})
|
||||
elseif sh_config.setup.interact == 'custom' then
|
||||
elseif shared.setup.interact == 'custom' then
|
||||
-- Add support for a custom target system here
|
||||
else
|
||||
print('^1[ERROR]: No interaction system was detected - please visit config/shared "setup" section^0')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- Initialize config(s)
|
||||
local sh_config = require 'config.shared'
|
||||
local cl_config = require 'config.client'
|
||||
local shared = require 'config.shared'
|
||||
local client = require 'config.client'
|
||||
local icons = require 'config.icons'
|
||||
|
||||
-- Initialize variables to track active locations
|
||||
|
|
@ -16,8 +16,8 @@ local wrongPIN, failedHack = 0, 0
|
|||
local questionData = {}
|
||||
|
||||
-- Build the input dialog for questionnaire if applicable
|
||||
if sh_config.computers.questionnaire then
|
||||
for _, question in ipairs(sh_config.questionnaire.questions) do
|
||||
if shared.computers.questionnaire then
|
||||
for _, question in ipairs(shared.questionnaire.questions) do
|
||||
questionData[#questionData + 1] = {
|
||||
type = question.type,
|
||||
label = question.label,
|
||||
|
|
@ -34,9 +34,9 @@ end
|
|||
-- Used to check if the answers submitted are correct
|
||||
--- @param answers table
|
||||
local function AreAnswersCorrect(answers)
|
||||
for question, answer in ipairs(sh_config.questionnaire.answers) do
|
||||
for question, answer in ipairs(shared.questionnaire.answers) do
|
||||
local submitted_answer = answers[question]
|
||||
if sh_config.questionnaire.questions[question].type == 'select' then
|
||||
if shared.questionnaire.questions[question].type == 'select' then
|
||||
if tonumber(submitted_answer) ~= answer then
|
||||
return false
|
||||
end
|
||||
|
|
@ -53,11 +53,11 @@ end
|
|||
local function InitiateRegisterRobbery()
|
||||
local canStart = lib.callback.await('lation_247robbery:StartRobbery', false)
|
||||
if not canStart then activeRegister = false return end
|
||||
local dict, anim = cl_config.anims.lockpick.dict, cl_config.anims.lockpick.clip
|
||||
local dict, anim = client.anims.lockpick.dict, client.anims.lockpick.clip
|
||||
lib.requestAnimDict(dict)
|
||||
while not HasAnimDictLoaded(dict) do Wait(0) end
|
||||
TaskPlayAnim(cache.ped, dict, anim, 8.0, 8.0, -1, 51, 1.0, false, false, false)
|
||||
local skillcheck = Minigame(sh_config.registers.minigame)
|
||||
local skillcheck = Minigame(shared.registers.minigame)
|
||||
ClearPedTasks(cache.ped)
|
||||
if not skillcheck then
|
||||
TriggerServerEvent('lation_247robbery:DoesLockpickBreak')
|
||||
|
|
@ -70,15 +70,16 @@ local function InitiateRegisterRobbery()
|
|||
street = GetStreetNameFromHashKey(GetStreetNameAtCoord(coords.x, coords.y, coords.z))
|
||||
}
|
||||
PoliceDispatch(data)
|
||||
if ProgressBar(cl_config.anims.register) then
|
||||
if ProgressBar(client.anims.register) then
|
||||
local codeChance = math.random(100)
|
||||
if codeChance <= sh_config.registers.noteChance then
|
||||
if codeChance <= shared.registers.noteChance then
|
||||
local generatedCode = math.random(1111, 9999)
|
||||
if safePin then safePin = nil end
|
||||
safePin = generatedCode
|
||||
local note = lib.alertDialog({
|
||||
local note = ShowAlert({
|
||||
header = locale('alerts.note.header'),
|
||||
content = locale('alerts.note.content', safePin),
|
||||
icon = icons.received_pin,
|
||||
centered = true,
|
||||
cancel = false,
|
||||
})
|
||||
|
|
@ -99,7 +100,7 @@ end
|
|||
-- Function to handle hacking the computer if required
|
||||
local function InitiateComputerHack()
|
||||
activeComputer = false -- Deactive target
|
||||
if failedHack >= sh_config.computers.maxAttempts then
|
||||
if failedHack >= shared.computers.maxAttempts then
|
||||
activeRegister = false
|
||||
activeComputer = false
|
||||
failedHack = 0
|
||||
|
|
@ -107,12 +108,12 @@ local function InitiateComputerHack()
|
|||
TriggerServerEvent('lation_247robbery:FailedRobbery')
|
||||
return
|
||||
end
|
||||
local dict, anim = cl_config.anims.hackPC.dict, cl_config.anims.hackPC.clip
|
||||
local dict, anim = client.anims.hackPC.dict, client.anims.hackPC.clip
|
||||
lib.requestAnimDict(dict)
|
||||
while not HasAnimDictLoaded(dict) do Wait(0) end
|
||||
TaskPlayAnim(cache.ped, dict, anim, 8.0, 8.0, -1, 1, 1, false, false, false)
|
||||
if sh_config.computers.questionnaire then
|
||||
local questions = lib.inputDialog(locale('inputs.questions.header'), questionData)
|
||||
if shared.computers.questionnaire then
|
||||
local questions = ShowInput({ title = locale('inputs.questions.header'), options = questionData })
|
||||
if not questions then
|
||||
activeComputer = true
|
||||
ClearPedTasks(cache.ped)
|
||||
|
|
@ -124,9 +125,10 @@ local function InitiateComputerHack()
|
|||
local generatedCode = math.random(1111, 9999)
|
||||
if safePin then safePin = nil end
|
||||
safePin = generatedCode
|
||||
lib.alertDialog({
|
||||
ShowAlert({
|
||||
header = locale('alerts.hack.header'),
|
||||
content = locale('alerts.hack.content', safePin),
|
||||
icon = icons.received_pin,
|
||||
centered = true,
|
||||
cancel = false
|
||||
})
|
||||
|
|
@ -138,7 +140,7 @@ local function InitiateComputerHack()
|
|||
ShowNotification(locale('notify.failed-hack'), 'error')
|
||||
end
|
||||
else
|
||||
local skillcheck = Minigame(sh_config.computers.minigame)
|
||||
local skillcheck = Minigame(shared.computers.minigame)
|
||||
if not skillcheck then
|
||||
ClearPedTasks(cache.ped)
|
||||
activeComputer = true
|
||||
|
|
@ -151,9 +153,10 @@ local function InitiateComputerHack()
|
|||
local generatedCode = math.random(1111, 9999)
|
||||
if safePin then safePin = nil end
|
||||
safePin = generatedCode
|
||||
lib.alertDialog({
|
||||
ShowAlert({
|
||||
header = locale('alerts.hack.header'),
|
||||
content = locale('alerts.hack.content', safePin),
|
||||
icon = icons.received_pin,
|
||||
centered = true,
|
||||
cancel = false
|
||||
})
|
||||
|
|
@ -164,7 +167,7 @@ end
|
|||
-- Function to handle the safe robbery
|
||||
local function InitiateSafeRobbery()
|
||||
activeSafe = false
|
||||
if wrongPIN >= sh_config.safes.maxAttempts then
|
||||
if wrongPIN >= shared.safes.maxAttempts then
|
||||
activeRegister = false
|
||||
activeSafe = false
|
||||
wrongPIN = 0
|
||||
|
|
@ -172,14 +175,17 @@ local function InitiateSafeRobbery()
|
|||
TriggerServerEvent('lation_247robbery:FailedRobbery')
|
||||
return
|
||||
end
|
||||
local inputCode = lib.inputDialog(locale('inputs.safe.header'), {
|
||||
{
|
||||
type = 'input',
|
||||
label = locale('inputs.safe.label'),
|
||||
description = locale('inputs.safe.desc'),
|
||||
placeholder = locale('inputs.safe.placeholder'),
|
||||
icon = icons.safe_pin,
|
||||
required = true
|
||||
local inputCode = ShowInput({
|
||||
title = locale('inputs.safe.header'),
|
||||
options = {
|
||||
{
|
||||
type = 'input',
|
||||
label = locale('inputs.safe.label'),
|
||||
description = locale('inputs.safe.desc'),
|
||||
placeholder = locale('inputs.safe.placeholder'),
|
||||
icon = icons.safe_pin,
|
||||
required = true
|
||||
}
|
||||
}
|
||||
})
|
||||
if not inputCode then activeSafe = true return end
|
||||
|
|
@ -191,7 +197,7 @@ local function InitiateSafeRobbery()
|
|||
elseif convertedCode == safePin then
|
||||
activeSafe = false
|
||||
wrongPIN = 0
|
||||
if ProgressBar(cl_config.anims.safe) then
|
||||
if ProgressBar(client.anims.safe) then
|
||||
activeRegister = false
|
||||
TriggerServerEvent('lation_247robbery:CompleteSafeRobbery')
|
||||
safePin = nil
|
||||
|
|
@ -211,7 +217,7 @@ AddEventHandler('lation_247robbery:onPlayerLoaded', function()
|
|||
name = 'cash_register' ..key,
|
||||
coords = coord,
|
||||
radius = 0.35,
|
||||
debug = sh_config.setup.debug,
|
||||
debug = shared.setup.debug,
|
||||
options = {
|
||||
{
|
||||
label = locale('target.register'),
|
||||
|
|
@ -242,7 +248,7 @@ AddEventHandler('lation_247robbery:onPlayerLoaded', function()
|
|||
name = 'computer' ..key,
|
||||
coords = coord,
|
||||
radius = 0.35,
|
||||
debug = sh_config.setup.debug,
|
||||
debug = shared.setup.debug,
|
||||
options = {
|
||||
{
|
||||
label = locale('target.computer'),
|
||||
|
|
@ -267,7 +273,7 @@ AddEventHandler('lation_247robbery:onPlayerLoaded', function()
|
|||
name = 'safe' ..key,
|
||||
coords = coord,
|
||||
radius = 0.45,
|
||||
debug = sh_config.setup.debug,
|
||||
debug = shared.setup.debug,
|
||||
options = {
|
||||
{
|
||||
label = locale('target.safe'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue