local t ={
[7844] = { -- donate exp
limit = 450,
exp = 75000000,
},
[7845] = { -- donate ml
mana = 6000000,
limit = {
[isSorcerer] = 130,
[isDruid] = 130,
[isPaladin] = 50,
[isKnight] = 15
}
},
[7846] = { -- donate skill
skill = 250000,
limit = {
[isPaladin] = 130,
[isKnight] = 130
}
}
}
local c=getConfigInfo('rateSkill')
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.itemid]
if v then
if v.exp then
if getPlayerLevel(cid) < v.limit then
doPlayerAddExp(cid, math.min(getExperienceForLevel(v.limit) - getPlayerExperience(cid), math.min(v.exp, getExperienceForLevel(v.limit))))
doSendMagicEffect(getThingPos(cid), 27)
doRemoveItem(item.uid)
else
doPlayerSendCancel(cid, 'You can only use this under level ' .. v.limit .. '.')
end
elseif v.mana then
for f, limit in pairs(v.limit) do
if f(cid) then
if getPlayerMagLevel(cid, true) < limit then
doPlayerAddSpentMana(cid, math.ceil(math.min((getPlayerRequiredMana(cid, limit) - getPlayerSpentMana(cid)), v.mana)))
doSendMagicEffect(getThingPos(cid), 27)
doRemoveItem(item.uid)
else
doPlayerSendCancel(cid, 'You can only use this under magic level ' .. limit .. '.')
end
break
end
end
elseif v.skill then
local skill, n
for f, limit in pairs(v.limit) do
if f(cid) then
if f == isKnight then
skill = {}
for i = 1, 3 do
skill[i] = {i, getPlayerSkillLevel(cid, i, true)}
end
table.sort(skill, function(a,b) return a[2]>b[2] end)
skill, n = skill[1][1], skill[1][2]
else
skill, n = 4, getPlayerSkillLevel(cid, 4, true)
end
if n < limit then
doPlayerAddSkillTry(cid, skill, math.ceil(math.min((getPlayerRequiredSkillTries(cid, skill, limit) - getPlayerSkillTries(cid, skill)) / c, v.skill / c)))
doSendMagicEffect(getThingPos(cid), 27)
doRemoveItem(item.uid)
else
doPlayerSendCancel(cid, 'You can only use this with ' .. SKILL_NAMES[skill] .. ' under ' .. limit .. '.')
end
return true
end
end
doPlayerSendCancel(cid, 'Your vocation cannot use this scroll.')
end
return true
end
end
LUA:local t ={ [7844] = { -- donate exp limit = 450, exp = 75000000, }, [7845] = { -- donate ml mana = 6000000, limit = { [isSorcerer] = 130, [isDruid] = 130, [isPaladin] = 50, [isKnight] = 15 } }, [7846] = { -- donate skill skill = 250000, limit = { [isPaladin] = 130, [isKnight] = 130 } } } local c=getConfigInfo('rateSkill') function onUse(cid, item, fromPosition, itemEx, toPosition) local v = t[item.itemid] if v then if v.exp then if getPlayerLevel(cid) < v.limit then doPlayerAddExp(cid, math.min(getExperienceForLevel(v.limit) - getPlayerExperience(cid), math.min(v.exp, getExperienceForLevel(v.limit)))) doSendMagicEffect(getThingPos(cid), 27) doRemoveItem(item.uid) else doPlayerSendCancel(cid, 'You can only use this under level ' .. v.limit .. '.') end elseif v.mana then for f, limit in pairs(v.limit) do if f(cid) then if getPlayerMagLevel(cid, true) < limit then doPlayerAddSpentMana(cid, math.ceil(math.min((getPlayerRequiredMana(cid, limit) - getPlayerSpentMana(cid)), v.mana))) doSendMagicEffect(getThingPos(cid), 27) doRemoveItem(item.uid) else doPlayerSendCancel(cid, 'You can only use this under magic level ' .. limit .. '.') end break end end elseif v.skill then local skill, n for f, limit in pairs(v.limit) do if f(cid) then if f == isKnight then skill = {} for i = 1, 3 do skill[i] = {i, getPlayerSkillLevel(cid, i, true)} end table.sort(skill, function(a,b) return a[2]>b[2] end) skill, n = skill[1][1], skill[1][2] else skill, n = 4, getPlayerSkillLevel(cid, 4, true) end if n < limit then doPlayerAddSkillTry(cid, skill, math.ceil(math.min((getPlayerRequiredSkillTries(cid, skill, limit) - getPlayerSkillTries(cid, skill)) / c, v.skill / c))) doSendMagicEffect(getThingPos(cid), 27) doRemoveItem(item.uid) else doPlayerSendCancel(cid, 'You can only use this with ' .. SKILL_NAMES[skill] .. ' under ' .. limit .. '.') end return true end end doPlayerSendCancel(cid, 'Your vocation cannot use this scroll.') end return true end end