Hi, I'm trying to create a helmet with an event. When equipped, it should execute the script every second, but it doesn't - it executes once when equipped.
I also tried another option: (draft)
in this code, equipping this helmet triggered an event and removing the helmet stopped the event, but the change (swapping helmets) duplicated the events and e.g. I swapped helmets 3 times and the event triggered 3 times
What is a good way to start an event after equipping the helmet and end the event after taking the helmet off? (so that swap does not duplicate events)
Lua:
function onEquip(player, item, slot)
addEvent(function()
print("working")
end, 1000, cid)
end
I also tried another option: (draft)
in this code, equipping this helmet triggered an event and removing the helmet stopped the event, but the change (swapping helmets) duplicated the events and e.g. I swapped helmets 3 times and the event triggered 3 times
Lua:
function onEquip(player, slot, item)
startScript(player)
end
function startScript(player)
eve = addEvent(startScript, 1000, player:getId())
print("working")
end
function onDeEquip(player, item, slot)
if eve then
stopEvent(eve)
eve = nil
end
end
What is a good way to start an event after equipping the helmet and end the event after taking the helmet off? (so that swap does not duplicate events)
Last edited: