Ir para conteúdo

Featured Replies

Postado

.Qual servidor ou website você utiliza como base? 

baiak 8.60 

Qual o motivo deste tópico? 

Ajuda com erro sistema de cave exclusiva 

Está surgindo algum erro? Se sim coloque-o aqui. 

Citar

Description:
data/lib/huntsTime.lua:5: attempt to index global 'Player' (a nil value)
[Warning - LuaInterface::initState] Cannot load data/lib/

 

Você tem o código disponível? Se tiver publique-o aqui: 

local tempo = 14400
local insideCave = 11500
ID_CAVE_EXCLUSIVA = 8981

function player:leaveCaveTime(monsterid)
    self:setStorageValue(insideCave, 0)
    self:teleportToTown()
    self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Seu tempo na cave esgotou-se, você foi teleportado para o templo.")
end
function player:enterCave()
    local getRentedCave = self:getRentedCave()
    if(getRentedCave == false) then
        return false
    end
    self:teleportTo(getRentedCave.position)
    doSendMagicEffect(getPlayerPosition(self.cid), 37)
    self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[CAVE EXCLUSIVA] Você entrou na hunt de "..getRentedCave.monster..".")
        
    return true
end

function player:addRandomCave()
    local caves = getCavesHunt()
    local randomCave = caves[math.random(1, #caves)]
    local itemCave = self:addItem(ID_CAVE_EXCLUSIVA, 1)
    Item.setNameMonsterCave(itemCave, randomCave)
end
function Item.getCaveMonster(item)
    return string.match(getItemName(item.uid),  "%[(.-)%]")
end
function Item.setNameMonsterCave(item, monster)
    doItemSetAttribute(item, "name", "".. getItemName(item) .." [".. monster .."]")
end

function getCavesHunt()
    local query = db.getResult("SELECT distinct monster from cave_rent")
    local caves = {}
    
    while(true) do
        table.insert(caves, query:getDataString("monster"))
        if not(result.next(query)) then
            break
        end
    end
    
    result.free(query)
   
   return caves
end

function updateStatusCave(monsterid, playerid)
    if(playerid ~= nil) then
        db.query("UPDATE cave_rent SET vacancy = "..playerid..", time = ".. os.time() + tempo.." WHERE id = "..monsterid.."")
    else
        db.query("UPDATE cave_rent SET vacancy = 0, time = 0 WHERE id = "..monsterid.."")
    end
end

function caveAvailable(monsterCave)
    if(monsterCave == nil) then
        return false
    end
    for _, monster in pairs(getCavesHunt()) do
        if(monster:lower() == monsterCave:lower()) then
            local query = db.getResult("SELECT * from cave_rent WHERE monster = '"..monsterCave.."' and vacancy = 0")
            if(query:getID() == -1) then
                return false
            end        
            return {id = tonumber(query:getDataInt("id")), name = tostring(query:getDataString("monster")), position = {x = tonumber(query:getDataInt("x")), y = tonumber(query:getDataInt("y")), z = tonumber(query:getDataInt("z"))}}
        end
    end
    return false
end

function player:getRentedCave()
    local query = db.getResult("SELECT * from cave_rent WHERE vacancy = "..self:getGuid().."")
    
    if(query:getID() == -1) then
        return false
    end
    
    local rentedCave = {
        position = {
            x = query:getDataInt("x"), 
            y = query:getDataInt("y"), 
            z = query:getDataInt("z")
        },
        monster = query:getDataString("monster"),
        time = query:getDataInt("time")
    } 
    
    return rentedCave
end

function updateCaveExpired()
    local query = db.getResult("SELECT cave.id AS monsterid, cave.time, player.name, player.id AS player_id FROM cave_rent cave INNER JOIN players player ON cave.vacancy = player.id WHERE cave.time < "..os.time().."")
    local players = {}
    if(query:getID() == -1) then
        return false
    end
    while(true) do
        table.insert(players, {monsterid = query:getDataInt("monsterid"), name = query:getDataString("name"), player_id = query:getDataString("player_id")})
        if not(result.next(query)) then
            break
        end
    end
    if(next(players) == nil) then
        return false
    end
    
    for _, info in pairs(players) do
        local player = Player(info.name)
        if(player ~= nil) then
            local getStorage = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = "..info.player_id.." and `key` = "..insideCave.." and `value` = 1")
            if(getStorage ~= -1) then
                player:leaveCaveTime()
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Seu tempo na cave esgotou-se. Adquira outra entrada para ter acesso novamente.")
            end
        end
        updateStatusCave(info.monsterid)
    end
end

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

Deis de já agradeço a todos pela ajuda ....

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

Postado
  • Autor

Opa eu uso otx 0.5 do baiak pvp postado aqui no tibia king agora de qual versão e o script nao sei te informa .

 

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