diff --git a/package/client/resource/interface/skillcheck.ts b/package/client/resource/interface/skillcheck.ts index cbb5e5b..ddce631 100644 --- a/package/client/resource/interface/skillcheck.ts +++ b/package/client/resource/interface/skillcheck.ts @@ -2,3 +2,7 @@ type SkillCheckDifficulty = 'easy' | 'medium' | 'hard' | { areaSize: number; spe export const skillCheck = (difficulty: SkillCheckDifficulty | SkillCheckDifficulty[], inputs?: string[]) => exports.ox_lib.skillCheck(difficulty); + +export const skillCheckActive = (): boolean => exports.ox_lib.skillCheckActive(); + +export const cancelSkillCheck = (): void => exports.ox_lib.cancelSkillCheck(); \ No newline at end of file diff --git a/resource/interface/client/skillcheck.lua b/resource/interface/client/skillcheck.lua index b33064d..a7f3908 100644 --- a/resource/interface/client/skillcheck.lua +++ b/resource/interface/client/skillcheck.lua @@ -22,6 +22,19 @@ function lib.skillCheck(difficulty, 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) diff --git a/web/src/features/skillcheck/index.tsx b/web/src/features/skillcheck/index.tsx index 6760b56..1452360 100644 --- a/web/src/features/skillcheck/index.tsx +++ b/web/src/features/skillcheck/index.tsx @@ -80,6 +80,11 @@ const SkillCheck: React.FC = () => { setVisible(true); }); + useNuiEvent('skillCheckCancel', () => { + setVisible(false); + fetchNui('skillCheckOver', false); + }); + const handleComplete = (success: boolean) => { if (!dataRef.current) return; if (!success || !Array.isArray(dataRef.current.difficulty)) {