• 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!

see the mana from mana potions in purple text

Ahilphino

Excellent OT User
Joined
Jun 5, 2013
Messages
1,667
Solutions
1
Reaction score
726
is this possible with TFS 1.0?

I know I can make it in orange text but how would i make it in purple text or some other color?

Code:
amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4}, 
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local lv = getPlayerLevel(player)
local conf = {
    v = amount[getPlayerVocation(player)],
    voc = getPlayerVocation(player),
    level = 180 -- min level
}

    if getPlayerLevel(player) >= conf.level then
            local hps = math.random((lv*conf.v[3]),(lv*conf.v[4]))
            local manas = math.random((lv*conf.v[1]),(lv*conf.v[2]))
            doCreatureAddHealth(player, hps)
            doPlayerAddMana(player, manas)
            player:say("+" ..manas.."", TALKTYPE_MONSTER_SAY)
            doSendMagicEffect(getPlayerPosition(player), CONST_ME_MAGIC_BLUE)
    else
        doPlayerSendTextMessage(player, 22, "Only players above " .. conf.level .. " level can drink this potion.")
    end
end
this is my current script potion script, i can source edit if necessary!
 
Code:
amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4},
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local lv = player:getLevel()
local conf = {
    v = amount[player:getVocation():getId()],
    voc = player:getVocation(),
    level = 180 -- min level
}

    if lv >= conf.level then
        local hps = math.random((lv*conf.v[3]),(lv*conf.v[4]))
        local manas = math.random((lv*conf.v[1]),(lv*conf.v[2]))
        player:addHealth(hps)
        player:addMana(manas)
        player:sendTextMessage(MESSAGE_EXPERIENCE, "", player:getPosition(), "" .. manas .. "", TEXTCOLOR_PURPLE)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    else
        player:say("Only players above " .. conf.level .. " level can drink this potion.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
Try this.
If you want script with exhaustion set try this one, you can configure exhaustion in config.lua, search for this -
Code:
-- Item Usage
timeBetweenActions = 200
timeBetweenExActions = 600
Script -
Code:
amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4},
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local lv = player:getLevel()
local conf = {
    v = amount[player:getVocation():getId()],
    voc = player:getVocation(),
    level = 180 -- min level
}

    if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if lv >= conf.level then
        local hps = math.random((lv*conf.v[3]),(lv*conf.v[4]))
        local manas = math.random((lv*conf.v[1]),(lv*conf.v[2]))
        player:addHealth(hps)
        player:addMana(manas)
        player:sendTextMessage(MESSAGE_EXPERIENCE, "", player:getPosition(), "" .. manas .. "", TEXTCOLOR_PURPLE)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        player:addCondition(exhaust)
    else
        player:say("Only players above " .. conf.level .. " level can drink this potion.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
 
Last edited:
Weoew! Thanks alot my mate!

The only issue right now is that this:
player:sendTextMessage(MESSAGE_EXPERIENCE, "", player:getPosition(), "" .. manas .. "", TEXTCOLOR_PURPLE)
My server log will be spammed with "22:38", with no message because of "" after MESSAGE_EXPERIENCE. I tried changing MESSAGE_EXPERIENCE to all other types of messages there is but all types had this same issue! I tried removing "" but it still won't work.

Also the server log only gets spammed if I use the regular tibia client, with otclient everything looks like it should.

I have tried my darnest to get this to work but I can't seem to get it :(
Any ideas? I could possibly edit the source if necessary!
 
Last edited:
Code:
local amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4},
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}


local player = {}

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    player.cid = Player(cid)
    player.maxLevel = 180
    player.level = player.cid:getLevel()
    player.voc = player.cid:getVocation()
    player.vocid = player.voc:getId()
    player.amount = amount[player.vocid]
    player.pos = player.cid:getPosition()

    if player.cid:getCondition(CONDITION_EXHAUST_HEAL) then
        player.cid:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return false
    end

    if player.level >= player.maxLevel then
        local health = math.random( ( player.level * player.amount[3] ),( player.level * player.amount[4] ) )
        local mana = math.random( ( player.level * player.amount[1] ),( player.level * player.amount[2] ) )
        player.cid:addHealth(health)
        player.cid:addMana(mana)
        player.cid:sendTextMessage(MESSAGE_EXPERIENCE, "", player.pos, "" .. mana .. "", TEXTCOLOR_PURPLE)
        player.pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        player.cid:addCondition(exhaust)
    else
        player.cid:say("Only players above " .. player.maxLevel .. " level can drink this potion.", TALKTYPE_MONSTER_SAY)
        return false
    end
    return true
