Ir para conteúdo

Featured Replies

Postado

alguem poderia me ajuda para esse sistema de alavanca levar de 1 a 10 players igual no global e nao só apenas 10 ?

-- CONFIG --
    local playersOnly = "no"
    local questLevel = 1
    local STORAGE_BOSS_CD = 17457
    local cdtime = 1 * 1 * 1 -- exhaust in seconds

    local room = {     -- boss room
        fromX = 1802,
        fromY = 675,
        fromZ = 7,
        --------------
        toX = 1868,
        toY = 724,
        toZ = 7
    }

    local monster_pos = {
        [1] = {pos = {1837, 716, 7}, monster = "Cursed Prospector Soul"}
    }

    local players_pos = {
        {x = 1834, y = 702, z = 6, stackpos = 253},
        {x = 1834, y = 701, z = 6, stackpos = 253},
        {x = 1835, y = 701, z = 6, stackpos = 253},
        {x = 1836, y = 701, z = 6, stackpos = 253},
        {x = 1837, y = 701, z = 6, stackpos = 253},
        {x = 1838, y = 701, z = 6, stackpos = 253},
        {x = 1837, y = 702, z = 6, stackpos = 253},
        {x = 1836, y = 702, z = 6, stackpos = 253},
        {x = 1835, y = 702, z = 6, stackpos = 253},
        {x = 1838, y = 702, z = 6, stackpos = 253}
    }

    local new_player_pos = {
        {x = 1830, y = 715, z = 7},
        {x = 1842, y = 715, z = 7},
        {x = 1836, y = 720, z = 7},
        {x = 1836, y = 710, z = 7},
        {x = 1836, y = 715, z = 7},
        {x = 1836, y = 715, z = 7},
        {x = 1835, y = 713, z = 7},
        {x = 1833, y = 721, z = 7},
        {x = 1838, y = 718, z = 7},
        {x = 1837, y = 718, z = 7}
    }
-- CONFIG END --

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local all_ready, monsters, player, level = 0, 0, {}, 0

    if item.itemid == 9826 then
        for i = 1, #players_pos do
            table.insert(player, 0)
        end
        for i = 1, #players_pos do
            player[i] = getThingfromPos(players_pos[i])
            if player[i].itemid > 0 then
                if string.lower(playersOnly) == "yes" then
                    if isPlayer(player[i].uid) == true then
                        all_ready = all_ready+1
                    else
                        monsters = monsters+1
                    end
                else
                    all_ready = all_ready+1
                end
            end
        end
        if all_ready == #players_pos then
            for i = 1, #players_pos do
                player[i] = getThingfromPos(players_pos[i])
                if isPlayer(player[i].uid) == true then
                    if getPlayerStorageValue(player[i].uid,STORAGE_BOSS_CD) > os.time() then
                        doPlayerSendCancel(cid,"Acesso so liberado a cada 20h.")
                        return false
                    end
                    if getPlayerLevel(player[i].uid) >= questLevel then
                        level = level+1
                    end
                else
                    level = level+1
                end
            end
            if level == #players_pos then
                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                    for _, area in pairs(monster_pos) do
                        doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
                    end
                    for i = 1, #players_pos do
                        doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                        doTeleportThing(player[i].uid, new_player_pos[i])
                        doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                        setPlayerStorageValue(player[i].uid,STORAGE_BOSS_CD,os.time() + cdtime)
                    end
                    doTransformItem(item.uid,9825)
                else
                    doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
                    return false
                end
            else
                doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
                return false
            end
        else
            doPlayerSendCancel(cid,"You need "..table.getn(players_pos).." players to do this quest.")
            return false
        end
    elseif item.itemid == 9825 then
        local player_room = 0
        for x = room.fromX, room.toX do
            for y = room.fromY, room.toY do
                for z = room.fromZ, room.toZ do
                    local pos = {x=x, y=y, z=z,stackpos = 253}
                    local thing = getThingfromPos(pos)
                    if thing.itemid > 0 then
                        if isPlayer(thing.uid) == true then
                            player_room = player_room+1
                        end
                    end
                end
            end
        end
        if player_room >= 1 then
            doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")
            return false
        elseif player_room == 0 then
            for x = room.fromX, room.toX do
                for y = room.fromY, room.toY do
                    for z = room.fromZ, room.toZ do
                        local pos = {x=x, y=y, z=z,stackpos = 253}
                        local thing = getThingfromPos(pos)
                        if thing.itemid > 0 then
                            doRemoveCreature(thing.uid)
                        end
                    end
                end
            end
            doTransformItem(item.uid,9826)
        end
    end

    return true
