mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 07:26:02 +01:00
chore(interface/skillcheck): types
This commit is contained in:
@@ -1,19 +1,32 @@
|
|||||||
|
---@type promise?
|
||||||
local skillcheck
|
local skillcheck
|
||||||
local gameCount = 0
|
local gameCount = 0
|
||||||
|
|
||||||
|
---@alias SkillCheckDifficulity 'easy' | 'medium' | 'hard' | { areaSize: number, speedMultiplier: number }
|
||||||
|
|
||||||
|
---@type SkillCheckDifficulity | SkillCheckDifficulity[]
|
||||||
local gameDifficulty
|
local gameDifficulty
|
||||||
|
|
||||||
|
---@type promise?
|
||||||
local gamePromise
|
local gamePromise
|
||||||
|
|
||||||
local function resolveSkillCheck(success)
|
local function resolveSkillCheck(success)
|
||||||
skillcheck:resolve(success)
|
if skillcheck then
|
||||||
skillcheck = nil
|
skillcheck:resolve(success)
|
||||||
SetNuiFocus(false, false)
|
skillcheck = nil
|
||||||
|
SetNuiFocus(false, false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param difficulty SkillCheckDifficulity | SkillCheckDifficulity[]
|
||||||
|
---@return boolean?
|
||||||
function lib.skillCheck(difficulty)
|
function lib.skillCheck(difficulty)
|
||||||
if skillcheck then return end
|
if skillcheck then return end
|
||||||
|
|
||||||
skillcheck = promise:new()
|
skillcheck = promise:new()
|
||||||
gameDifficulty = difficulty
|
gameDifficulty = difficulty
|
||||||
SetNuiFocus(true, false)
|
SetNuiFocus(true, false)
|
||||||
|
|
||||||
if type(difficulty) == 'table' then
|
if type(difficulty) == 'table' then
|
||||||
gameCount = 0
|
gameCount = 0
|
||||||
for i = 1, #difficulty do
|
for i = 1, #difficulty do
|
||||||
@@ -33,6 +46,7 @@ function lib.skillCheck(difficulty)
|
|||||||
data = difficulty
|
data = difficulty
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
return Citizen.Await(skillcheck)
|
return Citizen.Await(skillcheck)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -45,4 +59,4 @@ RegisterNUICallback('skillCheckOver', function(data, cb)
|
|||||||
if gameCount == #gameDifficulty then
|
if gameCount == #gameDifficulty then
|
||||||
resolveSkillCheck(data.success)
|
resolveSkillCheck(data.success)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user