-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I found an interesting issue where when the player finished filling up the gasnozzle and forgot to return it, the gasnozzle would remain in the character's hand.
Add timeout checking and error handling where appropriate. For example, check if the gasnozzle has been returned when the refueling is completed or canceled, delete it if it is not, and display the appropriate notification to the player.
ps-fuel/client/client.lua
RegisterNetEvent('ps-fuel:client:takenozzle', function ()
if hasNozzle then return end
local ped = PlayerPedId()
local nozzleProp = "prop_cs_fuel_nozle"
RequestAnimDict("anim@am_hold_up@male")
while not HasAnimDictLoaded('anim@am_hold_up@male') do
Wait(100)
end
TaskPlayAnim(ped, "anim@am_hold_up@male", "shoplift_high", 2.0, 8.0, 1000, 50, 0, 0, 0, 0)
TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 5, "pickupnozzle", 0.6)
QBCore.Functions.LoadModel(nozzleProp)
gasNozzle = CreateObject(nozzleProp, 1.0, 1.0, 1.0, 1, 1, 0)
if DoesEntityExist(gasNozzle) then
hasNozzle = true
AttachEntityToEntity(gasNozzle, ped, GetPedBoneIndex(ped, 18905), 0.13, 0.04, 0.01, -42.0, -115.0, -63.42, 0, 1, 0, 1, 0, 1)
-- Set the timeout check for the gasnozzle
Citizen.CreateThread(function()
Wait(120000) -- Set the timeout period, which can be adjusted according to actual needs
if hasNozzle then
DeleteObject(gasNozzle)
gasNozzle = nil
hasNozzle = false
QBCore.Functions.Notify("You forgot to return the gas nozzle!", "error")
end
end)
end
end)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request