• 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 rewards for each vocation at certain level tfs 1.2

Solution
Unfortunately this doesn't support telling the players the items they received. Other than that it should work.

Lua:
local rewards = {
    SORCERER = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40000},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40001},
    }
 
    DRUID = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40002},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage...
Unfortunately this doesn't support telling the players the items they received. Other than that it should work.

Lua:
local rewards = {
    SORCERER = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40000},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40001},
    }
 
    DRUID = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40002},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40003},
    }
 
    PALADIN = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40004},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40005},
    }
 
    KNIGHT = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40006},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40007},
    }
}

local sorc = {1, 5, 9}
local druid = {2, 6, 10}
local paladin = {3, 7, 11}
local knight = {4, 8, 12}

local magicEffect_reward = 14

function onAdvance(player, skill, oldlevel, newlevel)
         if skill ~= SKILL__LEVEL then
             return true
         end
      
        if isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.SORC
        elseif isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.DRUID
        elseif isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.PALADIN
        elseif isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.KNIGHT
        end
    
        if not VOC then return true end
    
        REWARD = VOC[newlevel]
    
        if not REWARD then return true end
    
        if player:getStorageValue(REWARD.storage) == nil then
            for i = 1, #REWARD.items do
                player:addItem(REWARD.items[i].itemid, rewards.items[i].count)
            end
            player:setStorageValue(REWARD.items[i].storage, 1)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations, you have reached level "..player:getLevel().." and received your rewards.")
            player:getPosition():sendMagicEffect(magicEffect_reward)
        end
      
return true
end
 
Solution
Unfortunately this doesn't support telling the players the items they received. Other than that it should work.

Lua:
local rewards = {
    SORCERER = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40000},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40001},
    }
 
    DRUID = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40002},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40003},
    }
 
    PALADIN = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40004},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40005},
    }
 
    KNIGHT = {
    [10] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40006},
    [20] = {items = {
            [1] = {itemid = 1111, count = 1},
            [2] = {itemid = 1111, count = 1}
            }, storage = 40007},
    }
}

local sorc = {1, 5, 9}
local druid = {2, 6, 10}
local paladin = {3, 7, 11}
local knight = {4, 8, 12}

local magicEffect_reward = 14

function onAdvance(player, skill, oldlevel, newlevel)
         if skill ~= SKILL__LEVEL then
             return true
         end
    
        if isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.SORC
        elseif isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.DRUID
        elseif isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.PALADIN
        elseif isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.KNIGHT
        end
  
        if not VOC then return true end
  
        REWARD = VOC[newlevel]
  
        if not REWARD then return true end
  
        if player:getStorageValue(REWARD.storage) == nil then
            for i = 1, #REWARD.items do
                player:addItem(REWARD.items[i].itemid, rewards.items[i].count)
            end
            player:setStorageValue(REWARD.items[i].storage, 1)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations, you have reached level "..player:getLevel().." and received your rewards.")
            player:getPosition():sendMagicEffect(magicEffect_reward)
        end
    
return true
end


thanks bro, dont work, show error in line 13, and i put "," after each vocation and dont have error, but dont send item to players

make more changes here:

Code:
local sorc = {1, 5, 9}
local druid1 = {2, 6, 10}
local paladin1 = {3, 7, 11}
local knight1 = {4, 8, 12}
local magicEffect_reward = 14
function onAdvance(player, skill, oldlevel, newlevel)
         if skill ~= SKILL__LEVEL then
             return true
         end
  
        if isInArray(sorc, player:getVocation():getId()) then
            VOC = rewards.SORCERER
        elseif isInArray(druid1, player:getVocation():getId()) then
            VOC = rewards.DRUID
        elseif isInArray(paladin1, player:getVocation():getId()) then
            VOC = rewards.PALADIN
        elseif isInArray(knight1, player:getVocation():getId()) then
            VOC = rewards.KNIGHT
        end

but dont work xD
 
Last edited:
Back
Top