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

[Error] Last Man Standing

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
Code:
local t = {
    tmp =     {
            {x = 376, y = 461, z = 7}, -- quina à noroeste (acima e à esquerda) da area onde os players devem estar para ingressar no evento
            {x = 392, y = 475, z = 7} -- quina à Sudeste (abaixo e à direita)
            },
    arena = {
            {x = 364, y = 366, z = 7}, -- Quina de cima e à esquerda
            {x = 389, y = 391, z = 7}, -- quina de baixo e à direita
            {x = 375, y = 374, z = 7} -- Centro da Arena
            },
   
    noPlayers = {x=178, y=64, z=7}, -- Para onde serão teleportados caso não haja campeão
    semChamps = {x=178, y=64, z=7}, -- Local para onde serão teleportados os 'players' caso passem os minutos sem campeão
           
    from = {x = 364, y = 366, z = 7}, -- quina de cima e à esquerda de onde os players serão transportados (escolha será aleatória)
    to = {x = 389, y = 391, z = 7}, -- quina de baixo e à direita de onde os players serão transportados (escolha será aleatória)

    minPlayers = 12, -- Número mínimo de players para iniciar o evento
    noPlayers = 1, -- Se houver este número de player na área o evento não começa
    prize = {6527}, -- prêmio que o vencedor vai receber
    expRewChamps = 125000, -- Coloque aqui a experiência que o campeão ganhará. Deixe zero se não quiser.
    expRewPart = 5000 -- Coloque aqui a experiência que todos os 'players' que participarão ganharão. Deixe zero se não quiser.
}

local kick = 0

function onTime()
    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, "[lastManStanding] Ganhou o evento!")
                doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." venceu o evento Last Man Standing.")
                doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 10)
                    if (t.expRewChamps > 0) then
                        doPlayerAddExperience(arenaPlayers[1],t.expRewChamps)
                        doSendMagicEffect(getPlayerPosition(arenaPlayers[1]), CONST_ME_MAGIC_RED)
                        doSendAnimatedText(getPlayerPosition(arenaPlayers[1]), "Exp!", TEXTCOLOR_WHITE)
                    end
                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],t.semChamps)
                        if (t.expRewPart > 0) then
                            doPlayerAddExperience(arenaPlayers[1],t.expRewPart)
                        end   
                        doPlayerSendTextMessage(arenaPlayers[i], MESSAGE_STATUS_WARNING, "Muito tarde, tente de novo mais tarde.")
                    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, "[lastManStanding] A batalha começou!")
                end
            else
                for i = 1, #players do
                    doTeleportThing(players[i], t.noPlayers)
                    doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "[lastManStanding] Nao começou porque nao haviam personagens suficientes!")
                end
            end
        end
    return true
end

error.png
 
try:
Code:
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)}
    local thing = players[i]
    doTeleportThing(thing, p)
    doSendMagicEffect(p, CONST_ME_TELEPORT)
    doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "[lastManStanding] A batalha começou!")
end
 
Your error is here t.noPlayers on line 106 in the function doTeleportThing.

But is define in the t table as
Code:
noPlayers = 1, -- Se houver este número de player na área o evento não começa
doTeleportThing parameters are doTeleportThing(cid, position), 1 is not a position.
 
Back
Top