• 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 Displaying amount that potions gives

liqeen

Active Member
Joined
Nov 26, 2014
Messages
151
Solutions
1
Reaction score
30
Location
Poland
Hello i need some help with that script
How do i add here a function that will show for how much the player is manasing? I mean the purple amount over the player everytime he uses the potion
Code:
-- =============================================================================================================================================================== --
-- ===================    CREATED BY [email protected] CREDITS TO OTLAND FOR HELPING ME TO LEARN EVERY KIND OF CODING USED IN THIS SCRIPT ====================== --
-- =============================================================================================================================================================== --
local config = {
lvl = 0.3, -- the multiplier for how much level matters. Default 1.
mlvl = 0, -- the mulitplier for how much mlvl matters. Default 1.
forMin = 0.2, -- forumula multiplier for MIN/max range. Default 0.9 == 90%          --Change both to 1.0 for amount healed to have no min/max
forMax = 0.3, -- forumula multiplier for min/MAX range. Default 0.9 == 110%          --Change both to 1.0 for amount healed to have no min/max
removeOnUse = false, -- Does this remove 1 potion after it's use? true/false          -- Default true.
useOnSummons = true, -- Can you use this on a players summon? true/false              -- Default true.
useOnGuildSummon = true, -- Can you use this on guild mate's summon? true/false      -- Default true.
useOnPartySummon = true, -- Can you use this on a party members summon? true/false      -- Default true.
realPvpMode = false, -- True = Players can't use potions for hotkeys || False = Players are allowed to use potions for hotkeys.
exhaust = Condition(CONDITION_EXHAUST_HEAL, CONDITIONID_HEAD), --Condition for each specific potion.Adjust time in potions table below.
cooldown =  Condition(CONDITION_SPELLCOOLDOWN, CONDITIONID_HEAD) -- Condition for creating "groups" of potions with same cooldown time, eg. all mana potions.
}
local POTIONS = {
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  [8704] = {empty = 7636, spellid = 1, splash = 2, exhaust = 0, health = true, mana = false, healthpercent = 8},                                                                         -- small health potion
  [7618] = {empty = 7636, spellid = 1, splash = 2, exhaust = 0, health = true, mana = false, healthpercent = 12},                                                                        -- health potion
  [7588] = {empty = 7634, spellid = 2, splash = 2, exhaust = 0, health = true, mana = false, healthpercent = 25, lvlReq = 50, vocations = {1, 3, 4, 7, 8, 12}},                            -- strong health potion
  [7591] = {empty = 7635, spellid = 2, splash = 2, exhaust = 0, health = true, mana = false, healthpercent = 40, lvlReq = 80, vocations = {4, 8, 12}},                                     -- great health potion
  [8473] = {empty = 7635, spellid = 2, splash = 2, exhaust = 0, health = true, mana = false, healthpercent = 60, lvlReq = 150, vocations = {4, 8, 12}},                                     -- ultimate health potion
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  [7620] = {empty = 7636, spellid = 3, splash = 7, exhaust = 0, health = false, mana = true, manapercent = 12},                                                                             -- mana potion
  [7589] = {empty = 7634, spellid = 3, splash = 7, exhaust = 0, health = false, mana = true, manapercent = 25, lvlReq = 50, vocations = {1, 2, 3, 5, 6, 7, 9, 10, 11}},                     -- strong mana potion
  [7590] = {empty = 7635, spellid = 3, splash = 7, exhaust = 0, health = false, mana = true, manapercent = 40, lvlReq = 80, vocations = {1, 2, 5, 6, 9, 10}},                             -- great mana potion
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  [8472] = {empty = 7635, spellid = 2, splash = 3, exhaust = 0, health = true,  mana = true, healthpercent = 60, manapercent = 60, lvlReq = 100, vocations = {3, 7, 11}}                     -- great spirit potion
}
------Below for Advanced Users Only----------
function Player:isCreatureFriend(creature)
    local PID
    local GID
      if self:getParty() then
        PID = self:getParty():getId()
      end
      if self:getGuild() then
        GID = self:getGuild():getId()
      end
     if creature:isPlayer() then
        if creature:getParty() then
            if creature:getParty():getId() == PID then
                return true
            end
        end
        if creature:getGuild() then
            if creature:getGuild():getId() == GID then
                  return true
            end
        end
        return false
    end
    if creature:isMonster() then
    local master = creature:getMaster()
        if master then
            if master:getId() == self:getId() then
                return true
            end
            if master:getParty() and master:getParty():getId() == PID then
                return true
            end
            if master:getGuild() and master:getGuild():getId() == GID then
                return true
            end
            return false
        end
    end
end

