91 lines
2.5 KiB
Lua
91 lines
2.5 KiB
Lua
--- Desencrypted By PrejuicioX
|
|
|
|
-- Fixed Bags System for Outfit Management
|
|
|
|
function SetupFixedBags()
|
|
for bagKey, bagData in pairs(Config.fixedBags) do
|
|
-- Process and assign IDs to all outfits
|
|
for outfitIndex, outfitData in pairs(bagData.outfits) do
|
|
local outfit = Config.fixedBags[bagKey].outfits[outfitIndex]
|
|
outfit.id = bagKey .. "-" .. outfitIndex
|
|
|
|
-- Structure outfit data for state bag
|
|
outfit.data = {
|
|
drawable = Config.fixedBags[bagKey].outfits[outfitIndex].drawable,
|
|
props = Config.fixedBags[bagKey].outfits[outfitIndex].props
|
|
}
|
|
end
|
|
|
|
-- Spawn bag objects at all configured locations
|
|
for locationIndex, locationCoords in pairs(bagData.bags.locations) do
|
|
SpawnFixedBag(locationCoords, bagData.outfits, bagData.bags.jobs)
|
|
end
|
|
end
|
|
end
|
|
|
|
function SpawnFixedBag(coords, outfits, jobs)
|
|
-- Clean up any existing bag at this location
|
|
DeleteNearestOfType(coords, Config.bagObject)
|
|
Citizen.Wait(50)
|
|
|
|
-- Load the bag model
|
|
DoRequestModel(Config.bagObject)
|
|
|
|
-- Create bag object slightly below ground level
|
|
local bagEntity = CreateObject(
|
|
Config.bagObject,
|
|
coords.xyz + vector3(0, 0, -1),
|
|
0,
|
|
1,
|
|
0
|
|
)
|
|
|
|
-- Set rotation
|
|
SetEntityHeading(bagEntity, coords.w)
|
|
Citizen.Wait(100)
|
|
|
|
-- Freeze in place
|
|
FreezeEntityPosition(bagEntity, true)
|
|
|
|
-- Configure entity state bags
|
|
EnsureEntityStateBag(bagEntity)
|
|
|
|
local entityState = Entity(bagEntity).state
|
|
entityState:set("kq_ob", true, false)
|
|
entityState:set("kq_ob_item", false, false)
|
|
entityState:set("kq_ob_bag", "fixed", false)
|
|
entityState:set("kq_ob_public", true, true)
|
|
entityState:set("kq_ob_owner", -1, true)
|
|
entityState:set("kq_ob_outfits", outfits, true)
|
|
entityState:set("kq_ob_jobs", jobs, false)
|
|
end
|
|
|
|
-- Initialize fixed bags on resource start
|
|
SetupFixedBags()
|
|
|
|
-- Debug command for testing fixed bags
|
|
if Config.debug then
|
|
RegisterCommand("obfixed", function(source, args)
|
|
OpenFixedBag(args[1])
|
|
end)
|
|
end
|
|
|
|
function OpenFixedBag(bagId)
|
|
local bagConfig = Config.fixedBags[bagId]
|
|
|
|
if not bagConfig then
|
|
DrawMissionText(
|
|
L("~r~This fixed bag does not exist. Please let the server admin know about this.)") .. " ~w~(" .. bagId .. ")",
|
|
6000
|
|
)
|
|
return
|
|
end
|
|
|
|
RotateTillFree()
|
|
OpenBag(bagId)
|
|
end
|
|
|
|
-- Export for external use
|
|
exports("OpenFixedBag", OpenFixedBag)
|
|
|
|
--- Desencrypted By PrejuicioX |