Ir para conteúdo

Featured Replies

Postado

esse sistema da regen de vida é de acordo com o level do personagem, eu gostaria que esse regen de vida fosse de acordo com o distance fighting do personagem

 

local function heal(uid, info, mana)

    if not isCreature(uid) then
        return true
    end
 
    local level = getPlayerLevel(uid)
    for _, v in ipairs(info) do
        if level >= v.level.min and level <= v.level.max then
            if mana then
                if not getTileInfo(getThingPos(uid)).protection then
                    doCreatureAddMana(uid, v.mana.reg)
                end
 
                addEvent(heal, v.mana.interval * 1000, uid, info, true)
            else
                if not getTileInfo(getThingPos(uid)).protection then
                    doCreatureAddHealth(uid, v.hp.reg)
                end
 
                addEvent(heal, v.hp.interval * 1000, uid, info)
            end
 
            break
        end
    end
   
    return true
end
 
function onLogin(cid)
 
local vocations = {
    [2] = {
        {level = {min = 0, max = 14}, hp = {reg = 5, interval = 5}, mana = {reg = 1, interval = 3}},
        {level = {min = 15, max = 29}, hp = {reg = 15, interval = 5}, mana = {reg = 2, interval = 3}},
        {level = {min = 30, max = 44}, hp = {reg = 30, interval = 5}, mana = {reg = 2, interval = 3}},
 {level = {min = 45, max = 59}, hp = {reg = 42, interval = 5}, mana = {reg = 3, interval = 3}},
 {level = {min = 60, max = 74}, hp = {reg = 55, interval = 5}, mana = {reg = 4, interval = 3}},
 {level = {min = 75, max = 99999}, hp = {reg = 70, interval = 5}, mana = {reg = 4, interval = 3}},
    }
}
 
    if vocations[getPlayerVocation(cid)] then
        heal(cid, vocations[getPlayerVocation(cid)], true)
        heal(cid, vocations[getPlayerVocation(cid)])
    end
   
    return true
end

 

Postado
  • Autor

 

Troque:
local level = getPlayerLevel(uid)
por:
local level = getPlayerSkillLevel(uid, SKILL_DISTANCE)

 

Ja testei esse seu metodo antes e obtive o seguinte erro: 

 

[3/9/2015 18:59:14] [Error - CreatureScript Interface] 

[3/9/2015 18:59:14] data/creaturescripts/scripts/regeneration.lua:onLogin
[3/9/2015 18:59:14] Description: 
[3/9/2015 18:59:14] data/creaturescripts/scripts/regeneration.lua:8: attempt to compare nil with number
[3/9/2015 18:59:14] stack traceback:
[3/9/2015 18:59:14]  data/creaturescripts/scripts/regeneration.lua:8: in function 'heal'
[3/9/2015 18:59:14]  data/creaturescripts/scripts/regeneration.lua:44: in function <data/creaturescripts/scripts/regeneration.lua:30>

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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo