• 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!

LMS globalevent Time problem

Sweetlove

Member
Joined
Jun 22, 2009
Messages
270
Reaction score
14
Location
Sverige
Hey!

Dunno if im going crazy or just retarded, bit of both i guess but nwm that! here's my problem, i use 0.4 and it's in milliseconds isnt it ? instead of interval "1" its "1000" , right? anyways, my LMS tp appears like it should and it brings me to correct location, my lastman.lua script also brings me from waiting room to arena BUT!! lets say i want the tp to appear each 10 min i put "600000" and then i guess i have to put "720000" on the lastman.lua cuz it's the one that brings me to the arena, but it's also the same that brings the winner back to tempel, so my problem is that after , 10 min to tp open,2 min in waiting room but then ofc the winner has to wait 12 min to get teleported back out cuz the script does not refresh correctly.
lastman.lua
Code:
local t = {
    tmp = {
        {x = 1124, y = 1009, z = 7}, -- northwest corner of area where players must stand in order to join the event
        {x = 1130, y = 1015, z = 7} -- south east corner
    },
    arena = {
        {x = 1116, y = 1001, z = 6}, -- nw corner of arena
        {x = 1130, y = 1015, z = 6}, -- se corner of arena
        {x = 1123, y = 1008, z = 6} -- center of arena
    },
  
    from = {x = 1116, y = 1001, z = 6}, -- top left cornor of the playground (random players teleportation)
    to = {x = 1130, y = 1015, z = 6}, -- bottom right cornor of the playground (random players teleportation)
  
    minPlayers = 2, -- min players required to start the battle
    noPlayers = 1, -- no players
    prize = {6527} -- rewards
}
local kick = 0

function onThink()
    local arenaPlayers = {}

    for x = t.arena[1].x, t.arena[2].x do
        for y = t.arena[1].y, t.arena[2].y do
            for z = t.arena[1].z, t.arena[2].z do
                local pos = {x = x, y = y, z = z}
                local n = getTileInfo(pos).creatures
                if n ~= 0 then
                    pos.stackpos = 1
                    local c = getThingfromPos(pos)
                    while c.uid ~= 0 do
                        if c.itemid == 1 and c.type == 1 then
                            table.insert(arenaPlayers, c.uid)
                            if #arenaPlayers == n then
                                break
                            end
                        end
                        pos.stackpos = pos.stackpos + 1
                        c = getThingfromPos(pos)
                    end
                end
            end
        end
    end

    if #arenaPlayers == 1 then
        local p = getPlayerMasterPos(arenaPlayers[1])
        doTeleportThing(arenaPlayers[1], p)
        doSendMagicEffect(p, CONST_ME_TELEPORT)
        doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You won a battle and received your reward.")
        doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing battle.")
        doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 10)
        kick = 0

    elseif #arenaPlayers > 1 then
        if kick == 0 then
            kick = os.time()
        else
            if os.time() - kick >= 840 then
                kick = 0
                for i = 1, #arenaPlayers do
                    doTeleportThing(arenaPlayers[i], {x=1000, y=1005, z=7})
                    doPlayerSendTextMessage(arenaPlayers[i], MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
                end
            end
        end
    elseif #arenaPlayers == 0 then
        kick = 0
      
        local players = {}
        for x = t.tmp[1].x, t.tmp[2].x do
            for y = t.tmp[1].y, t.tmp[2].y do
                for z = t.tmp[1].z, t.tmp[2].z do
                    local c = getTopCreature({x = x, y = y, z = z})
                    if c.type == 1 then
                        table.insert(players, c.uid)
                    end
                end
            end
        end

        if #players >= t.minPlayers then
            for i = 1, #players do
                local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
                doTeleportThing(players[i], p)
                doSendMagicEffect(p, CONST_ME_TELEPORT)
                doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
            end
        else
            for i = 1, #players do
                doTeleportThing(players[i], {x=1000, y=1005, z=7})
                doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
            end
        end
    end
  return true
end

lastmantp.lua

Code:
local createpos = {x=1001,y=1006,z=6}
local topos = {x=1127,y=1012,z=7}
local msg = "Last man standing event TP has now closed! It will open again in 30 minutes!"
local timetoclose = 120          -- in second
local function remove()
    local tp = getTileItemById(createpos,1387).uid
    if tp ~= 0 then
        doRemoveItem(tp)
        doBroadcastMessage(msg)
    end
end

function onThink(interval)
    doCreateTeleport(1387, topos, createpos)
    doBroadcastMessage("Last man standing event TP is now open!\nCatch the teleport within "..timetoclose.." seconds quickly! Located in Thais depot, reward 10 game tokens!")
    addEvent(remove,timetoclose*1000)
    return true
end

Also if i lower the lastman.lua interval it will instant tp first players that enter waiting room.
All help is super appreciated!

Kind regards!

bump
 
Last edited by a moderator:
im pretty sure 0.4 uses miliseconds......-.- 0.3.6 uses seconds, however even if it were seconds it would still be executed each 10 min and it would take 10 min for the winner to be announced ..
 
Back
Top