• 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 [TALKACTION] TFS 0.4 8.60 command !aura on !aura off - Aura Heal - no Heal Health and Mana; It's Not Healing Neither Mana Nor Health

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
Location
São Paulo, Brazil
GitHub
Samuel10M
[TALKACTION] TFS 0.4 8.60 - Aura Heal - no Heal Health and Mana it's not healing neither mana nor health

Health:
Lua:
        aurastr = 25950 -- storage da aura
    estr = 25951 -- storage para o exhaust
    porcentagem = 100 -- chance de curar em cada volta da aura, em porcentagem
    quantheal = 999999 -- porcentagem do hp máximo que cada cura irá curar. (No caso, irá curar 10% do hp máximo cada cura)
    tempo = 1180 -- tempo para dar uma volta no player (este tempo foi o que achei mais agradável visualmente, é recomendável não mudar)
    tipoaura = 35 -- número do efeito da aura (efeito de distância, pode ser identificado com /x no jogo)
    efeitocura = 11 -- número do efeito quando a cura chega ao player (efeito de posição fixa, pode ser identificado com /z no jogo)

-- Função que chama a aura
function efeitosAura(i,tm,cid)
    if(isCreature(cid)) then
            local atual = getCreaturePosition(cid)
        local posaura = {
            {x=(atual.x)-1, y=(atual.y)-1, z=atual.z},
            {x=atual.x, y=(atual.y)-1, z=atual.z},
            {x=(atual.x)+1, y=(atual.y)-1, z=atual.z},
            {x=(atual.x)+1, y=atual.y, z=atual.z},
            {x=(atual.x)+1, y=(atual.y)+1, z=atual.z},
            {x=atual.x, y=(atual.y)+1, z=atual.z},
            {x=(atual.x)-1, y=(atual.y)+1, z=atual.z},
            {x=(atual.x)-1, y=atual.y, z=atual.z},
        }
        local chances = math.random(100)
        if(chances<=porcentagem/8 and getCreatureHealth(cid)<getCreatureMaxHealth(cid)) then
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid)/quantheal)
            if(i<=8 and i>1) then
                doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, atual, tipoaura)
            else
                doSendDistanceShoot({x=posaura[1].x, y=posaura[1].y, z=posaura[1].z}, atual, tipoaura)
            end
            doSendMagicEffect(atual, efeitocura)
        end
        if(i==8) then
            doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, {x=posaura[1].x, y=posaura[1].y, z=posaura[1].z}, tipoaura)
        elseif(i<8) then
            doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, {x=posaura[i+1].x, y=posaura[i+1].y, z=posaura[i+1].z}, tipoaura)
        end
        if(i<=8 and getPlayerStorageValue(cid, aurastr)==2) then
            i = i+1
            tm = tempo/8
            return addEvent(efeitosAura,tm,i,tm,cid)
        elseif(i>8 and getPlayerStorageValue(cid, aurastr)==2) then
            return efeitosAura(1,0,cid)
        else
            return TRUE
        end
    else
        return TRUE
    end
end

-- Função principal
function onSay(cid, words, param, channel)
    if(param=="on") then
        if getPlayerStorageValue(cid, estr) > os.time() then
            doPlayerSendCancel(cid, "Espere "..(getPlayerStorageValue(cid, estr) - os.time()).." segundos para poder habilitar aura novamente.")
        else
            if(getPlayerStorageValue(cid, aurastr)==2) then
                doPlayerSendCancel(cid,"Sua aura já está habilitada.")
            elseif(getPlayerStorageValue(cid, aurastr)==-1) then
                doPlayerSendCancel(cid,"Aura ligada!")
                setPlayerStorageValue(cid, aurastr, 2)
                efeitosAura(1,tempo/8,cid)
            end
        end
    elseif(param=="off") then
        if(getPlayerStorageValue(cid, aurastr)==2) then
            setPlayerStorageValue(cid, estr, os.time()+2)
            setPlayerStorageValue(cid, aurastr, -1)
            doPlayerSendCancel(cid,"Aura desligada!")
        end
    else   
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Digite '!aura on' para ligar sua aura, e '!aura off' para desligá-la.")
    end
    return TRUE