end

 

Postado
  • Autor
8 horas atrás, Toruk disse:

Acho q mudar essa linha pode funcionar:



if all_ready == #players_pos then

Para:



if all_ready > 0 then

e nao é que funcionou.

mas ficou aparecendo isso.

 

[Error - Action Interface]
data/actions/scripts/alavanca/bosspox.lua:onUse
Description:
(luaDoCreatureSetStorage) Creature not found

Editado por carloos (veja o histórico de edições)

Postado

O que acontece é o seguinte:

Agora que tu mudou o all_ready para maior que 0, ele vai fazer um loop e alterar o valor da storage para todos os players da tabela nomeada player, mesmo que não tenha todos os players, por tanto acontece este erro.

Para arrumar isso, basta adicionar uma verificação de isPlayer dentro do loop, como isto:

-- CONFIG --
local playersOnly = "no"
local questLevel = 1
local STORAGE_BOSS_CD = 17457
local cdtime = 1 * 1 * 1 -- exhaust in seconds

local room = { -- boss room
    fromX = 1802,
    fromY = 675,
    fromZ = 7,
    --------------
    toX = 1868,
    toY = 724,
    toZ = 7
}

local monster_pos = {
    [1] = { pos = { 1837, 716, 7 }, monster = "Cursed Prospector Soul" }
}

local players_pos = {
    { x = 1834, y = 702, z = 6, stackpos = 253 },
    { x = 1834, y = 701, z = 6, stackpos = 253 },
    { x = 1835, y = 701, z = 6, stackpos = 253 },
    { x = 1836, y = 701, z = 6, stackpos = 253 },
    { x = 1837, y = 701, z = 6, stackpos = 253 },
    { x = 1838, y = 701, z = 6, stackpos = 253 },
    { x = 1837, y = 702, z = 6, stackpos = 253 },
    { x = 1836, y = 702, z = 6, stackpos = 253 },
    { x = 1835, y = 702, z = 6, stackpos = 253 },
    { x = 1838, y = 702, z = 6, stackpos = 253 }
}

