Ir para conteúdo

Featured Replies

Postado
15 minutos atrás, moleza disse:


 Boa noite tudo bem? então a ideia era healar % da vida maxima, por exemplo encher 20% da mana e da vida, esse script continua enchendo 200k 

Curando 20% mana e vida

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local ITEM_ID = 12780 -- ID do item Senzu Bean
    local STORAGE_ID = 50000 -- ID de armazenamento para controle de cooldown
    local COOLDOWN_TIME = 60 -- Tempo de recarga em segundos
    local HEAL_PERCENTAGE = 20 -- Porcentagem de vida e mana a ser curada
    local EFFECT_ID = 80 -- ID do efeito visual ao usar a Senzu Bean

    local pos = getPlayerPosition(cid)
    local newPos = {x = pos.x + 1, y = pos.y, z = pos.z}

    -- Verifica se o item usado é uma Senzu Bean
    if item.itemid ~= ITEM_ID then
        doPlayerSendCancel(cid, "You must use a Senzu Bean.")
        return TRUE
    end

    -- Verifica se o jogador está em cooldown
    if exhaustion.get(cid, STORAGE_ID) == TRUE then
        local cooldownTime = exhaustion.get(cid, STORAGE_ID) / 1000
        doPlayerSendCancel(cid, "You are still in cooldown for " .. cooldownTime .. " seconds.")
        return TRUE
    end

    -- Calcula a quantidade de vida e mana a ser curada com base na porcentagem
    local maxHealth = getPlayerMaxHealth(cid)
    local maxMana = getPlayerMaxMana(cid)
    local healAmount = math.floor(maxHealth * HEAL_PERCENTAGE / 100)
    local manaAmount = math.floor(maxMana * HEAL_PERCENTAGE / 100)

    -- Cura o jogador
    doPlayerAddMana(cid, manaAmount)
    doCreatureAddHealth(cid, healAmount)

    -- Exibe a mensagem e o efeito visual
    doCreatureSay(cid, "Aaahhh! Bem melhor!", TALKTYPE_ORANGE_1)
    doSendMagicEffect(newPos, EFFECT_ID)

    -- Remove a Senzu Bean do inventário
    doRemoveItem(item.uid, 1)

    -- Define o tempo de cooldown
    exhaustion.set(cid, STORAGE_ID, COOLDOWN_TIME * 1000)

    return TRUE
end
 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

  • Respostas 8
  • Visualizações 482
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

Postado
  • Autor
57 minutos atrás, L3K0T disse:

Curando 20% mana e vida

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local ITEM_ID = 12780 -- ID do item Senzu Bean
    local STORAGE_ID = 50000 -- ID de armazenamento para controle de cooldown
    local COOLDOWN_TIME = 60 -- Tempo de recarga em segundos
    local HEAL_PERCENTAGE = 20 -- Porcentagem de vida e mana a ser curada
    local EFFECT_ID = 80 -- ID do efeito visual ao usar a Senzu Bean

    local pos = getPlayerPosition(cid)
    local newPos = {x = pos.x + 1, y = pos.y, z = pos.z}

    -- Verifica se o item usado é uma Senzu Bean
    if item.itemid ~= ITEM_ID then
        doPlayerSendCancel(cid, "You must use a Senzu Bean.")
        return TRUE
    end

    -- Verifica se o jogador está em cooldown
    if exhaustion.get(cid, STORAGE_ID) == TRUE then
        local cooldownTime = exhaustion.get(cid, STORAGE_ID) / 1000
        doPlayerSendCancel(cid, "You are still in cooldown for " .. cooldownTime .. " seconds.")
        return TRUE
    end

    -- Calcula a quantidade de vida e mana a ser curada com base na porcentagem
    local maxHealth = getPlayerMaxHealth(cid)
    local maxMana = getPlayerMaxMana(cid)
    local healAmount = math.floor(maxHealth * HEAL_PERCENTAGE / 100)
    local manaAmount = math.floor(maxMana * HEAL_PERCENTAGE / 100)

    -- Cura o jogador
    doPlayerAddMana(cid, manaAmount)
    doCreatureAddHealth(cid, healAmount)

    -- Exibe a mensagem e o efeito visual
    doCreatureSay(cid, "Aaahhh! Bem melhor!", TALKTYPE_ORANGE_1)
    doSendMagicEffect(newPos, EFFECT_ID)

    -- Remove a Senzu Bean do inventário
    doRemoveItem(item.uid, 1)

    -- Define o tempo de cooldown
    exhaustion.set(cid, STORAGE_ID, COOLDOWN_TIME * 1000)

    return TRUE
end
 

[23:7:54.227] [Error - Action Interface]
[23:7:54.230] data/actions/scripts/heal/senzu_bean.lua:onUse
[23:7:54.233] Description:
[23:7:54.235] data/actions/scripts/heal/senzu_bean.lua:25: attempt to call global 'getPlayerMaxHealth' (a nil value)
[23:7:54.237] stack traceback:
[23:7:54.239]   data/actions/scripts/heal/senzu_bean.lua:25: in function <data/actions/scripts/heal/senzu_bean.lua:1>

Em 11/06/2023 em 09:41, ernaix69 disse:
  Ocultar conteúdo