end

Mana:

Lua:
    aurastr = 25950 -- storage da aura
    estr = 25951 -- storage para o exhaust
    porcentagem = 100 -- chance de curar em cada volta da aura, em porcentagem
    quantheal = 999999 -- porcentagem do hp máximo que cada cura irá curar. (No caso, irá curar 10% do hp máximo cada cura)
    tempo = 1180 -- tempo para dar uma volta no player (este tempo foi o que achei mais agradável visualmente, é recomendável não mudar)
    tipoaura = 35 -- número do efeito da aura (efeito de distância, pode ser identificado com /x no jogo)
    efeitocura = 11 -- número do efeito quando a cura chega ao player (efeito de posição fixa, pode ser identificado com /z no jogo)

-- Função que chama a aura
function efeitosAura(i,tm,cid)
    if(isCreature(cid)) then
            local atual = getCreaturePosition(cid)
        local posaura = {
            {x=(atual.x)-1, y=(atual.y)-1, z=atual.z},
            {x=atual.x, y=(atual.y)-1, z=atual.z},
            {x=(atual.x)+1, y=(atual.y)-1, z=atual.z},
            {x=(atual.x)+1, y=atual.y, z=atual.z},
            {x=(atual.x)+1, y=(atual.y)+1, z=atual.z},
            {x=atual.x, y=(atual.y)+1, z=atual.z},
            {x=(atual.x)-1, y=(atual.y)+1, z=atual.z},
            {x=(atual.x)-1, y=atual.y, z=atual.z},
        }
        local chances = math.random(100)
        if(chances<=porcentagem/8 and getCreatureMana(cid)<getCreatureMaxMana(cid)) then
            doCreatureAddMana(cid, getCreatureMaxMana(cid)/quantheal)
            if(i<=8 and i>1) then
                doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, atual, tipoaura)
            else
                doSendDistanceShoot({x=posaura[1].x, y=posaura[1].y, z=posaura[1].z}, atual, tipoaura)
            end
            doSendMagicEffect(atual, efeitocura)
        end
        if(i==8) then
            doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, {x=posaura[1].x, y=posaura[1].y, z=posaura[1].z}, tipoaura)
        elseif(i<8) then
            doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, {x=posaura[i+1].x, y=posaura[i+1].y, z=posaura[i+1].z}, tipoaura)
        end
        if(i<=8 and getPlayerStorageValue(cid, aurastr)==2) then
            i = i+1
            tm = tempo/8
            return addEvent(efeitosAura,tm,i,tm,cid)
        elseif(i>8 and getPlayerStorageValue(cid, aurastr)==2) then
            return efeitosAura(1,0,cid)
        else
            return TRUE
        end
    else
        return TRUE
    end
end

-- Função principal
function onSay(cid, words, param, channel)
    if(param=="on") then
        if getPlayerStorageValue(cid, estr) > os.time() then
            doPlayerSendCancel(cid, "Espere "..(getPlayerStorageValue(cid, estr) - os.time()).." segundos para poder habilitar aura novamente.")
        else
            if(getPlayerStorageValue(cid, aurastr)==2) then
                doPlayerSendCancel(cid,"Sua aura já está habilitada.")
            elseif(getPlayerStorageValue(cid, aurastr)==-1) then
                doPlayerSendCancel(cid,"Aura ligada!")
                setPlayerStorageValue(cid, aurastr, 2)
                efeitosAura(1,tempo/8,cid)
            end
        end
    elseif(param=="off") then
        if(getPlayerStorageValue(cid, aurastr)==2) then
            setPlayerStorageValue(cid, estr, os.time()+2)
            setPlayerStorageValue(cid, aurastr, -1)
            doPlayerSendCancel(cid,"Aura desligada!")
        end
    else   
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Digite '!aura on' para ligar sua aura, e '!aura off' para desligá-la.")
    end
    return TRUE
