• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Vocation Rewards per Level

Fa7Zilla

aux1lia.net
Joined
May 13, 2014
Messages
63
Reaction score
7
Location
Edron?
Hello guys, im useing this Script and i have some issues with it... For example... At level 30 it must give dwarven fang, knight axe and dragon hammer to Knights... But script execute itself when Knight reach 30 SKILLS...

Could someone check what's wrong ?

local config, storage = {

[{1, 5}] = {

[20] = {

{

{2188, 1}

}

},

[35] = {

{

{2187, 1}

}

},

[50] = {

{

{8871, 1}, {8902, 1}

}

}

},

[{2, 6}] = {

[20] = {

{

{2185, 1}

}

},

[35] = {

{

{2183, 1}

}

},

[50] = {

{

{8871, 1}, {8902, 1}

}

}

},

[{3, 7}] = {

[15] = {

{

{2389, 10}

}

},

[25] = {

{

{2455, 1}, {2543, 200}

}

},

[35] = {

{

{7378, 10}

}

}

},

[55] = {

{

{15644, 1}, {2547, 200}

}

},

[{4, 8}] = {

[30] = {

{

{7408, 1}, {7750, 1}, {2434, 1}

}

},

[55] = {

{

{7404, 1}, {15451, 1}, {15647, 1}

}

},

[100] = {

{

{2160, 10}

}

}

}

}, 123



function onAdvance(cid, skill, oldLevel, newLevel)

local player = Player(cid)

if skill ~= 8 then

return true

end



for vocation, k in pairs(config) do

if isInArray(vocation, player:getVocation():getId()) then

for level, v in pairs(k) do

if newLevel >= level and player:getStorageValue(storage + level) ~= 1 then

local text = ""

for i = 1, #v[1] do

local itemType = ItemType(v[1][1])

