📦Entity Sets
Discover how to control object visibility and states using Entity Sets for dynamic map customization in FiveM
-- enset_manager/client.lua
-- List of Entity Sets to manage (replace these with the Entity Sets from your map's documentation)
local entitySets = {
"example_enset_1",
"example_enset_2",
"example_enset_3"
}
-- Function to activate Entity Sets
local function activateEntitySets()
for _, enset in ipairs(entitySets) do
if not IsEntitySetActive(enset) then
ActivateEntitySet(enset)
while not IsEntitySetActive(enset) do
Wait(10) -- Wait until the Entity Set is fully activated
end
print("[Entity Set Manager] Activated Entity Set: " .. enset)
end
end
end
-- Function to deactivate Entity Sets
local function deactivateEntitySets()
for _, enset in ipairs(entitySets) do
if IsEntitySetActive(enset) then
DeactivateEntitySet(enset)
while IsEntitySetActive(enset) do
Wait(10) -- Wait until the Entity Set is fully deactivated
end
print("[Entity Set Manager] Deactivated Entity Set: " .. enset)
end
end
end
-- Event to trigger Entity Set management when the resource starts
CreateThread(function()
if GetCurrentResourceName() == resourceName then
activateEntitySets()
print("[Entity Set Manager] All Entity Sets have been activated successfully!")
end
end)
-- Example of how to deactivate Entity Sets when the resource stops
AddEventHandler('onResourceStop', function(resourceName)
if resourceName == GetCurrentResourceName() then
deactivateEntitySets()
print("[Entity Set Manager] All Entity Sets have been deactivated successfully!")
end
end)Last updated