end
 
Solution
The quantheal value is to high. You use it to fraction the max health/mana. So if you have for examp 2000 health, the actual healing would be 0.002 which I believe it is rounded to 0 I would recomend the following changes to script:
Fist change all constants to local and lower the quantheal to a value from 0 to 100 (percentage of healing):
Lua:
    local aurastr = 25950 -- storage da aura
    local estr = 25951 -- storage para o exhaust
    local porcentagem = 100 -- chance de curar em cada volta da aura, em porcentagem
    local quantheal = 50 -- porcentagem do hp máximo que cada cura irá curar. (No caso, irá curar 50% do hp máximo cada cura)
    local tempo = 1180 -- tempo para dar uma volta no player (este tempo foi o que achei...
The quantheal value is to high. You use it to fraction the max health/mana. So if you have for examp 2000 health, the actual healing would be 0.002 which I believe it is rounded to 0 I would recomend the following changes to script:
Fist change all constants to local and lower the quantheal to a value from 0 to 100 (percentage of healing):
Lua:
    local aurastr = 25950 -- storage da aura
    local estr = 25951 -- storage para o exhaust
    local porcentagem = 100 -- chance de curar em cada volta da aura, em porcentagem
    local quantheal = 50 -- porcentagem do hp máximo que cada cura irá curar. (No caso, irá curar 50% do hp máximo cada cura)
    local tempo = 1180 -- tempo para dar uma volta no player (este tempo foi o que achei mais agradável visualmente, é recomendável não mudar)
    local tipoaura = 35 -- número do efeito da aura (efeito de distância, pode ser identificado com /x no jogo)
    local efeitocura = 11 -- número do efeito quando a cura chega ao player (efeito de posição fixa, pode ser identificado com /z no jogo)
Also changing the line 25 in both scripts to:
Health:
Lua:
 doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(quantheal/100))
Mana:
Lua:
 doCreatureAddMana(cid, getCreatureMaxMana(cid)*(quantheal/100))

Also set the storages differents for each aura and different talkactions for each, so it will not conflict
 
Solution
@jacqen

how to join the two

doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(quantheal/100))
doCreatureAddMana(cid, getCreatureMaxMana(cid)*(quantheal/100))

Lua:
[07/11/2021 18:58:22] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/aura.lua:27: 'end' expected (to close 'if' at line 24) near 'if'
[07/11/2021 18:58:22] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/aura.lua)
[07/11/2021 18:58:22] data/talkactions/scripts/aura.lua:27: 'end' expected (to close 'if' at line 24) near 'if'

Lua:
aurastr = 25951 -- storage da aura
    estr = 25951 -- storage para o exhaust
    porcentagem = 100 -- chance de curar em cada volta da aura, em porcentagem
    quantheal = 999999 -- porcentagem do hp máximo que cada cura irá curar. (No caso, irá curar 10% do hp máximo cada cura)
    tempo = 2000 -- tempo para dar uma volta no player (este tempo foi o que achei mais agradável visualmente, é recomendável não mudar)
    tipoaura = 35 -- número do efeito da aura (efeito de distância, pode ser identificado com /x no jogo)
    efeitocura = 11 -- número do efeito quando a cura chega ao player (efeito de posição fixa, pode ser identificado com /z no jogo)

