refactor: split config
This commit is contained in:
+25
-38
@@ -1,4 +1,4 @@
|
|||||||
local Config = require 'config.client'
|
local config = require 'config.client'
|
||||||
|
|
||||||
local currentGear = {
|
local currentGear = {
|
||||||
mask = 0,
|
mask = 0,
|
||||||
@@ -20,24 +20,24 @@ end
|
|||||||
|
|
||||||
lib.callback.register('qbx_divegear:client:fillTank', function()
|
lib.callback.register('qbx_divegear:client:fillTank', function()
|
||||||
if IsPedSwimmingUnderWater(cache.ped) then
|
if IsPedSwimmingUnderWater(cache.ped) then
|
||||||
exports.qbx_core:Notify(Lang:t("error.underwater", {oxygenlevel = oxygenLevel}), 'error')
|
exports.qbx_core:Notify(Lang:t('error.underwater', {oxygenlevel = oxygenLevel}), 'error')
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if lib.progressBar({
|
if lib.progressBar({
|
||||||
duration = Config.RefillTankTimeMs,
|
duration = config.RefillTankTimeMs,
|
||||||
label = Lang:t("info.filling_air"),
|
label = Lang:t('info.filling_air'),
|
||||||
useWhileDead = false,
|
useWhileDead = false,
|
||||||
canCancel = true,
|
canCancel = true,
|
||||||
anim = {
|
anim = {
|
||||||
dict = "clothingshirt",
|
dict = 'clothingshirt',
|
||||||
clip = "try_shirt_positive_d",
|
clip = 'try_shirt_positive_d',
|
||||||
blendIn = 8.0
|
blendIn = 8.0
|
||||||
}
|
}
|
||||||
}) then
|
}) then
|
||||||
|
|
||||||
oxygenLevel = Config.OxygenLevel
|
oxygenLevel = config.startingOxygenLevel
|
||||||
exports.qbx_core:Notify(Lang:t("success.tube_filled"), 'success')
|
exports.qbx_core:Notify(Lang:t('success.tube_filled'), 'success')
|
||||||
if currentGear.enabled then
|
if currentGear.enabled then
|
||||||
enableScuba()
|
enableScuba()
|
||||||
end
|
end
|
||||||
@@ -76,13 +76,13 @@ end
|
|||||||
|
|
||||||
local function takeOffSuit()
|
local function takeOffSuit()
|
||||||
if lib.progressBar({
|
if lib.progressBar({
|
||||||
duration = Config.TakeOffSuitTimeMs,
|
duration = config.TakeOffSuitTimeMs,
|
||||||
label = Lang:t("info.pullout_suit"),
|
label = Lang:t('info.pullout_suit'),
|
||||||
useWhileDead = false,
|
useWhileDead = false,
|
||||||
canCancel = true,
|
canCancel = true,
|
||||||
anim = {
|
anim = {
|
||||||
dict = "clothingshirt",
|
dict = 'clothingshirt',
|
||||||
clip = "try_shirt_positive_d",
|
clip = 'try_shirt_positive_d',
|
||||||
blendIn = 8.0
|
blendIn = 8.0
|
||||||
}
|
}
|
||||||
}) then
|
}) then
|
||||||
@@ -90,29 +90,16 @@ local function takeOffSuit()
|
|||||||
SetPedMaxTimeUnderwater(cache.ped, 50.00)
|
SetPedMaxTimeUnderwater(cache.ped, 50.00)
|
||||||
currentGear.enabled = false
|
currentGear.enabled = false
|
||||||
deleteGear()
|
deleteGear()
|
||||||
exports.qbx_core:Notify(Lang:t("success.took_out"))
|
exports.qbx_core:Notify(Lang:t('success.took_out'))
|
||||||
TriggerServerEvent("InteractSound_SV:PlayOnSource", nil, 0.25)
|
TriggerServerEvent('InteractSound_SV:PlayOnSource', nil, 0.25)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function drawText(text)
|
|
||||||
SetTextFont(4)
|
|
||||||
SetTextProportional(true)
|
|
||||||
SetTextScale(0.0, 0.45)
|
|
||||||
SetTextDropshadow(1, 0, 0, 0, 255)
|
|
||||||
SetTextEdge(1, 0, 0, 0, 255)
|
|
||||||
SetTextDropShadow()
|
|
||||||
SetTextOutline()
|
|
||||||
BeginTextCommandDisplayText("STRING")
|
|
||||||
AddTextComponentSubstringPlayerName(text)
|
|
||||||
EndTextCommandDisplayText(0.45, 0.90)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function startOxygenLevelDrawTextThread()
|
local function startOxygenLevelDrawTextThread()
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while currentGear.enabled do
|
while currentGear.enabled do
|
||||||
if IsPedSwimmingUnderWater(cache.ped) then
|
if IsPedSwimmingUnderWater(cache.ped) then
|
||||||
drawText(oxygenLevel..'⏱')
|
DrawText2D(oxygenLevel..'⏱', vec2(1.0, 1.42), 1.0, 1.0, 0.45, 4)
|
||||||
end
|
end
|
||||||
Wait(0)
|
Wait(0)
|
||||||
end
|
end
|
||||||
@@ -124,12 +111,12 @@ local function startOxygenLevelDecrementerThread()
|
|||||||
while currentGear.enabled do
|
while currentGear.enabled do
|
||||||
if IsPedSwimmingUnderWater(cache.ped) and oxygenLevel > 0 then
|
if IsPedSwimmingUnderWater(cache.ped) and oxygenLevel > 0 then
|
||||||
oxygenLevel -= 1
|
oxygenLevel -= 1
|
||||||
if oxygenLevel % 10 == 0 and oxygenLevel ~= Config.OxygenLevel then
|
if oxygenLevel % 10 == 0 and oxygenLevel ~= config.startingOxygenLevel then
|
||||||
TriggerServerEvent("InteractSound_SV:PlayOnSource", "breathdivingsuit", 0.25)
|
TriggerServerEvent('InteractSound_SV:PlayOnSource', 'breathdivingsuit', 0.25)
|
||||||
end
|
end
|
||||||
if oxygenLevel == 0 then
|
if oxygenLevel == 0 then
|
||||||
disableScuba()
|
disableScuba()
|
||||||
TriggerServerEvent("InteractSound_SV:PlayOnSource", nil, 0.25)
|
TriggerServerEvent('InteractSound_SV:PlayOnSource', nil, 0.25)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
@@ -139,23 +126,23 @@ end
|
|||||||
|
|
||||||
local function putOnSuit()
|
local function putOnSuit()
|
||||||
if oxygenLevel <= 0 then
|
if oxygenLevel <= 0 then
|
||||||
exports.qbx_core:Notify(Lang:t("error.need_otube"), 'error')
|
exports.qbx_core:Notify(Lang:t('error.need_otube'), 'error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if IsPedSwimming(cache.ped) or cache.vehicle then
|
if IsPedSwimming(cache.ped) or cache.vehicle then
|
||||||
exports.qbx_core:Notify(Lang:t("error.not_standing_up"), 'error')
|
exports.qbx_core:Notify(Lang:t('error.not_standing_up'), 'error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if lib.progressBar({
|
if lib.progressBar({
|
||||||
duration = Config.PutOnSuitTimeMs,
|
duration = config.PutOnSuitTimeMs,
|
||||||
label = Lang:t("info.put_suit"),
|
label = Lang:t('info.put_suit'),
|
||||||
useWhileDead = false,
|
useWhileDead = false,
|
||||||
canCancel = true,
|
canCancel = true,
|
||||||
anim = {
|
anim = {
|
||||||
dict = "clothingshirt",
|
dict = 'clothingshirt',
|
||||||
clip = "try_shirt_positive_d",
|
clip = 'try_shirt_positive_d',
|
||||||
blendIn = 8.0
|
blendIn = 8.0
|
||||||
}
|
}
|
||||||
}) then
|
}) then
|
||||||
@@ -163,7 +150,7 @@ local function putOnSuit()
|
|||||||
attachGear()
|
attachGear()
|
||||||
enableScuba()
|
enableScuba()
|
||||||
currentGear.enabled = true
|
currentGear.enabled = true
|
||||||
TriggerServerEvent("InteractSound_SV:PlayOnSource", "breathdivingsuit", 0.25)
|
TriggerServerEvent('InteractSound_SV:PlayOnSource', 'breathdivingsuit', 0.25)
|
||||||
startOxygenLevelDecrementerThread()
|
startOxygenLevelDecrementerThread()
|
||||||
startOxygenLevelDrawTextThread()
|
startOxygenLevelDrawTextThread()
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
OxygenLevel = 100,
|
startingOxygenLevel = 100,
|
||||||
PutOnSuitTimeMs = 5000,
|
putOnSuitTimeMs = 5000,
|
||||||
TakeOffSuitTimeMs = 5000,
|
takeOffSuitTimeMs = 5000,
|
||||||
RefillTankTimeMs = 5000
|
RefillTankTimeMs = 5000
|
||||||
}
|
}
|
||||||
+3
-3
@@ -2,17 +2,17 @@ local Translations = {
|
|||||||
error = {
|
error = {
|
||||||
canceled = "Canceled",
|
canceled = "Canceled",
|
||||||
not_standing_up = "You need to be on solid ground to put this on...",
|
not_standing_up = "You need to be on solid ground to put this on...",
|
||||||
need_otube = "you need to refill your oxygen! Get a replacement air supply!",
|
need_otube = "You need to refill your oxygen! Get a replacement air supply!",
|
||||||
underwater = "Cannot do this underwater",
|
underwater = "Cannot do this underwater",
|
||||||
},
|
},
|
||||||
success = {
|
success = {
|
||||||
took_out = "You took your diving gear off.",
|
took_out = "You took your diving gear off",
|
||||||
tube_filled = "You've successfully refilled your air tank!"
|
tube_filled = "You've successfully refilled your air tank!"
|
||||||
},
|
},
|
||||||
info = {
|
info = {
|
||||||
put_suit = "Putting on your diving suit...",
|
put_suit = "Putting on your diving suit...",
|
||||||
pullout_suit = "Taking off your diving suit...",
|
pullout_suit = "Taking off your diving suit...",
|
||||||
filling_air = "Filling air"
|
filling_air = "Filling air..."
|
||||||
},
|
},
|
||||||
warning = {
|
warning = {
|
||||||
oxygen_one_minute = "You have less than one minute of air remaining!",
|
oxygen_one_minute = "You have less than one minute of air remaining!",
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
exports.qbx_core:CreateUseableItem("diving_gear", function(source)
|
exports.qbx_core:CreateUseableItem('diving_gear', function(source)
|
||||||
TriggerClientEvent('qbx_divegear:client:useGear', source)
|
TriggerClientEvent('qbx_divegear:client:useGear', source)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
exports.qbx_core:CreateUseableItem("diving_fill", function(source)
|
exports.qbx_core:CreateUseableItem('diving_fill', function(source)
|
||||||
local success = lib.callback.await('qbx_divegear:client:fillTank', source)
|
local success = lib.callback.await('qbx_divegear:client:fillTank', source)
|
||||||
if success then
|
if success then
|
||||||
exports.ox_inventory:RemoveItem(source, 'diving_fill', 1)
|
exports.ox_inventory:RemoveItem(source, 'diving_fill', 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user