local HealthPotions = {
[8377] = {min=1400,max=1700,trans=7635,lvl=200,voc={4,8}},
[7591] = {min=1100,max=1500,trans=7635,lvl=130,voc={4,8}},
[7588] = {min=400,max=1200,trans=7634,lvl=60,voc={3,4,7,8}},
[7618] = {min=270,max=330,trans=7636,lvl=8,voc={1,2,3,4,5,6,7,8}}
}
local ManaPotions = {
[7590] = {min=200,max=350,trans=7635,lvl=80,voc={1,2,5,6}},
[7589] = {min=100,max=200,trans=7634,lvl=50,voc={1,2,3,5,6,7}},
[7620] = {min=85,max=150,trans=7636,lvl=8,voc={1,2,3,4,5,6,7,8}}
}
local BothPotions = {
[8376] = {hmin=700,hmax=900,mmin=150,mmax=250,trans=7635,lvl=150,voc={3,7}},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if itemEx.uid ~= cid or itemEx.itemid ~= 1 then
return TRUE
end
local HealthP = HealthPotions[item.itemid]
local ManaP = ManaPotions[item.itemid]
local BothP = BothPotions[item.itemid]
if HealthP then
if isInArray(HealthP.voc, getPlayerVocation(cid)) == TRUE and getPlayerLevel(cid) >= HealthP.lvl or getPlayerGroupId(cid) >= 2 then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, HealthP.min, HealthP.max, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "AAHHLMIGHTY!!...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
else
doCreatureSay(cid, "This potion can only be consumed by " .. getVocationsName(HealthP.voc) .. " of level " .. HealthP.lvl .. " or higher.", TALKTYPE_ORANGE_1)
end
elseif ManaP then
if isInArray(ManaP.voc, getPlayerVocation(cid)) == TRUE and getPlayerLevel(cid) >= ManaP.lvl or getPlayerGroupId(cid) >= 2 then
if(doTargetCombatMana(0, cid, ManaP.min, ManaP.max, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
else
doCreatureSay(cid, "This potion can only be consumed by " .. getVocationsName(ManaP.voc) .. " of level " .. ManaP.lvl .. " or higher.", TALKTYPE_ORANGE_1)
end
elseif BothP then
if isInArray(BothP.voc, getPlayerVocation(cid)) == TRUE and getPlayerLevel(cid) >= BothP.lvl or getPlayerGroupId(cid) >= 2 then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, BothP.hmin, BothP.hmax, CONST_ME_MAGIC_BLUE) == LUA_ERROR or doTargetCombatMana(0, cid, BothP.mmin, BothP.max, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "AAAHHHWSOME!!...", TALKTYPE_ORANGE_1)
doRemoveItem(item.uid,1)
else
doCreatureSay(cid, "This potion can only be consumed by " .. getVocationsName(BothP.voc) .. " of level " .. BothP.lvl .. " or higher.", TALKTYPE_ORANGE_1)
end
end
return TRUE
end