ed
This commit is contained in:
parent
d3f4114333
commit
5cb18574a7
2 changed files with 268 additions and 181 deletions
|
|
@ -11,21 +11,21 @@ local function Debug(msg)
|
|||
end
|
||||
|
||||
-- Check if player has required items
|
||||
lib.callback.register('container_heist:server:checkRequiredItems', function(source)
|
||||
QBCore.Functions.CreateCallback('container_heist:server:checkRequiredItems', function(source, cb)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if not Player then return false end
|
||||
if not Player then return cb(false) end
|
||||
|
||||
-- Check for required flex tool
|
||||
local hasItem = exports['tgiann-inventory']:HasItem(src, Config.RequiredItems.flex.name, Config.RequiredItems.flex.amount)
|
||||
return hasItem
|
||||
cb(hasItem)
|
||||
end)
|
||||
|
||||
-- Check cooldowns
|
||||
lib.callback.register('container_heist:server:checkCooldown', function(source, pointId)
|
||||
QBCore.Functions.CreateCallback('container_heist:server:checkCooldown', function(source, cb, pointId)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if not Player then return {success = false, message = "Player not found"} end
|
||||
if not Player then return cb({success = false, message = "Player not found"}) end
|
||||
|
||||
local citizenId = Player.PlayerData.citizenid
|
||||
local currentTime = os.time()
|
||||
|
|
@ -33,12 +33,12 @@ lib.callback.register('container_heist:server:checkCooldown', function(source, p
|
|||
-- Check player cooldown
|
||||
if playerCooldowns[citizenId] and (currentTime - playerCooldowns[citizenId]) < (Config.CooldownTime * 60) then
|
||||
local timeLeft = math.ceil(((playerCooldowns[citizenId] + (Config.CooldownTime * 60)) - currentTime) / 60)
|
||||
return {success = false, message = "You need to wait " .. timeLeft .. " more minutes before attempting another heist!"}
|
||||
return cb({success = false, message = "You need to wait " .. timeLeft .. " more minutes before attempting another heist!"})
|
||||
end
|
||||
|
||||
-- Check point cooldown
|
||||
if pointCooldowns[pointId] and (currentTime - pointCooldowns[pointId]) < (Config.CooldownTime * 60) then
|
||||
return {success = false, message = Config.Notifications.alreadyRobbed}
|
||||
return cb({success = false, message = Config.Notifications.alreadyRobbed})
|
||||
end
|
||||
|
||||
-- Find point type
|
||||
|
|
@ -51,20 +51,20 @@ lib.callback.register('container_heist:server:checkCooldown', function(source, p
|
|||
end
|
||||
|
||||
if not pointType then
|
||||
return {success = false, message = "Invalid point!"}
|
||||
return cb({success = false, message = "Invalid point!"})
|
||||
end
|
||||
|
||||
-- Check global cooldown for container type
|
||||
if globalCooldowns[pointType] and (currentTime - globalCooldowns[pointType]) < (Config.GlobalCooldown * 60) then
|
||||
local timeLeft = math.ceil(((globalCooldowns[pointType] + (Config.GlobalCooldown * 60)) - currentTime) / 60)
|
||||
return {success = false, message = Config.Notifications.globalCooldown .. " (" .. timeLeft .. " minutes left)"}
|
||||
return cb({success = false, message = Config.Notifications.globalCooldown .. " (" .. timeLeft .. " minutes left)"})
|
||||
end
|
||||
|
||||
return {success = true}
|
||||
cb({success = true})
|
||||
end)
|
||||
|
||||
-- Get police count
|
||||
lib.callback.register('container_heist:server:getPoliceCount', function()
|
||||
QBCore.Functions.CreateCallback('container_heist:server:getPoliceCount', function(source, cb)
|
||||
local policeCount = 0
|
||||
local players = QBCore.Functions.GetPlayers()
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ lib.callback.register('container_heist:server:getPoliceCount', function()
|
|||
end
|
||||
end
|
||||
|
||||
return policeCount
|
||||
cb(policeCount)
|
||||
end)
|
||||
|
||||
-- Alert police
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue