Blade33711
Member
It's possible to do on each bed if player sleeping this effect?
doSendMagicEffect(pos, CONST_ME_SLEEP)
doSendMagicEffect(pos, CONST_ME_SLEEP)
function sendBedEffect(position)
if not position then
return false
end
local item = 7793
if getTileItemById(position, item).uid > 0 then
doSendMagicEffect(position, CONST_ME_SLEEP)
local sleepEvent = addEvent(sendBedEffect, 3000, position)
-- will queue this function, so it executes again after 3s, this will cause a loop
end
return true
end
local events = {}
local function sendBedEffect(cid, pos)
if isPlayer(cid) then
stopEvent(events[cid])
events[cid] = nil
end
doSendMagicEffect(pos, CONST_ME_SLEEP)
events[cid] = addEvent(sendBedEffect, 3000, cid, pos)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
events[cid] = addEvent(sendBedEffect, 3000, cid, toPosition)
return true
end