• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Full HP/MANA potion (1 charge)

zxzxzx

New Member
Joined
Mar 12, 2011
Messages
334
Reaction score
3
Hello! I need full hp/mana potion with only 1 charge, the potion ID must be 12328 and when I use it the potion should disappear.

Thanks for help++
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local addh = creature:getHealth()
local addm = creature:getMana()
creature:addHealth(addh)
creature:addMana(addm)
item:remove()
return true
end
Giving 1.2 a shot, I think this is right at least
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local healthToAdd = player:getMaxHealth() - player:getHealth()
    local manaToAdd = player:getMaxMana() - player:getMana()
   
   -- prevent the player from accidentally using the item or double clicking
    if healthToAdd == 0 and manaToAdd == 0 then
        player:sendCancelMessage('You already have full Health and Mana!')
        return true
    end
  
    player:addHealth(healthToAdd)
    player:addMana(manaToAdd)
    player:say('Aaaaah!', TALKTYPE_MONSTER_SAY)
    item:remove(1)
return true
end

You could also probably just do this instead of calculating how much to add, not sure which is better nor if it even matters: :p
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local lessThanFullHP = player:getMaxHealth() - player:getHealth() > 0
    local lessThanFullMP = player:getMaxMana() - player:getMana() > 0
   
    if not lessThanFullHP and not lessThanFullMP then
        player:sendCancelMessage('You already have full Health and Mana!')
        return true
    end
   
    player:addHealth(player:getMaxHealth())
    player:addMana(player:getMaxMana())
    player:say('Aaaaah!', TALKTYPE_MONSTER_SAY)
    item:remove(1)
return true
end
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local healthToAdd = player:getMaxHealth() - player:getHealth()
    local manaToAdd = player:getMaxMana() - player:getMana()
  
   -- prevent the player from accidentally using the item or double clicking
    if healthToAdd == 0 and manaToAdd == 0 then
        player:sendCancelMessage('You already have full Health and Mana!')
        return true
    end
 
    player:addHealth(healthToAdd)
    player:addMana(manaToAdd)
    player:say('Aaaaah!', TALKTYPE_MONSTER_SAY)
    item:remove(1)
return true
end

You could also probably just do this instead of calculating how much to add, not sure which is better nor if it even matters: :p
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local lessThanFullHP = player:getMaxHealth() - player:getHealth() > 0
    local lessThanFullMP = player:getMaxMana() - player:getMana() > 0
  
    if not lessThanFullHP and not lessThanFullMP then
        player:sendCancelMessage('You already have full Health and Mana!')
        return true
    end
  
    player:addHealth(player:getMaxHealth())
    player:addMana(player:getMaxMana())
    player:say('Aaaaah!', TALKTYPE_MONSTER_SAY)
    item:remove(1)
return true
end

working! thanks for help ++ ;)
 
Back
Top