Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Progressbar Support #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 115 additions & 1 deletion client.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
if (Config.FRAMEWORK == 'qb') then
FRAMEWORK = Config.GET_CORE
elseif (Config.FRAMEWORK == 'esx') then
FRAMEWORK = exports["es_extended"]:getSharedObject()
elseif (Config.FRAMEWORK == 'esx-old') then
TriggerEvent('esx:getSharedObject', function(obj) FRAMEWORK = obj end)
else
-- put in custom logic to grab framework and delete print code underneath
print('^6[^3dream-postal^6]^0 Unsupported Framework detected!')
end
Comment on lines +1 to +10
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already grab framework in client_util so this code is not needed. With that being said is client_util loaded in first? If not then we must change order in fxmanifest.lua


---@diagnostic disable: lowercase-global

local POSTAL_BOSS_COORDS = Config.POSTAL_BOSS_COORDS
local POSTAL_BOSS_HEADING = Config.POSTAL_BOSS_HEADING
local POSTAL_BOSS_HASH = Config.POSTAL_BOSS_HASH
Expand All @@ -16,6 +28,8 @@ local DROP_OFF_PED_HASH = Config.DROP_OFF_PED_HASH
local SHOW_WHITE_ARROW_MARKER = Config.SHOW_WHITE_ARROW_MARKER
local IS_WHITELISTED_TO_JOB = Config.IS_WHITELISTED_TO_JOB
local WHITELISTED_JOB_TITLE = Config.WHITELISTED_JOB_TITLE
local USE_PROGRESS_BAR = Config.USE_PROGRESS_BAR
local PROGRESS_BAR = Config.PROGRESS_BAR

local isPedSpawned = false
local postalBossPed = nil
Expand Down Expand Up @@ -159,6 +173,31 @@ function pickupMail()
return
end

if (USE_PROGRESS_BAR) then
if (PROGRESS_BAR == 'qb') then
QBCore.Functions.Progressbar("grab_mail", "Grabbing Package from Mailbox", Config.PROGRESS_BAR_DURATION, false, false, {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use FRAMEWORK here

disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {
animDict = "anim_heist@arcade@light_gun@male@right@",
animName = "enter",
flags = 49
}, {}, {}, function() -- Done

end, function() -- Cancel

end)
Wait(Config.PROGRESS_BAR_DURATION)
elseif (PROGRESS_BAR == 'an_progBar') then
exports['an-progBar']:run(Config.PROGRESS_BAR_DURATION, 'Grabbing Package from Mailbox')
Wait(Config.PROGRESS_BAR_DURATION)
else
print('^6[^3dream-postal^6]^0 Unsupported Progress Bar detected!')
end
end

NotifyPlayer(t('place_package_in_back_of_van'))

TARGET.RemoveZone(postalJobState.postalBoxZone)
Expand Down Expand Up @@ -225,7 +264,31 @@ function pickupMail()
end

function insertPackageIntoVehicle()
-- TODO: add some sort of animation
if (USE_PROGRESS_BAR) then
if (PROGRESS_BAR == 'qb') then
QBCore.Functions.Progressbar("insert_into_veh", "Placing Package into Vehicle", Config.PROGRESS_BAR_DURATION, false, false, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {
animDict = "anim_heist@arcade@light_gun@male@right@",
animName = "enter",
flags = 49
}, {}, {}, function() -- Done

end, function() -- Cancel

end)
Wait(Config.PROGRESS_BAR_DURATION)
elseif (PROGRESS_BAR == 'an_progBar') then
exports['an-progBar']:run(Config.PROGRESS_BAR_DURATION, 'Placing Package into Vehicle')
Wait(Config.PROGRESS_BAR_DURATION)
else
print('^6[^3dream-postal^6]^0 Unsupported Progress Bar detected!')
end
end

removeBox()

if (Config.TARGET == 'ox') then
Expand Down Expand Up @@ -423,6 +486,30 @@ function createPutPackageInVanZone()
end

function putPackageInVehicle()
if (USE_PROGRESS_BAR) then
if (PROGRESS_BAR == 'qb') then
QBCore.Functions.Progressbar("insert_into_veh", "Placing Package into Vehicle", Config.PROGRESS_BAR_DURATION, false, false, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {
animDict = "anim_heist@arcade@light_gun@male@right@",
animName = "enter",
flags = 49
}, {}, {}, function() -- Done

end, function() -- Cancel

end)
Wait(Config.PROGRESS_BAR_DURATION)
elseif (PROGRESS_BAR == 'an_progBar') then
exports['an-progBar']:run(Config.PROGRESS_BAR_DURATION, 'Placing Package into Vehicle')
Wait(Config.PROGRESS_BAR_DURATION)
else
print('^6[^3dream-postal^6]^0 Unsupported Progress Bar detected!')
end
end
removeBox()
postalJobState.isCarryingBox = false
postalJobState.hasBoxInVan = true
Expand Down Expand Up @@ -642,11 +729,38 @@ function deliverPackageToPed()
return
end



Comment on lines +732 to +733
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this added lines

if (not postalJobState.isCarryingBox) then
NotifyPlayer(t('where_is_the_package'), 'error', 7500)
return
end

if (USE_PROGRESS_BAR) then
if (PROGRESS_BAR == 'qb') then
QBCore.Functions.Progressbar("give_to_ped", "Handing Package to Recipient", Config.PROGRESS_BAR_DURATION, false, false, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {
animDict = "anim_heist@arcade@light_gun@male@right@",
animName = "enter",
flags = 49
}, {}, {}, function() -- Done

end, function() -- Cancel

end)
Wait(Config.PROGRESS_BAR_DURATION)
elseif (PROGRESS_BAR == 'an_progBar') then
exports['an-progBar']:run(Config.PROGRESS_BAR_DURATION, 'Handing Package to Recipient')
Wait(Config.PROGRESS_BAR_DURATION)
else
print('^6[^3dream-postal^6]^0 Unsupported Progress Bar detected!')
end
end

local playerPed = PlayerPedId()
NotifyPlayer(t('you_delivered_the_package'), 'success')

Expand Down
5 changes: 5 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ Config.PAY_MULTIPLIER = 1.5
-- Whether or not to show the white arrow marker above the drop off ped & blue postal boxes.
Config.SHOW_WHITE_ARROW_MARKER = true

-- Whether or not to show progressbar and what kind/duration.
Config.USE_PROGRESS_BAR = true -- use progress bar or not
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we initialize this to false

Config.PROGRESS_BAR = 'qb' -- 'qb' | 'an_progBar'
Config.PROGRESS_BAR_DURATION = 2000 -- 2 seconds

-- List of coordinates that hold the pick-up locations for the packages.
-- TO FIND MORE LOCATIONS:
-- 1. Execute /pbox to find a singular location.
Expand Down