president vankk
Web Developer & AuraOT Owner
- Joined
- Jul 10, 2009
- Messages
- 5,719
- Solutions
- 9
- Reaction score
- 339
Hi my dear friends,
What I'm doing wrong with this script below? The idea is pretty simple, when the player use the item he will recive mana or even more health, or then skills as well, but it is not working, there is no problems on console, nothing, xD.
Also, seems this part player:setStorageValue(Storage.Ferumbras, math.max(0, Storage.Ferumbras) + 1) is not working too.
Thanks.
What I'm doing wrong with this script below? The idea is pretty simple, when the player use the item he will recive mana or even more health, or then skills as well, but it is not working, there is no problems on console, nothing, xD.
Also, seems this part player:setStorageValue(Storage.Ferumbras, math.max(0, Storage.Ferumbras) + 1) is not working too.
Code:
local skills = {
-- sorcerer
[1] = {
mana = 300,
ml = 5
},
-- druid
[2] = {
mana = 300,
ml = 5
},
-- paladin
[3] = {
health = 300,
skills = {
[SKILL_SHIELD] = 5,
[SKILL_DISTANCE] = 5,
}
},
-- knight
[4] = {
health = 300,
skills = {
[SKILL_SWORD] = 5,
[SKILL_AXE] = 5,
[SKILL_CLUB] = 5,
}
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local vocation = player:getVocation()
local info = skills[vocation:getId()]
if not info then
return true
end
if player:getStorageValue(Storage.Ferumbras) == 2 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'Você não pode utilizar mais esse item. Já atingiu o limite permitido.')
return true
end
if info.ml then
local ml = player:getBaseMagicLevel()
for i = ml + 1, info.ml do
player:addManaSpent(vocation:getRequiredManaSpent(i) - player:getManaSpent())
end
end
if info.health then
local tmpCondition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
tmpCondition:setTicks(-1)
tmpCondition:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, info.health)
player:addCondition(tmpCondition)
end
if info.mana then
local tmpCondition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
tmpCondition:setTicks(-1)
tmpCondition:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTS, info.mana)
player:addCondition(tmpCondition)
end
for skill, level in pairs(info.skills) do
local skillLevel = player:getSkillLevel(skill)
for i = skillLevel + 1, level do
player:addSkillTries(skill, vocation:getRequiredSkillTries(skill, i) - player:getSkillTries(skill))
end
end
player:setStorageValue(Storage.Ferumbras, math.max(0, Storage.Ferumbras) + 1)
--item:remove()
return true
end
Thanks.