- Joined
- Apr 22, 2013
- Messages
- 39
- Solutions
- 1
- Reaction score
- 15
Hi everyone!
I'm trying to make a rewards system by vocation, but seems I can't get it to work.
I am using TFS 1.2
This is my script:
No error or anything, but nothing happens.
Also, if someone has an idea how to give the knight weapons according to skill in a prettier/more efficient way, I'm open to suggestions.
Thanks in advance!
I'm trying to make a rewards system by vocation, but seems I can't get it to work.
I am using TFS 1.2
This is my script:
Lua:
local rewards = {
[{1,5}] = { -- sorcerer
[20] = {items = {{itemid = 2160, count = 2}, {itemid = 8900, count = 1}}, storage = 40953},
[50] = {items = {{itemid = 2160, count = 5}, {itemid = 8902, count = 1}}, storage = 40955},
[80] = {items = {{itemid = 2160, count = 10}, {itemid = 18409, count = 1}, {itemid = 18390, count = 1}}, storage = 40955},
[150] = {items = {{itemid = 2160, count = 20}, {itemid = 16112, count = 1}}, storage = 40955},
},
[{2,6}] = { -- druid
[20] = {items = {{itemid = 2160, count = 2}, {itemid = 8900, count = 1}}, storage = 40955},
[50] = {items = {{itemid = 2160, count = 5}, {itemid = 8902, count = 1}}, storage = 40955},
[80] = {items = {{itemid = 2160, count = 10}, {itemid = 18411, count = 1}, {itemid = 18412, count = 1}}, storage = 40955},
[150] = {items = {{itemid = 2160, count = 20}, {itemid = 16112, count = 1}}, storage = 40955},
},
[{3,7}] = { -- paladin
[20] = {items = {{itemid = 2160, count = 2}}, storage = 40955},
[50] = {items = {{itemid = 2160, count = 5}}, storage = 40955},
[80] = {items = {{itemid = 2160, count = 10}, {itemid = 8855, count = 1}, {itemid = 15644, count = 1}}, storage = 40955},
[150] = {items = {{itemid = 2160, count = 20}, {itemid = 22417, count = 1}, {itemid = 22420, count = 1}}, storage = 40955},
},
[{4,8}] = { -- knight
[20] = {items = {{itemid = 2160, count = 2}, {itemid = 8900, count = 1}}, storage = 40955},
[50] = {items = {{itemid = 2160, count = 5}, {itemid = 8902, count = 1}}, storage = 40955},
[80] = {items = {{itemid = 2160, count = 10}, {itemid = 2536, count = 1}}, storage = 40955},
[150] = {items = {{itemid = 2160, count = 20}, {itemid = 18410, count = 1}}, storage = 40955},
}
}
function onAdvance(player, skill, oldlevel, newlevel)
if skill ~= SKILL_LEVEL then
return true
end
for voc, x in pairs(rewards) do
if isInArray(voc, player:getVocation()) then
for level, z in pairs(x) do
if newlevel >= level and player:getStorageValue(z.storage) < 1 then
player:setStorageValue(z.storage, 1)
for v = 1, #z.items do
player:addItem(z.items[v].itemid, z.items[v].count)
end
if newlevel == 80 then
if player:getVocation() == 4 or player:getVocation() == 8 then
club = player:getSkillLevel(SKILL_CLUB)
sword = player:getSkillLevel(SKILL_SWORD)
axe = player:getSkillLevel(SKILL_AXE)
if club > sword and club > axe then -- CLUB
player:addItem(22410, 1)
player:addItem(22413, 1)
elseif sword > club and sword > axe then -- SWORD
player:addItem(22398, 1)
player:addItem(22401, 1)
elseif axe > club and axe > sword then -- AXE
player:addItem(22404, 1)
player:addItem(22407, 1)
end
end
end
if newlevel == 150 then
if player:getVocation() == 4 or player:getVocation() == 8 then
club = player:getSkillLevel(SKILL_CLUB)
sword = player:getSkillLevel(SKILL_SWORD)
axe = player:getSkillLevel(SKILL_AXE)
if club > sword and club > axe then -- CLUB
player:addItem(22411, 1)
player:addItem(22414, 1)
elseif sword > club and sword > axe then -- SWORD
player:addItem(22399, 1)
player:addItem(22402, 1)
elseif axe > club and axe > sword then -- AXE
player:addItem(22405, 1)
player:addItem(22408, 1)
end
end
end
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations, you reached level "..level.." and received your rewards!")
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
player:setStorageValue(z.storage, 1)
end
end
end
end
return true
end
No error or anything, but nothing happens.
Also, if someone has an idea how to give the knight weapons according to skill in a prettier/more efficient way, I'm open to suggestions.
Thanks in advance!