local new_player_pos = {
    { x = 1830, y = 715, z = 7 },
    { x = 1842, y = 715, z = 7 },
    { x = 1836, y = 720, z = 7 },
    { x = 1836, y = 710, z = 7 },
    { x = 1836, y = 715, z = 7 },
    { x = 1836, y = 715, z = 7 },
    { x = 1835, y = 713, z = 7 },
    { x = 1833, y = 721, z = 7 },
    { x = 1838, y = 718, z = 7 },
    { x = 1837, y = 718, z = 7 }
}
-- CONFIG END --

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local all_ready, monsters, player, level = 0, 0, {}, 0

    if item.itemid == 9826 then
        for i = 1, #players_pos do
            table.insert(player, 0)
        end
        for i = 1, #players_pos do
            player[i] = getThingfromPos(players_pos[i])
            if player[i].itemid > 0 then
                if string.lower(playersOnly) == "yes" then
                    if isPlayer(player[i].uid) == true then
                        all_ready = all_ready + 1
                    else
                        monsters = monsters + 1
                    end
                else
                    all_ready = all_ready + 1
                end
            end
        end
        if all_ready > 0 then
            for i = 1, #players_pos do
                player[i] = getThingfromPos(players_pos[i])
                if isPlayer(player[i].uid) == true then
                    if getPlayerStorageValue(player[i].uid, STORAGE_BOSS_CD) > os.time() then
                        doPlayerSendCancel(cid, "Acesso so liberado a cada 20h.")
                        return false
                    end
                    if getPlayerLevel(player[i].uid) >= questLevel then
                        level = level + 1
                    end
                else
                    level = level + 1
                end
            end
            if level == #players_pos then
                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                    for _, area in pairs(monster_pos) do
                        doSummonCreature(area.monster, { x = area.pos[1], y = area.pos[2], z = area.pos[3] })
                    end
                    for i = 1, #players_pos do
                        if isPlayer(player[i].uid) then
                            doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                            doTeleportThing(player[i].uid, new_player_pos[i])
                            doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                            setPlayerStorageValue(player[i].uid, STORAGE_BOSS_CD, os.time() + cdtime)
                        end
                    end
                    doTransformItem(item.uid, 9825)
                else
                    doPlayerSendTextMessage(cid, 19, "Only players can do this quest.")
                    return false
                end
            else
                doPlayerSendTextMessage(cid, 19, "All Players have to be level " .. questLevel .. " to do this quest.")
                return false
            end
        else
            doPlayerSendCancel(cid, "You need " .. table.getn(players_pos) .. " players to do this quest.")
            return false
        end
    elseif item.itemid == 9825 then
        local player_room = 0
        for x = room.fromX, room.toX do
            for y = room.fromY, room.toY do
                for z = room.fromZ, room.toZ do
                    local pos = { x = x, y = y, z = z, stackpos = 253 }
                    local thing = getThingfromPos(pos)
                    if thing.itemid > 0 then
                        if isPlayer(thing.uid) == true then
                            player_room = player_room + 1
                        end
                    end
                end
            end
        end
        if player_room >= 1 then
            doPlayerSendTextMessage(cid, 19, "There is already a team in the quest room.")
            return false
        elseif player_room == 0 then
            for x = room.fromX, room.toX do
                for y = room.fromY, room.toY do
                    for z = room.fromZ, room.toZ do
                        local pos = { x = x, y = y, z = z, stackpos = 253 }
                        local thing = getThingfromPos(pos)
                        if thing.itemid > 0 then
                            doRemoveCreature(thing.uid)
                        end
                    end
                end
            end
            doTransformItem(item.uid, 9826)
        end
    end

    return true
end

 

Editado por Anderson Sacani (veja o histórico de edições)

Postado
  • Autor
3 horas atrás, Anderson Sacani disse:

O que acontece é o seguinte:

Agora que tu mudou o all_ready para maior que 0, ele vai fazer um loop e alterar o valor da storage para todos os players da tabela nomeada player, mesmo que não tenha todos os players, por tanto acontece este erro.

Para arrumar isso, basta adicionar uma verificação de isPlayer dentro do loop, como isto:


-- CONFIG --
local playersOnly = "no"
local questLevel = 1
local STORAGE_BOSS_CD = 17457
local cdtime = 1 * 1 * 1 -- exhaust in seconds

local room = { -- boss room
    fromX = 1802,
    fromY = 675,
    fromZ = 7,
    --------------
    toX = 1868,
    toY = 724,
    toZ = 7
}

local monster_pos = {
    [1] = { pos = { 1837, 716, 7 }, monster = "Cursed Prospector Soul" }
}

local players_pos = {
    { x = 1834, y = 702, z = 6, stackpos = 253 },
    { x = 1834, y = 701, z = 6, stackpos = 253 },
    { x = 1835, y = 701, z = 6, stackpos = 253 },
    { x = 1836, y = 701, z = 6, stackpos = 253 },
    { x = 1837, y = 701, z = 6, stackpos = 253 },
    { x = 1838, y = 701, z = 6, stackpos = 253 },
    { x = 1837, y = 702, z = 6, stackpos = 253 },
    { x = 1836, y = 702, z = 6, stackpos = 253 },
    { x = 1835, y = 702, z = 6, stackpos = 253 },
    { x = 1838, y = 702, z = 6, stackpos = 253 }
}