text = text .. (i ~= 1 and (i == #v[1] and " and " or ", ") or "") .. (v[1][2] > 1 and v[1][2] or itemType:getArticle()) .. " " .. (v[1][2] > 1 and itemType:getPluralName() or itemType:getName())

player:addItem(v[1][1], v[1][2])

end

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Congratulations, you reached level %d and received %s.", level, text))

player:setStorageValue(storage + level, 1)

end

end

end

end

return true

end
 
not working bro
replace your script with this one
Code:
local c = {
   [{1,5}] = { -- sorcerer
     [20] = {items = {{itemid = 2188, count = 1}}, storage = 40953},
     [35] = {items = {{itemid = 2187, count = 1}}, storage = 40954},
     [50] = {items = {{itemid = 8921, count = 1}, {itemid = 8902, count = 1}}, storage = 40955}
   },
   [{2,6}] = { -- druid
     [20] = {items = {{itemid = 2185, count = 1}}, storage = 40953},
     [35] = {items = {{itemid = 2183, count = 1}}, storage = 40954},
     [50] = {items = {{itemid = 8871, count = 1}, {itemid = 8902, count = 1}}, storage = 40955}
   },
   [{3,7}] = { -- paladin
     [15] = {items = {{itemid = 2389, count = 10}}, storage = 40953},
     [25] = {items = {{itemid = 2455, count = 1}, {itemid = 2543, count = 200}}, storage = 40954},
     [35] = {items = {{itemid = 7378, count = 10}}, storage = 40955},
     [50] = {items = {{itemid = 15644, count = 1}, {itemid = 2547, count = 200}}, storage = 40956}
   },
   [{4,8}] = { -- knight
     [30] = {items = {{itemid = 7408, count = 1}, {itemid = 7750, count = 1}, {itemid = 2434, count = 1}}, storage = 40953},
     [55] = {items = {{itemid = 7404, count = 1}, {itemid = 15451, count = 1}, {itemid = 15647, count = 1}}, storage = 40954},
     [100] = {items = {{itemid = 2160, count = 10}}, storage = 40955}
   }
}
function onAdvance(cid, skill, oldlevel, newlevel)
         if skill ~= SKILL__LEVEL then
             return true
         end
         for voc, x in pairs(c) do
             if isInArray(voc, getPlayerVocation(cid)) then
                     for level, z in pairs(x) do
                         if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
                    local text = ""
                    for v = 1, #z.items do
                        count, info = z.items[v].count, getItemInfo(z.items[v].itemid)
                        local ret = ", "
                        if v == 1 then
                            ret = ""
                        elseif v == #z.items then
                            ret = " and "
                        end
                        text = text .. ret
                        text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
                        doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
                    end
                                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you reached level "..level.." and received "..text..".")
                                 doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
                                 setPlayerStorageValue(cid, z.storage, 1)
                         end
                     end
             end
         end
         return true
end
 
replace your script with this one
Code:
local c = {
   [{1,5}] = { -- sorcerer
     [20] = {items = {{itemid = 2188, count = 1}}, storage = 40953},
     [35] = {items = {{itemid = 2187, count = 1}}, storage = 40954},
     [50] = {items = {{itemid = 8921, count = 1}, {itemid = 8902, count = 1}}, storage = 40955}
   },
   [{2,6}] = { -- druid
     [20] = {items = {{itemid = 2185, count = 1}}, storage = 40953},
     [35] = {items = {{itemid = 2183, count = 1}}, storage = 40954},
     [50] = {items = {{itemid = 8871, count = 1}, {itemid = 8902, count = 1}}, storage = 40955}
   },
   [{3,7}] = { -- paladin
     [15] = {items = {{itemid = 2389, count = 10}}, storage = 40953},
     [25] = {items = {{itemid = 2455, count = 1}, {itemid = 2543, count = 200}}, storage = 40954},
     [35] = {items = {{itemid = 7378, count = 10}}, storage = 40955},
     [50] = {items = {{itemid = 15644, count = 1}, {itemid = 2547, count = 200}}, storage = 40956}
   },
   [{4,8}] = { -- knight
     [30] = {items = {{itemid = 7408, count = 1}, {itemid = 7750, count = 1}, {itemid = 2434, count = 1}}, storage = 40953},
     [55] = {items = {{itemid = 7404, count = 1}, {itemid = 15451, count = 1}, {itemid = 15647, count = 1}}, storage = 40954},
     [100] = {items = {{itemid = 2160, count = 10}}, storage = 40955}
   }
}
function onAdvance(cid, skill, oldlevel, newlevel)
         if skill ~= SKILL__LEVEL then
             return true
         end
         for voc, x in pairs(c) do
             if isInArray(voc, getPlayerVocation(cid)) then
                     for level, z in pairs(x) do
                         if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
                    local text = ""
                    for v = 1, #z.items do
                        count, info = z.items[v].count, getItemInfo(z.items[v].itemid)
                        local ret = ", "
                        if v == 1 then
                            ret = ""
                        elseif v == #z.items then
                            ret = " and "
                        end
                        text = text .. ret
                        text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
                        doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
                    end
                                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you reached level "..level.." and received "..text..".")
                                 doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
                                 setPlayerStorageValue(cid, z.storage, 1)
                         end
                     end
             end
         end
         return true
end

Is there a way to remove the old item given? Like, removing an axe given before if its in the hand of the player? If not, not remove anything
 
Thanks! But in doing that, it will remove the item even if it's in his backpack right? I want it to remove the item only if it's in his hand. How should I do that?
 
Thanks! But in doing that, it will remove the item even if it's in his backpack right? I want it to remove the item only if it's in his hand. How should I do that?
a = player:getSlotItem(CONST_SLOT_LEFT)
b = player:getSlotItem(CONST_SLOT_RIGHT)
if a == itemid or b == itemid then ... end
idk how is named on tfs 0.3~ but there must have the same =)
 
a = player:getSlotItem(CONST_SLOT_LEFT)
b = player:getSlotItem(CONST_SLOT_RIGHT)
if a == itemid or b == itemid then ... end
idk how is named on tfs 0.3~ but there must have the same =)

Code:
local a = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
local b = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
if a.itemid == id or b.itemid == id then
~~
return true
end
:)
 
Back
Top