• 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 LMS Bug

sirspray

New Member
Joined
Dec 15, 2012
Messages
93
Reaction score
2
Location
Sweden
Hello, my last man standig event is bugged, evreything works good but when the events starts it works in the room BUT the winner dosent get tp back to temple and dosent get an reward and it dosent broadcast when he wins! anyone could help me with this?

Lua:
 local t = {
    tmp = {
        {x = 32535, y = 32219, z = 7}, -- northwest corner of area where players must stand in order to join the event
        {x = 32539, y = 32221, z = 7} -- south east corner
    },
    arena = {
        {x = 32541, y = 32215, z = 7}, -- nw corner of arena
        {x = 32378, y = 32222, z = 7}, -- se corner of arena
        {x = 32372, y = 32217, z = 7} -- center of arena
    },
  
    from = {x = 32541, y = 32215, z = 7}, -- top left cornor of the playground (random players teleportation)
    to = {x = 32553, y = 32225, z = 7}, -- bottom right cornor of the playground (random players teleportation)
  
    minPlayers = 2, -- min players required to start the battle
    noPlayers = 1, -- no players
    prize = {2160} -- 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=32369, y=32241, 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=32369, y=32240, 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
[/I][/I][/I][/I][/I][/I]
 
Last edited:
change
doTeleportThing(arenaPlayers[1], p) to
Code:
doTeleportThing(arenaPlayers[1], {x=32369, y=32240, z=7})


or add this in ur lib 05-function

Code:
function getPlayerMasterPos(cid)
   return getTownTemplePosition(getPlayerTown(cid))
end
 
Last edited:
change
doTeleportThing(arenaPlayers[1], p) to
Code:
doTeleportThing(arenaPlayers[1], {x=32369, y=32240, z=7})


or add this in ur lib 05-function

Code:
function getPlayerMasterPos(cid)
   return getTownTemplePosition(getPlayerTown(cid))
end

i did do this but nothing happens :/ same bug but no error in my server log
 
I thought it doesnt work as well, but it does, it just takes a lot of time, its the way script is built. I dunno how to change that, maybe someone does?
 
i did do this but nothing happens :/ same bug but no error in my server log
if you solved it post the solution.
don't just change the thread title and mark it solved, people with the same question won't be able to see your solution.
 
<globalevent name="arena" interval="60000" event="script" value="LMS/arena.lua"/>

that mean the winner will w8ing 1 min to get tp change it to 7000 not 60000 that for 0.4

if u use 0.3.6 change it to 7
 
<globalevent name="arena" interval="7000" event="script" value="LMS/arena.lua"/>

that mean winner will w8ing 7 sec to get tp
 
Try this

Code:
 local t = {
    tmp = {
        {x = 32535, y = 32219, z = 7}, -- northwest corner of area where players must stand in order to join the event
        {x = 32539, y = 32221, z = 7} -- south east corner
    },
    arena = {
        {x = 32541, y = 32215, z = 7}, -- nw corner of arena
        {x = 32378, y = 32222, z = 7}, -- se corner of arena
        {x = 32372, y = 32217, z = 7} -- center of arena
    },

    from = {x = 32541, y = 32215, z = 7}, -- top left cornor of the playground (random players teleportation)
    to = {x = 32553, y = 32225, z = 7}, -- bottom right cornor of the playground (random players teleportation)

    minPlayers = 2, -- min players required to start the battle
    noPlayers = 1, -- no players
    prize = {2160} -- 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
        player = getPlayerGUID(arenaPlayers[1])
        local p = getPlayerMasterPos(player)
        doTeleportThing(player, p)
        doSendMagicEffect(p, CONST_ME_TELEPORT)
        doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_BLUE, "You won a battle and received your reward.")
        doBroadcastMessage(getCreatureName(player) .." won a Last Man Standing battle.")
        doPlayerAddItem(player, 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=32369, y=32241, 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=32369, y=32240, 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
 
Back
Top