-- Função que chama a aura
function efeitosAura(i,tm,cid)
    if(isCreature(cid)) then
            local atual = getCreaturePosition(cid)
        local posaura = {
            {x=(atual.x)-1, y=(atual.y)-1, z=atual.z},
            {x=atual.x, y=(atual.y)-1, z=atual.z},
            {x=(atual.x)+1, y=(atual.y)-1, z=atual.z},
            {x=(atual.x)+1, y=atual.y, z=atual.z},
            {x=(atual.x)+1, y=(atual.y)+1, z=atual.z},
            {x=atual.x, y=(atual.y)+1, z=atual.z},
            {x=(atual.x)-1, y=(atual.y)+1, z=atual.z},
            {x=(atual.x)-1, y=atual.y, z=atual.z},
        }
        local chances = math.random(100)
        if(chances<=porcentagem/8 and getCreatureHealth(cid)<getCreatureMaxHealth(cid)) then
 doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(quantheal/100))
    if(chances<=porcentagem/8 and getCreatureMana(cid)<getCreatureMaxMana(cid)) then
 doCreatureAddMana(cid, getCreatureMaxMana(cid)*(quantheal/100))
            if(i<=8 and i>1) then
                doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, atual, tipoaura)
            else
                doSendDistanceShoot({x=posaura[1].x, y=posaura[1].y, z=posaura[1].z}, atual, tipoaura)
            end
            doSendMagicEffect(atual, efeitocura)
        end
        if(i==8) then
            doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, {x=posaura[1].x, y=posaura[1].y, z=posaura[1].z}, tipoaura)
        elseif(i<8) then
            doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, {x=posaura[i+1].x, y=posaura[i+1].y, z=posaura[i+1].z}, tipoaura)
        end
        if(i<=8 and getPlayerStorageValue(cid, aurastr)==2) then
            i = i+1
            tm = tempo/8
            return addEvent(efeitosAura,tm,i,tm,cid)
        elseif(i>8 and getPlayerStorageValue(cid, aurastr)==2) then
            return efeitosAura(1,0,cid)
        else
            return TRUE
        end
    else
        return TRUE
    end
end

-- Função principal
function onSay(cid, words, param, channel)
    if(param=="on") then
        if getPlayerStorageValue(cid, estr) > os.time() then
            doPlayerSendCancel(cid, "Espere "..(getPlayerStorageValue(cid, estr) - os.time()).." segundos para poder habilitar aura novamente.")
        else
            if(getPlayerStorageValue(cid, aurastr)==2) then
                doPlayerSendCancel(cid,"Sua aura já está habilitada.")
            elseif(getPlayerStorageValue(cid, aurastr)==-1) then
                doPlayerSendCancel(cid,"Aura ligada!")
                setPlayerStorageValue(cid, aurastr, 2)
                efeitosAura(1,tempo/8,cid)
            end
        end
    elseif(param=="off") then
        if(getPlayerStorageValue(cid, aurastr)==2) then
            setPlayerStorageValue(cid, estr, os.time()+2)
            setPlayerStorageValue(cid, aurastr, -1)
            doPlayerSendCancel(cid,"Aura desligada!")
        end
    else   
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Digite '!aura on' para ligar sua aura, e '!aura off' para desligá-la.")
    end
    return TRUE
end
 
@jacqen

how to join the two

doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(quantheal/100))
doCreatureAddMana(cid, getCreatureMaxMana(cid)*(quantheal/100))
Change line 24 ~ 34 to:

Lua:
if chances<=porcentagem/8 and (getCreatureMana(cid)<getCreatureMaxMana(cid) or getCreatureHealth(cid)<getCreatureMaxHealth(cid)) then
    if getCreatureMana(cid)<getCreatureMaxMana(cid) then
        doCreatureAddMana(cid, getCreatureMaxMana(cid)*(quantheal/100))
    end
    if  getCreatureHealth(cid)<getCreatureMaxHealth(cid) then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid)*(quantheal/100))
    end
    if(i<=8 and i>1) then
        doSendDistanceShoot({x=posaura[i].x, y=posaura[i].y, z=posaura[i].z}, atual, tipoaura)
    else
        doSendDistanceShoot({x=posaura[1].x, y=posaura[1].y, z=posaura[1].z}, atual, tipoaura)
    end
    doSendMagicEffect(atual, efeitocura)
end
 

Similar threads

Back
Top