function onUse(caster, item, castPos, target, toPosition, isHotkey)
local potion = POTIONS[item.itemid]
local health = potion.health
local mana = potion.mana
local hpPercent = potion.healthpercent
local mpPercent = potion.manapercent
local exhaust = config.exhaust
local cooldown = config.cooldown
local mlevel = caster:getMagicLevel()
local level = caster:getLevel()
    if(not potion) then
        return false
    end
    if isHotkey and config.realPvpMode == true then
        caster:getPosition():sendMagicEffect(CONST_ME_POFF)
        return caster:sendTextMessage(MESSAGE_INFO_DESCR,"Hotkey use is disabled for potions!")
    end
    if toPosition.z == 0 or nil then
        caster:getPosition():sendMagicEffect(CONST_ME_POFF)
        return caster:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    if toPosition.x == 65535 or nil then
        caster:getPosition():sendMagicEffect(CONST_ME_POFF)
        return caster:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end

    if target:isItem() then
        if (not target:hasProperty()) then
            Item(doCreateItem(2016, potion.splash, toPosition)):decay()
                if config.removeOnUse and not caster:getGroup():getAccess() then
                    Item(item.uid):remove(1)
                end
            return true
        end
        caster:getPosition():sendMagicEffect(CONST_ME_POFF)
        return caster:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    local healthmax = target:getMaxHealth()
    local manamax = target:getMaxMana()
    if caster:getCondition(CONDITION_EXHAUST_HEAL, CONDITIONID_HEAD, potion.spellid) then
        caster:getPosition():sendMagicEffect(CONST_ME_POFF)
        return caster:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
    end
    if (potion.vocations) and  (not caster:getGroup():getAccess()) then
        if (not isInArray(potion.vocations, caster:getVocation():getId())) then
            caster:getPosition():sendMagicEffect(CONST_ME_POFF)
            return caster:sendTextMessage(MESSAGE_INFO_DESCR,"Your vocation may not use this fluid")
        end
    end
    if((potion.lvlReq and caster:getLevel() < potion.lvlReq) and not caster:getGroup():getAccess()) then
        caster:getPosition():sendMagicEffect(CONST_ME_POFF)
        return caster:sendTextMessage(MESSAGE_INFO_DESCR,"Only players of " ..potion.level.. " or above may use this fluid.")
    end
    if target:isPlayer() then
        if health == true then
            target:addHealth(( math.random((((healthmax/100)*hpPercent ) + ((level/12)*config.lvl ) + ((mlevel/18)*config.mlvl ))*config.forMin, ((((healthmax/100)*hpPercent ) + ((level/12)*config.lvl )+ ((mlevel/18))*config.mlvl )*config.forMax))))
        end
        if mana == true then
            target:addMana(( math.random((((manamax/100)*mpPercent ) + ((level/18)*config.lvl ) + ((mlevel/12)*config.mlvl ))*config.forMin, ((((manamax/100)*mpPercent ) + ((level/18)*config.lvl )+ ((mlevel/12))*config.mlvl )*config.forMax))))
        end
    end
    if target:isMonster() then
    local monsterMaster = target:getMaster()
        if caster:isCreatureFriend(target) then
            if config.useOnSummons == true then
                if health then
                    target:addHealth(( math.random((((healthmax/100)*hpPercent ) + ((level/12)*config.lvl ) + ((mlevel/18)*config.mlvl ))*config.forMin, ((((healthmax/100)*hpPercent ) + ((level/12)*config.lvl )+ ((mlevel/18))*config.mlvl )*config.forMax))))
                else
                    caster:getPosition():sendMagicEffect(CONST_ME_POFF)
                    return caster:sendTextMessage(MESSAGE_STATUS_SMALL,"Summons don't use mana!")
                end
            else
                caster:getPosition():sendMagicEffect(CONST_ME_POFF)
                return caster:sendTextMessage(MESSAGE_STATUS_SMALL,"You can't use this on summons!")
            end
        else
            caster:getPosition():sendMagicEffect(CONST_ME_POFF)
            return caster:sendTextMessage(MESSAGE_STATUS_SMALL,"You can't use this on that creature!")
        end
    end      
    if target:isNpc() then
        caster:getPosition():sendMagicEffect(CONST_ME_POFF)
        return caster:sendTextMessage(MESSAGE_STATUS_SMALL,"You can't use this on that creature!")
    end
    if config.removeOnUse and not caster:getGroup():getAccess() then
        Item(item.uid):remove(1)
    end
    exhaust:setParameter(CONDITION_PARAM_TICKS, potion.exhaust)
    exhaust:setParameter(CONDITION_PARAM_SUBID, potion.spellid)
    cooldown:setParameter(CONDITION_PARAM_TICKS, potion.exhaust)
    cooldown:setParameter(CONDITION_PARAM_SUBID, potion.spellid)
    caster:addCondition(cooldown)
    caster:addCondition(exhaust)
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    doCreatureSayWithRadius(target, 'Aaaah...', TALKTYPE_MONSTER_SAY, 2, 2)
  return true
end
 
Solution
PHP:
-- =============================================================================================================================================================== --
-- ===================    CREATED BY [email protected] CREDITS TO OTLAND FOR HELPING ME TO LEARN EVERY KIND OF CODING USED IN THIS SCRIPT ====================== --
-- =============================================================================================================================================================== --
local config = {
lvl = 0.3, -- the multiplier for how much level matters. Default 1.
mlvl = 0, -- the mulitplier for how much mlvl matters. Default 1.
forMin = 0.2, -- forumula multiplier for MIN/max range. Default 0.9 == 90%...
Back
Top