Can the same person enter again after 20 hours?Hello everyone looking for a script for the boss teleport in the teleport you can enter every 20 hours for one person
Right.Yes, every person every 20 hours
local config = {
[58059] = {timer = 517635,
range = 13,
newPos = Position(31674, 31363, 9),
bossName = 'Unaz The Mean',
bossPos = Position(31681, 31369, 9)}
}
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return
end
local teleport = config[item.actionid]
if not teleport then
return
end
if player:getStorageValue(teleport.timer) > os.time() then
position:sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(fromPosition)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:say('You have to wait to challenge this enemy again!', TALKTYPE_MONSTER_SAY)
return true
end
if roomIsOccupied(teleport.bossPos, teleport.range, teleport.range) then
position:sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(fromPosition)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:say('Someone is fighting against the boss! You need wait awhile.', TALKTYPE_MONSTER_SAY)
return true
end
clearRoom(teleport.bossPos, teleport.range, teleport.range, fromPosition)
local monster = Game.createMonster(teleport.bossName, teleport.bossPos, true, true)
if not monster then
return true
end
position:sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(teleport.newPos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:say('You have ten minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.', TALKTYPE_MONSTER_SAY)
addEvent(clearBossRoom, 60 * 10 * 1000, player.uid, monster.uid, teleport.bossPos, teleport.range, teleport.range, fromPosition)
player:setStorageValue(teleport.timer, os.time() + 20 * 3600)
return true
end
function clearBossRoom(playerId, bossId, centerPosition, rangeX, rangeY, exitPosition)
local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() and spectator.uid == playerId then
spectator:teleportTo(exitPosition)
exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if spectator:isMonster() then
spectator:remove()
end
end
end
function clearRoom(centerPosition, rangeX, rangeY, exitPosition)
local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isMonster() then
spectator:remove()
end
end
end
function roomIsOccupied(centerPosition, rangeX, rangeY)
local spectators = Game.getSpectators(centerPosition, false, true, rangeX, rangeX, rangeY, rangeY)
if #spectators ~= 0 then
return true
end
return false
end