local values = {} local function SpawnItemAt(identifier, position) -- hostside only -- if Game.IsMultiplayer and CLIENT then return end if not Entity.Spawner then Timer.Wait(function() SpawnItemAt(identifier, position) end, 5) return end -- use server spawn method Timer.Wait(function() local prefab = ItemPrefab.GetItemPrefab(identifier) Entity.Spawner.AddItemToSpawnQueue(prefab, position, nil, nil, nil) end, 5) end local function onSwitchToggled(state, item, pos) if state then SpawnItemAt("eksfx_switch_sound", pos) else SpawnItemAt("eksfx_switch_sound", pos) end end if (Game.IsMultiplayer and SERVER) or not Game.IsMultiplayer then Hook.Add("ekutility_heavypowerswitch.OnAlways", "Test", function (effect, deltaTime, item, targets, worldPosition, client) local relay = item.GetComponentString("RelayComponent") local state = relay.isOn local id = item.ID if values[id] == nil then values[id] = state end if values[id] ~= state then values[id] = state onSwitchToggled(state, item, item.WorldPosition) end end) end;