local new_player_pos = {
    { x = 1830, y = 715, z = 7 },
    { x = 1842, y = 715, z = 7 },
    { x = 1836, y = 720, z = 7 },
    { x = 1836, y = 710, z = 7 },
    { x = 1836, y = 715, z = 7 },
    { x = 1836, y = 715, z = 7 },
    { x = 1835, y = 713, z = 7 },
    { x = 1833, y = 721, z = 7 },
    { x = 1838, y = 718, z = 7 },
    { x = 1837, y = 718, z = 7 }
}
-- CONFIG END --

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local all_ready, monsters, player, level = 0, 0, {}, 0

    if item.itemid == 9826 then
        for i = 1, #players_pos do
            table.insert(player, 0)
        end
        for i = 1, #players_pos do
            player[i] = getThingfromPos(players_pos[i])
            if player[i].itemid > 0 then
                if string.lower(playersOnly) == "yes" then
                    if isPlayer(player[i].uid) == true then
                        all_ready = all_ready + 1
                    else
                        monsters = monsters + 1
                    end
                else
                    all_ready = all_ready + 1
                end
            end
        end
        if all_ready > 0 then
            for i = 1, #players_pos do
                player[i] = getThingfromPos(players_pos[i])
                if isPlayer(player[i].uid) == true then
                    if getPlayerStorageValue(player[i].uid, STORAGE_BOSS_CD) > os.time() then
                        doPlayerSendCancel(cid, "Acesso so liberado a cada 20h.")
                        return false
                    end
                    if getPlayerLevel(player[i].uid) >= questLevel then
                        level = level + 1
                    end
                else
                    level = level + 1
                end
            end
            if level == #players_pos then
                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                    for _, area in pairs(monster_pos) do
                        doSummonCreature(area.monster, { x = area.pos[1], y = area.pos[2], z = area.pos[3] })
                    end
                    for i = 1, #players_pos do
                        if isPlayer(player[i].uid) then
                            doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                            doTeleportThing(player[i].uid, new_player_pos[i])
                            doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                            setPlayerStorageValue(player[i].uid, STORAGE_BOSS_CD, os.time() + cdtime)
                        end
                    end
                    doTransformItem(item.uid, 9825)
                else
                    doPlayerSendTextMessage(cid, 19, "Only players can do this quest.")
                    return false
                end
            else
                doPlayerSendTextMessage(cid, 19, "All Players have to be level " .. questLevel .. " to do this quest.")
                return false
            end
        else
            doPlayerSendCancel(cid, "You need " .. table.getn(players_pos) .. " players to do this quest.")
            return false
        end
    elseif item.itemid == 9825 then
        local player_room = 0
        for x = room.fromX, room.toX do
            for y = room.fromY, room.toY do
                for z = room.fromZ, room.toZ do
                    local pos = { x = x, y = y, z = z, stackpos = 253 }
                    local thing = getThingfromPos(pos)
                    if thing.itemid > 0 then
                        if isPlayer(thing.uid) == true then
                            player_room = player_room + 1
                        end
                    end
                end
            end
        end
        if player_room >= 1 then
            doPlayerSendTextMessage(cid, 19, "There is already a team in the quest room.")
            return false
        elseif player_room == 0 then
            for x = room.fromX, room.toX do
                for y = room.fromY, room.toY do
                    for z = room.fromZ, room.toZ do
                        local pos = { x = x, y = y, z = z, stackpos = 253 }
                        local thing = getThingfromPos(pos)
                        if thing.itemid > 0 then
                            doRemoveCreature(thing.uid)
                        end
                    end
                end
            end
            doTransformItem(item.uid, 9826)
        end
    end

    return true
end

 

MUITO OBRIGADO PELA ATENÇAO.

acabei de testar e agora está dando este erro :(

me ajuda pf

[Error - Action Interface]
data/actions/scripts/alavanca/bossdeath.lua:onUse
Description:
(luaGetThingFromPos) Tile not found

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo