• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Script with counting \ Help

Godz4t4n1c

New Member
Joined
Sep 9, 2015
Messages
51
Reaction score
1
good morning to all!, I need your help I have a script that works perfectly but the only problem is that you can not change the time to open and close, that is only in 10 minutes it opens and 1 minute closes, I need help

Code:
local tp = {
    itemID = 1387, -- Id del objeto que aparecerá haciendo de teleport.
    createPos = {x = 1200, y = 1135, z = 7}, -- Coordenada del lugar donde será creado el cual.
    takePlayer = {x = 232, y = 1536, z = 5}, -- Coordenada del lugar donde llevará a los jugadores.
    belero = { -- Efecto Mágico que aparecerá en el portal al...
      CONST_ME_TELEPORT, -- ...abrirse.
      CONST_ME_LOSEENERGY, -- ...cerrarse.
    },
    timePortal = { -- Tiempo que el portal permanecerá...
      opens = 2, -- ...abierto. (contado en Minutos)
      close = 1, -- ...cerrado. (contado en Horas)
    },
    countColor = COLOR_RED, -- Color de la cuenta atrás que transcurrirá hasta abrirse.

    msgabierto = "El Portal del Evento Run esta abierto!!!!, Corre que tienes 1 minuto para entrar!!",
    msgcerrado = "El evento run se acaba de cerrar!, se volvera abrir dentro de 3 horas.",
  }

function AnimatedTime(timeDiff, pos, color)
    if isNumber(timeDiff) then
      local dateFormat = {
        {"h", timeDiff / 60 / 60 % 24},
        {"m", timeDiff / 60 % 60},
        {"s", timeDiff % 60}
      }

      local out = {}
        for k, t in ipairs(dateFormat) do
          local v = math.floor(t[2])
            if(v > 0) then
                table.insert(out, v .. t[1])
            end
        end
      local ret = table.concat(out)

      return doSendAnimatedText(pos, ret, color)
    end
end

function CloseTP()
  local t = getTileItemById(tp.createPos, tp.itemID).uid
    if t > 0 then
        doRemoveItem(t)
        doSendMagicEffect (tp.createPos, tp.belero[2])
        doBroadcastMessage(tp.msgcerrado, MESSAGE_EVENT_ADVANCE)
    end

    for i = 0, tp.timePortal.close * 10 * 60 do
      local c = tp.timePortal.close * 10 * 60 - i
        addEvent(AnimatedTime, i * 1000, tostring(c), tp.createPos, tp.countColor)
    end
end

function OpenTP()
    doSendMagicEffect (tp.createPos, tp.belero[1])
    doCreateTeleport (tp.itemID, tp.takePlayer, tp.createPos)
    doBroadcastMessage(tp.msgabierto, MESSAGE_EVENT_ADVANCE)

    for i = 0, tp.timePortal.opens * 10 do
      local c = tp.timePortal.opens * 10 - i
        addEvent(AnimatedTime, i * 1000, tostring(c), tp.createPos, tp.countColor)
    end
    addEvent (CloseTP, tp.timePortal.opens * 10 * 1000)

    addEvent (OpenTP, (tp.timePortal.close * 10 * 60 * 1000) + (tp.timePortal.opens * 10 * 1000))
  return true
end

function onStartup()
    for i = 0, tp.timePortal.close * 10 * 60 do
      local c = tp.timePortal.close * 10 * 60 - i
        addEvent(AnimatedTime, i * 1000, tostring(c), tp.createPos, tp.countColor)
    end

    addEvent(OpenTP, tp.timePortal.close * 10 * 60 * 1000)
end

I want it to open 3 hours, and close 1 minute

I would also like to know if this script can be linked so that the zombie event can be activated

Thanks in advance!
 
timePortal = {- Time the portal will remain ...
opens = 2, - ... open. (counted in minutes)
close = 1, - ... closed. (counted in Hours)
},

in the closed part, 1 = 10 minutes

if you put 18 = 180 = 3 hours

and open, 10 = 1 minute open

Hunter event: [8.60] Hunter Event

PSDT: I want to know if this script can be linked to the zombie event or the hunter event, with the start
 
Back
Top