• 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!

Get mounts depending on the vocation

Salvus

Well-Known Member
Joined
Feb 7, 2019
Messages
102
Solutions
1
Reaction score
69
Is it possible to fix this script so you can get mounts depending on the vocation

Code:
function onAdvance(player, skill, oldLevel, newLevel)
    local config = {
        -- [level] {mountId and mountName}
        [100] = {mountId = 1, mountName = "Widow Queen"},
        [2000] = {mountId = 2, mountName = "Racing Bird"},
    }
    
    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end

    local storage = 2100
    for level, i in pairs(config) do
        if newLevel >= level and player:getStorageValue(storage) < level then
            player:addMount(i.mountId)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations, you reached level "..newLevel.." and won the "..i.mountName.." mount.")
            player:setStorageValue(storage, level)
        end
    end
    return true
end


In level 100 knight will get winow Queen and sorcerer will get a Racing Bird in level 100.
Something like that.
 
Try that
Lua:
function onAdvance(player, skill, oldLevel, newLevel)
  local config = {
    -- [level] {
    --  [vocationId] = {mountId and mountName}
    --}
    [100] = {
      [1] = {
        -- Sorcerer
        mountId = 1,
        mountName = "Widow Queen"
      },
      [2] = {
        -- Druid
        mountId = 1,
        mountName = "Widow Queen"
      },
      [3] = {
        -- Paladin
        mountId = 1,
        mountName = "Widow Queen"
      },
      [4] = {
        -- Knight
        mountId = 1,
        mountName = "Widow Queen"
      }
    }
  }

  if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
    return true
  end

  local storage = 2100
  for level, i in pairs(config) do
    if newLevel >= level and player:getStorageValue(storage) < level then
      local voc = player:getVocation():getId()
      voc = voc > 4 and voc - 4 or voc
      local mount = i[voc]
      player:addMount(mount.mountId)
      player:sendTextMessage(
        MESSAGE_EVENT_ADVANCE,
        "Congratulations, you reached level " .. newLevel .. " and won the " .. mount.mountName .. " mount."
      )
      player:setStorageValue(storage, level)
    end
  end
  return true
end
 
That didn't work but i got this from Felipe Silva

Code:
function onAdvance(player, skill, oldLevel, newLevel)
    local config = {
        --  [level] = {vocation = {[vocation_id] = mount_id}}
        [100] = {vocation = {
        [1] = 5,
        [2] = 6,
        [3] = 7,
        [4] = 8,
        [5] = 9,
        [6] = 10,
        [7] = 11,
        [8] = 12}
        
        },
        [2000] = {vocation = {
        [1] = 5,
        [2] = 6,
        [3] = 7,
        [4] = 8,
        [5] = 9,
        [6] = 10,
        [7] = 11,
        [8] = 12}
        
        },
    }

    if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
        return true
    end

    local storage = 2100
    for level, i in pairs(config) do
        if newLevel >= level and player:getStorageValue(storage) < level then
            player:addMount(i.vocation[player:getVocation():getId()])
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations, you reached level "..newLevel.." and won a mount.")
            player:setStorageValue(storage, level)
        end
    end
    return true
end
 
Back
Top