108 lines
3.5 KiB
Lua
108 lines
3.5 KiB
Lua
--- Desencrypted By PrejuicioX
|
|
|
|
-- Global variables (preserve for cross-file compatibility)
|
|
CURRENT_BAG = nil
|
|
BAG_OPEN = false
|
|
CHANGING_OUTFIT = false
|
|
PREVIEW_PED = nil
|
|
|
|
-- Cache for GetNearestBag function
|
|
function GetNearestBag()
|
|
return UseCache("GetNearestBag", function()
|
|
local playerCoords = GetEntityCoords(PlayerPedId())
|
|
local objects = GetGamePool("CObject")
|
|
local closestDistance = 20.0
|
|
local closestBag = nil
|
|
|
|
for _, object in pairs(objects) do
|
|
local objectCoords = GetEntityCoords(object)
|
|
local distance = #(playerCoords - objectCoords)
|
|
|
|
if distance <= closestDistance then
|
|
local objectModel = GetEntityModel(object)
|
|
local bagModel = GetHashKey(Config.bagObject)
|
|
|
|
if objectModel == bagModel then
|
|
if IsEntityOutfitBag(object) and distance < closestDistance then
|
|
closestDistance = distance
|
|
closestBag = object
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return closestBag, closestDistance
|
|
end, 2000)
|
|
end
|
|
|
|
-- Main interaction thread (only if target system is disabled)
|
|
if not Config.target.enabled then
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
local sleepTime = 1200
|
|
local playerPed = PlayerPedId()
|
|
local isInVehicle = IsPedInAnyVehicle(playerPed, true)
|
|
|
|
if not isInVehicle then
|
|
if not BAG_OPEN then
|
|
local nearestBag, distance = GetNearestBag()
|
|
|
|
-- Reduce sleep time when near a bag
|
|
if distance <= 5.0 then
|
|
sleepTime = 750
|
|
end
|
|
|
|
-- Handle interaction when close to bag
|
|
if distance < 2.0 and nearestBag then
|
|
local canInteract = IsPublic(nearestBag) or OwnsBag(nearestBag)
|
|
|
|
if canInteract then
|
|
sleepTime = 0
|
|
local bagCoords = GetEntityCoords(nearestBag)
|
|
|
|
-- Display appropriate interaction prompt
|
|
if OwnsBag(nearestBag) and CorrectBagJob(nearestBag) then
|
|
DisplayBagPromptWithPickup(bagCoords, nearestBag)
|
|
else
|
|
DisplayBagPromptOpenOnly(bagCoords)
|
|
end
|
|
|
|
-- Handle open interaction
|
|
if IsControlJustReleased(0, Config.keybinds.open.input) then
|
|
OpenBag(nearestBag)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
else
|
|
sleepTime = 2000
|
|
end
|
|
|
|
Citizen.Wait(sleepTime)
|
|
end
|
|
end)
|
|
end
|
|
|
|
-- Display prompt for owned bags (with pickup option)
|
|
function DisplayBagPromptWithPickup(coords, bag)
|
|
local promptText = L("~w~[~g~{OPEK_KEYBIND}~w~] to open [~g~{PICKUP_KEYBIND}~w~] to pickup the bag")
|
|
promptText = promptText:gsub("{OPEK_KEYBIND}", Config.keybinds.open.label)
|
|
promptText = promptText:gsub("{PICKUP_KEYBIND}", Config.keybinds.pickup.label)
|
|
|
|
Draw3DText(coords.x, coords.y, coords.z + 0.05, promptText, 4, 0.04, 0.04)
|
|
|
|
-- Handle pickup interaction
|
|
if IsControlJustReleased(0, Config.keybinds.pickup.input) then
|
|
PickupBag(bag)
|
|
end
|
|
end
|
|
|
|
-- Display prompt for public bags (open only)
|
|
function DisplayBagPromptOpenOnly(coords)
|
|
local promptText = L("~w~[~g~{OPEN_KEYBIND}~w~] to open the bag")
|
|
promptText = promptText:gsub("{OPEN_KEYBIND}", Config.keybinds.open.label)
|
|
|
|
Draw3DText(coords.x, coords.y, coords.z + 0.05, promptText, 4, 0.04, 0.04)
|
|
end
|
|
|
|
--- Desencrypted By PrejuicioX |