function objectHandler(closestZones) local pos, zone local tmp = {} for _, id in pairs(closestZones) do zone = Config.workstations[id] pos = zone.pos tmp[id] = {} if not ECO.WORKPLACE[id] then ECO.WORKPLACE[id] = {} end -- OBJECT if zone.object.model then if ECO.WORKPLACE[id].object then tmp[id].object = ECO.WORKPLACE[id].object else modelLoader(zone.object.model) local obj if zone.object.placeOnGround then obj = CreateObject(zone.object.model, pos.xyz) PlaceObjectOnGroundProperly(obj) if zone.object.offset then SetEntityCoords(obj, GetEntityCoords(obj) + zone.object.offset) end else obj = CreateObject(zone.object.model, (zone.object.offset and pos.xyz + zone.object.offset or pos.xyz)) end SetEntityHeading(obj, pos.w) FreezeEntityPosition(obj, true) tmp[id].object = obj end end -- FX MARKER if zone.fx and zone.accessToUse then if ECO.WORKPLACE[id].fx then tmp[id].fx = ECO.WORKPLACE[id].fx else fxLoader(zone.fx.dict) UseParticleFxAsset(zone.fx.dict) local pfx = StartParticleFxLoopedAtCoord(zone.fx.name, pos.xyz + zone.fx.offset, zone.fx.loopedAtCoord[1], zone.fx.loopedAtCoord[2], zone.fx.loopedAtCoord[3], zone.fx.loopedAtCoord[4], false, false, false, false) SetParticleFxLoopedColour(pfx, -- handle zone.fx.loopedColour[1], -- külső méret 0-8 zone.fx.loopedColour[2], -- belső mag méret 0-5 zone.fx.loopedColour[3], -- fényesség(fehéredik) 0-6 0) -- nothing tmp[id].fx = pfx end end -- TARGETS if Config.useTarget and (zone.accessToUse or zone.accessToRemove) then if ECO.WORKPLACE[id].targetZone then tmp[id].targetZone = ECO.WORKPLACE[id].targetZone else local obj local zoneId = 'zone_' .. id local options = { { event = 'eco_crafting:targetControl', icon = "fa-solid fa-screwdriver-wrench", label = translate('use_workstation_target', zone.name), zoneId = id, canInteract = function() local ws = Config.workstations[id] return ws and ws.accessToUse or false end, distance = zone.actionDistance }, { event = 'eco_crafting:workstationRemovalRequest', icon = "fa-solid fa-toolbox", label = translate('workstation_removal'), zoneId = id, canInteract = function() local ws = Config.workstations[id] return ws and ws.accessToRemove or false end, distance = zone.actionDistance } } if tmp[id].object then obj = tmp[id].object else local objects = GetGamePool('CObject') local closestDistance = 1.0 for i = 1, #objects do local distance = #(GetEntityCoords(objects[i]) - pos.xyz) if closestDistance > distance then obj = objects[i] closestDistance = distance end end end if obj then tmp[id].targetZone = { id = zoneId, type = "localEntityZone" } eCore:addLocalEntity(obj, options) else tmp[id].targetZone = { id = zoneId, type = "boxZone" } eCore:addBoxZone({ coords = pos.xyz, name = zoneId, size = vec3(1.0, 1.5, 3.0), rotation = pos.w, debug = Config.debugPoly, options = options }); end end end end for id, params in pairs(ECO.WORKPLACE) do if params.fx and (not tmp[id] or not tmp[id].fx) then StopParticleFxLooped(params.fx, 0) end if params.object and (not tmp[id] or not tmp[id].object) then DeleteObject(params.object) end if params.targetZone and (not tmp[id] or not tmp[id].targetZone) then if params.targetZone.type == "boxZone" then eCore:removeZone(params.targetZone.id) elseif params.targetZone.type == "localEntityZone" then eCore:removeLocalEntity(params.targetZone.id) end end end ECO.WORKPLACE = tmp end function workplaceDeleter() for _, params in pairs(ECO.WORKPLACE) do if params.fx then StopParticleFxLooped(params.fx, 0) end if params.object then DeleteObject(params.object) end if params.targetZone then if params.targetZone.type == "boxZone" then eCore:removeZone(params.targetZone.id) elseif params.targetZone.type == "localEntityZone" then eCore:removeLocalEntity(params.targetZone.id) end end end ECO.WORKPLACE = {} end