Skip to content

Commit

Permalink
refactor(client/main): using inside zone functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason authored Nov 7, 2023
1 parent 6de430d commit 8747b77
Showing 1 changed file with 19 additions and 35 deletions.
54 changes: 19 additions & 35 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
local isLoggedIn = false
local isLoggedIn = LocalPlayer.state.isLoggedIn
local coralZones = {}
local coralTargetZones = {}
local currentArea = 0
local inSellerZone = false
local isWearingSuit = false
local oxygenLevel = 0
local currentDivingLocation = {
Expand Down Expand Up @@ -143,6 +142,12 @@ local function setDivingLocation(divingLocation)
onExit = function()
currentArea = 0
lib.hideTextUI()
end,
inside = function()
if IsControlJustPressed(0, 51) then -- E
takeCoral(currentArea)
lib.hideTextUI()
end
end
})
end
Expand Down Expand Up @@ -191,13 +196,17 @@ local function createSeller()
rotation = current.coords.w,
size = vec3(current.zoneOptions.length, current.zoneOptions.width, 3),
onEnter = function()
inSellerZone = true
lib.showTextUI(Lang:t("info.sell_coral_dt"))
end,
onExit = function()
inSellerZone = false
lib.hideTextUI()
end,
inside = function()
if IsControlJustPressed(0, 51) then -- E
sellCoral()
lib.hideTextUI()
end
end
})
end
end
Expand Down Expand Up @@ -265,7 +274,7 @@ end)

RegisterNetEvent("qb-diving:client:setoxygenlevel", function()
if oxygenLevel == 0 then
oxygenLevel = Config.OxygenLevel -- oxygenlevel
oxygenLevel = Config.OxygenLevel
exports.qbx_core:Notify(Lang:t("success.tube_filled"), 'success')
TriggerServerEvent('qb-diving:server:removeItemAfterFill')
return
Expand Down Expand Up @@ -360,37 +369,12 @@ RegisterNetEvent('qb-diving:client:UseGear', function()
end
end)

-- Threads

CreateThread(function()
if isLoggedIn then
local config, area = lib.callback.await('qb-diving:server:GetDivingConfig', false)
Config.CoralLocations = config
setDivingLocation(area)
createSeller()
end
if Config.UseTarget then return end
while isLoggedIn do
local sleep = 1000
if currentArea ~= 0 then
sleep = 0
if IsControlJustPressed(0, 51) then -- E
takeCoral(currentArea)
lib.hideTextUI()
sleep = 3000
end
end

if inSellerZone then
sleep = 0
if IsControlJustPressed(0, 51) then -- E
sellCoral()
lib.hideTextUI()
sleep = 3000
end
end
Wait(sleep)
end
if not isLoggedIn then return end
local config, area = lib.callback.await('qb-diving:server:GetDivingConfig', false)
Config.CoralLocations = config
setDivingLocation(area)
createSeller()
end)

CreateThread(function()
Expand Down

0 comments on commit 8747b77

Please sign in to comment.