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

Potions with level and vocation check

ntmr

hi!
Senator
Joined
Jul 7, 2007
Messages
1,835
Reaction score
15
Location
Santa Catarina, Brazil
While the items.xml does not support level and vocation requirement, it can be done LUA.

potions.lua:
Code:
local greatHealthPot = 7591
local greatManaPot = 7590
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636
local knightsandpaladins = {3, 4, 7, 8}
local druidsandsorcerers = {1, 2, 5, 6}
local druidspaladinsandsorcerers = {1, 2, 3, 5, 6, 7}
local knights = {4, 8}

function onUse(cid, item, frompos, item2, topos)
    if(item.itemid == healthPot) then
        if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 170, 230, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
            return FALSE
        end
        doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
        doTransformItem(item.uid, emptyPot)
    elseif(item.itemid == manaPot) then
        if(doTargetCombatMana(0, cid, 170, 230, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
            return FALSE
        end
        doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
        doTransformItem(item.uid, emptyPot)
    elseif(item.itemid == strongHealthPot) then
        if getPlayerLevel(cid) >= 50 and isInArray(knightsandpaladins, getPlayerVocation(cid)) == TRUE then
            if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 300, 500, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
                return FALSE
            end
            doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doTransformItem(item.uid, strongEmptyPot)
        else
            doCreatureSay(cid, "Only knights and paladins of level 50 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        end
    elseif(item.itemid == strongManaPot) then
        if getPlayerLevel(cid) >= 50 and isInArray(druidspaladinsandsorcerers, getPlayerVocation(cid)) == TRUE then
            if(doTargetCombatMana(0, cid, 300, 500, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
                return FALSE
            end
            doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doTransformItem(item.uid, strongEmptyPot)
        else
            doCreatureSay(cid, "Only druids, sorcerers and paladins of level 50 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        end
    elseif(item.itemid == greatHealthPot) then
        if getPlayerLevel(cid) >= 80 and isInArray(knights, getPlayerVocation(cid)) == TRUE then
            if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 500, 800, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
                return FALSE
            end
            doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doTransformItem(item.uid, greatEmptyPot)
        else
            doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        end
    elseif(item.itemid == greatManaPot) then
        if getPlayerLevel(cid) >= 80 and isInArray(druidsandsorcerers, getPlayerVocation(cid)) == TRUE then
            if(doTargetCombatMana(0, cid, 500, 800, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
                return FALSE
            end
            doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doTransformItem(item.uid, greatEmptyPot)
        else
            doCreatureSay(cid, "Only druids and sorcerers of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        end
    end

    return TRUE
end

:thumbup:
 
Last edited:
ok .. but i think only knights can use GreatHealthPot...StrongHealthPotion...
and StrongManaPotion is for sorc/druid and pally..
or no?
 
Thanks, fixed :)

Strong mana potions for druids, sorcerers and paladins level 50.
Strong health potions for knights and paladins level 50.
Great mana potions for druids and sorcerers level 80.
Great health potions for knights level 80.
 
Last edited:
StrongHealth is only for knight =]
No have knight and pally potions =]

other thing
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
i don't know if player say Aaaah... when use... but i really think theys don't say the cancel msg o.o
doCreatureSay(cid, "Only knights and paladins of level 50 or above may drink this fluid.", TALKTYPE_ORANGE_1)

only it =]
 
The player says both messages, and the other player can see it too :p

Screenshot from Tibia:
greathealthbu8.jpg
 
Ah, and strong health potions are for knights and paladins :)
12:02 You see a strong health potion.
It weighs 2.00 oz.
This potion can only be consumed by knights and paladins of level 50 or higher.
^^
 
@Nightmare
this lines is not needed because who this have on items.xml

Code:
doCreatureSay(cid, "Only druids and sorcerers of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)

i go comit this

thanks
 
What is difference between
Code:
if(doTargetCombatMana(0, cid, 300, 500, CONST_ME_MAGIC_BLUE) == LUA_ERROR)
and
Code:
doPlayerAddMana(cid, math.random(300, 500))

2nd is used in standard fluids, so i want know which one is better and what more gives. Thanks :)
 
@Lithium
But it will show these message when a low-lvl try to use a great potion? On Tibia it shows, just loot the screenshot I've posted.

@slawkens
Don't know, this script is from TFS SVN, I've only added the vocation and level conditions...
 
@Nightmare
already fixed and optimized the script in TFS repository
 
i got stupid question, what i have to put in actions.xml?
 
Last edited:
Back
Top