1
0
Fork 0
forked from Simnation/Main
Main/resources/[standalone]/ox_lib/resource/interface/client/skillcheck.lua

56 lines
1.2 KiB
Lua
Raw Normal View History

2025-06-07 08:51:21 +02:00
--[[
https://github.com/overextended/ox_lib
This file is licensed under LGPL-3.0 or higher <https://www.gnu.org/licenses/lgpl-3.0.en.html>
Copyright © 2025 Linden <https://github.com/thelindat>
]]
---@type promise?
local skillcheck
---@alias SkillCheckDifficulity 'easy' | 'medium' | 'hard' | { areaSize: number, speedMultiplier: number }
---@param difficulty SkillCheckDifficulity | SkillCheckDifficulity[]
---@param inputs string[]?
---@return boolean?
function lib.skillCheck(difficulty, inputs)
if skillcheck then return end
skillcheck = promise:new()
lib.setNuiFocus(false, true)
SendNUIMessage({
action = 'startSkillCheck',
data = {
difficulty = difficulty,
inputs = inputs
}
})
return Citizen.Await(skillcheck)
end
function lib.cancelSkillCheck()
if not skillcheck then
error('No skillCheck is active')
end
SendNUIMessage({action = 'skillCheckCancel'})
end
---@return boolean
function lib.skillCheckActive()
return skillcheck ~= nil
end
RegisterNUICallback('skillCheckOver', function(success, cb)
cb(1)
if skillcheck then
lib.resetNuiFocus()
skillcheck:resolve(success)
skillcheck = nil
end
end)