end
 
Last edited:
Still I get this in server log but I see the purple text on my char, I just get this still:
05:48
05:48
05:48
05:49
05:49
05:49

(empty message everytime I use it)

:(
 
Here try this
Code:
local amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4},
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}


local player = {}

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    player.cid = Player(cid)
    player.maxLevel = 180
    player.level = player.cid:getLevel()
    player.voc = player.cid:getVocation()
    player.vocid = player.voc:getId()
    player.amount = amount[player.vocid]
    player.pos = player.cid:getPosition()

    if player.cid:getCondition(CONDITION_EXHAUST_HEAL) then
        player.cid:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return false
    end

    if player.level >= player.maxLevel then
        local health = math.random( ( player.level * player.amount[3] ),( player.level * player.amount[4] ) )
        local mana = math.random( ( player.level * player.amount[1] ),( player.level * player.amount[2] ) )
        player.cid:addHealth(health)
        player.cid:addMana(mana)
        doPlayerSendTextMessage(player.cid, MESSAGE_EXPERIENCE, "", player.pos, mana, TEXTCOLOR_PURPLE)
        player.pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        player.cid:addCondition(exhaust)
    else
        player.cid:say("Only players above " .. player.maxLevel .. " level can drink this potion.", TALKTYPE_MONSTER_SAY)
        return false
    end
    return true
end
 
change this
doPlayerSendTextMessage(player.cid, MESSAGE_EXPERIENCE, "", player.pos, mana, TEXTCOLOR_PURPLE)
to this
doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "", player.pos, mana, TEXTCOLOR_PURPLE)

Should look like this now, I am not testing the code this is why I don't know if it works or not
Code:
local amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4},
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}


local player = {}

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    player.cid = Player(cid)
    player.maxLevel = 180
    player.level = player.cid:getLevel()
    player.voc = player.cid:getVocation()
    player.vocid = player.voc:getId()
    player.amount = amount[player.vocid]
    player.pos = player.cid:getPosition()

    if player.cid:getCondition(CONDITION_EXHAUST_HEAL) then
        player.cid:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return false
    end

    if player.level >= player.maxLevel then
        local health = math.random( ( player.level * player.amount[3] ),( player.level * player.amount[4] ) )
        local mana = math.random( ( player.level * player.amount[1] ),( player.level * player.amount[2] ) )
        player.cid:addHealth(health)
        player.cid:addMana(mana)
        doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "", player.pos, mana, TEXTCOLOR_PURPLE)
        player.pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        player.cid:addCondition(exhaust)
    else
        player.cid:say("Only players above " .. player.maxLevel .. " level can drink this potion.", TALKTYPE_MONSTER_SAY)
        return false
    end
    return true
end
 
06:01 /reload actions
06:01
06:01
06:01
06:01
06:01

Still mate, and no text above my head right now
 
06:01 /reload actions
06:01
06:01
06:01
06:01
06:01

Still mate, and no text above my head right now
I dont know then I took the text animation right from a animated text function
I didn't write it tho, someone else did, but it works for 1.x
Code:
function doSendAnimatedText(pos, value, color, player)
    if(not tonumber(value))then
      return error("arg #2 in doSendAnimatedText is not a number")
    end
    if(isPlayer(player))then
      doPlayerSendTextMessage(player, MESSAGE_EXPERIENCE, "", pos, value, color)
    else
        for _, v in ipairs(getSpectators(pos, 7, 5, true)) do
            if(isPlayer(v))then
              doPlayerSendTextMessage(v, MESSAGE_EXPERIENCE, "", pos, value, color)
            end
        end
    end
end
 
Hey mate yes! I searched around before making this thread and I saw this code too but he had same issue!
http://otland.net/threads/dosendanimatedtext-pos-text-color-player-for-9-1.135138/
) This wasn't expected to be used simply for the animated text, so a message must always be sent, I have set the message to "", but on the game's console it'll still show an empty line, if it is possible to fix and someone knows how, please do post here
Its from his post! He has same issue :p

This is also why I think we need to go to sources to fix this!
 
Last edited:
I know it can only print numbers, but are you using otclient? Because in otclient it works like it should it's only in normal tibia client where I get messages in the server log

