mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(web/skillcheck): ability to cancel skillcheck (#364)
* - (FEAT) Added feature to cancel skillcheck - (FEAT) Added feature to check is any active skillcheck * - Fix hiding UI * - return actual boolean * - Fix focus does not reset properly * Update skillcheck wrappers
This commit is contained in:
@@ -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();
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user