function onUse(cid, item, fromPosition, itemEx, toPosition)
ITEM = 12780
local storage = 50000
local wait = 1.0
local pos1 = {x = getPlayerPosition(cid).x + 1, y = getPlayerPosition(cid).y + 0, z = getPlayerPosition(cid).z}
if fromPosition.x ~= CONTAINER_POSITION and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = getCreatureMaxHealth(cid) * 0.3 -- regenera 30% do hp
REG_MANA = getCreatureMaxMana(cid) * 0.3 -- regenera 30% da mana
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
doCreatureSay(cid, 'Aaahhh! Bem Melhor!', TALKTYPE_ORANGE_1)
doSendMagicEffect(pos1, 80)
doRemoveItem(item.uid, 0)
exhaustion.set(cid, storage, wait)
elseif item.itemid == ITEM and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = getCreatureMaxHealth(cid) * 0.3 -- regenera 30% do hp
REG_MANA = getCreatureMaxMana(cid) * 0.3 -- regenera 30% da mana
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
doCreatureSay(cid, 'Aaahhh! Bem Melhor!', TALKTYPE_ORANGE_1)
doSendMagicEffect(pos1, 80)
doRemoveItem(item.uid, 0)
exhaustion.set(cid, storage, wait)
else
doPlayerSendCancel(cid, "You are exhausted.")
end
return TRUE
end

@moleza

EDIT** 

 

tinha feito um negocio errado quand fui colocar o script, está funcionando esse aqui, muito obg

Postado
Em 11/06/2023 em 17:01, moleza disse:

@ernaix69 quando uso a senzu, nada acontece, sem erros também

 

aparece isso no serverlog 

 

17:01 Using the last Senzu Bean...

 

mas não usa

 

** edit **

 

não sei se interfere em algo mas meu servidor a vida e a mana estão em % então fica 100/100

 

Spoiler

function onUse(cid, item, fromPosition, itemEx, toPosition)
local waittime = 1.5 -- Tempo de exhaustion
local storage = 61630 -- não mecha
local hp = getCreatureMaxHealth(cid)

if getPlayerLevel(cid) < 1 then
    doPlayerSendCancel(cid, "você precisa ser level 1 ou mais para usar a senzu bean")
    return true
end

if exhaustion.check(cid, storage) then
    doPlayerSendChannelMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde ".. exhaustion.get(cid, storage) .. " segundos para usar a senzu novamente.", TALKTYPE_CHANNEL_O, CHANNEL_SPELL)
    return true
end

exhaustion.set(cid, storage, waittime)
doCreatureAddHealth(cid, hp*0.3)
doAddCondition(cid, heal)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid, 1)
return true
end
 

@moleza

Postado
5 horas atrás, moleza disse:

[23:7:54.227] [Error - Action Interface]
[23:7:54.230] data/actions/scripts/heal/senzu_bean.lua:onUse
[23:7:54.233] Description:
[23:7:54.235] data/actions/scripts/heal/senzu_bean.lua:25: attempt to call global 'getPlayerMaxHealth' (a nil value)
[23:7:54.237] stack traceback:
[23:7:54.239]   data/actions/scripts/heal/senzu_bean.lua:25: in function <data/actions/scripts/heal/senzu_bean.lua:1>

EDIT** 

 

tinha feito um negocio errado quand fui colocar o script, está funcionando esse aqui, muito obg

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local ITEM_ID = 12780 -- ID do item Senzu Bean
    local STORAGE_ID = 50000 -- ID de armazenamento para controle de cooldown
    local COOLDOWN_TIME = 60 -- Tempo de recarga em segundos
    local HEAL_PERCENTAGE = 20 -- Porcentagem de vida e mana a ser curada
    local EFFECT_ID = 80 -- ID do efeito visual ao usar a Senzu Bean

    local pos = getPlayerPosition(cid)
    local newPos = {x = pos.x + 1, y = pos.y, z = pos.z}

    -- Verifica se o item usado é uma Senzu Bean
    if item.itemid ~= ITEM_ID then
        doPlayerSendCancel(cid, "You must use a Senzu Bean.")
        return TRUE
    end

    -- Verifica se o jogador está em cooldown
    if exhaustion.get(cid, STORAGE_ID) == TRUE then
        local cooldownTime = exhaustion.get(cid, STORAGE_ID) / 1000
        doPlayerSendCancel(cid, "You are still in cooldown for " .. cooldownTime .. " seconds.")
        return TRUE
    end

    -- Calcula a quantidade de vida e mana a ser curada com base na porcentagem
    local maxHealth = getCreatureMaxHealth(cid)
    local maxMana = getCreatureMaxMana(cid)
    local healAmount = math.floor(maxHealth * HEAL_PERCENTAGE / 100)
    local manaAmount = math.floor(maxMana * HEAL_PERCENTAGE / 100)

    -- Cura o jogador
    doPlayerAddMana(cid, manaAmount)
    doCreatureAddHealth(cid, healAmount)

    -- Exibe a mensagem e o efeito visual
    doCreatureSay(cid, "Aaahhh! Bem melhor!", TALKTYPE_ORANGE_1)
    doSendMagicEffect(newPos, EFFECT_ID)

    -- Remove a Senzu Bean do inventário
    doRemoveItem(item.uid, 1)

    -- Define o tempo de cooldown
    exhaustion.set(cid, STORAGE_ID, COOLDOWN_TIME * 1000)

    return TRUE
end
 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

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 520.3k

Informação Importante

Confirmação de Termo