I tested it again with
doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "", player.pos, tonumber(mana), TEXTCOLOR_PURPLE)
and added his function to global.lua! It still gives me server log msg.
 
I know it can only print numbers, but are you using otclient? Because in otclient it works like it should it's only in normal tibia client where I get messages in the server log
Nah I am using a standard 10.41 client, I have to head to bed because I have work in the morning so I will test it for you after work if someone else doesn't fix it for you by then.
 
Ok thanks man! I restarted server and everything just to make sure:
4ev05wAhi.png

Using ur latest script with
Code:
local amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4},
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}


local player = {}

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    player.cid = Player(cid)
    player.maxLevel = 1
    player.level = player.cid:getLevel()
    player.voc = player.cid:getVocation()
    player.vocid = player.voc:getId()
    player.amount = amount[player.vocid]
    player.pos = player.cid:getPosition()

    if player.cid:getCondition(CONDITION_EXHAUST_HEAL) then
        player.cid:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return false
    end

    if player.level >= player.maxLevel then
        local health = math.random( ( player.level * player.amount[3] ),( player.level * player.amount[4] ) )
        local mana = math.random( ( player.level * player.amount[1] ),( player.level * player.amount[2] ) )
        player.cid:addHealth(health)
        player.cid:addMana(mana)
        doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "", player.pos, tonumber(mana), TEXTCOLOR_PURPLE)
        player.pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        player.cid:addCondition(exhaust)
    else
        player.cid:say("Only players above " .. player.maxLevel .. " level can drink this potion.", TALKTYPE_MONSTER_SAY)
        return false
    end
    return true
end

But I am also using the latest tfs rev not 1.0, so that might be why it works for you? Not sure!

Anyways! Thanks alot! I'll be waiting :)
 
Ok I fixed it an left a comment in the code so you see the correct parameters :)
mana.png

Code:
local amount = {
-- [vocation] = {minmp, maxmp, minhp, maxhp}, (it will be multiplied by player level)
    [1] = {3, 3.5, 4, 4},
    [2] = {3, 3.5, 0, 0},
    [3] = {1,1.2, 2, 2.2},
    [4] = {0, 0, 5, 7},
    [5] = {3, 3.5, 0, 0},
    [6] = {3, 3.5, 0, 0},
    [7] = {1,1.2, 2, 2.2},
    [8] = {0, 0, 5, 7}
}


local player = {}

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local p = Player(cid)
    player.minimumLevel = 180
    player.level = p:getLevel()
    player.vocid = p:getVocation():getId()
    player.amount = player.vocid > 0 and amount[player.vocid] or amount[math.ceil(math.random(1, #amount))]
    player.pos = p:getPosition()
    player.manaColor = TEXTCOLOR_PURPLE
    player.healthColor = TEXTCOLOR_RED

    if p:getCondition(CONDITION_EXHAUST_HEAL) then
        p:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return false
    end

    if player.level >= player.minimumLevel then
        local health = math.random( ( player.level * player.amount[3] ),( player.level * player.amount[4] ) )
        local mana = math.random( ( player.level * player.amount[1] ),( player.level * player.amount[2] ) )
        p:addHealth(health)
        p:addMana(mana)
        --player.cid:sendTextMessage(type, text_in_console, pos, text_over_head, color)
        if health == 0 then
            p:sendTextMessage(MESSAGE_EXPERIENCE, "You've gained "..mana.." mana.", player.pos, mana, player.manaColor)
        elseif mana == 0 then
            p:sendTextMessage(MESSAGE_EXPERIENCE, "You've gained "..health.." health.", player.pos, health, player.healthColor)
        else
            p:sendTextMessage(MESSAGE_EXPERIENCE, "You've gained "..mana.." mana.", player.pos, mana, player.manaColor)
            p:sendTextMessage(MESSAGE_EXPERIENCE, "You've gained "..health.." health.", player.pos, health, player.healthColor)
        end
        -- un comment if you want to remove the item
        --Item(item.uid):remove(1)
        player.pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        p:addCondition(exhaust)
    else
        p:say("Only players above " .. player.minimumLevel .. " level can drink this potion.", TALKTYPE_MONSTER_SAY)
        return false
    end
    return true
end
 
Last edited:
Yes! Mate this is defnitely better but still it would be best without any message at all in server log but I suppose that isn't possible?

I removed "show status messages in console" in the tibia client's options and now it looks like it should but still really would like it to not send any msg at all in console if possible! :E
 
Back
Top