Hello someone can help me with this script?
I want one potion for all vocations
Example:
800-850 mana for mages.
400-450 Health and 350-400 Mana for paladins.
1300-1350 Health and 200-250 Mana for knights.
TFS 0.4
I want one potion for all vocations
Example:
800-850 mana for mages.
400-450 Health and 350-400 Mana for paladins.
1300-1350 Health and 200-250 Mana for knights.
TFS 0.4
Lua:
local t = {level = 8, mana = {600, 650}, health = {1100, 1150},
voc_add = {
[{1,5,9,13}] = {"mana"},
[{2,6,10,14}] = {"mana"},
[{4,8,12,16}] = {"health"}}
}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, fromPosition, itemEx, toPosition)
local check, p = {}, getPlayerPosition(cid)
for id, v in pairs(t.voc_add) do
if isInArray(id, getPlayerVocation(cid)) then
check = v
break
end
end
if #check == 0 then
doPlayerSendCancel(cid, "Your vocation can not use this item.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
doSendMagicEffect(p, CONST_ME_POFF)
return true
end
if getPlayerLevel(cid) < t.level then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHLEVEL)
doSendMagicEffect(p, CONST_ME_POFF)
return true
end
for i = 1, #check do
if check[i] == "mana" then
doPlayerAddMana(cid, math.ceil(math.random(t.mana[1], t.mana[2])))
else
doCreatureAddHealth(cid, math.ceil(math.random(t.health[1], t.health[2])))
end
end
doSendMagicEffect(p, CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
return true
end