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

OTC progressbar bug

Amai

New Member
Joined
Aug 14, 2010
Messages
2
Reaction score
0
Hi!

Would there be a nice person who knows the solution to the problem with progressbar? It's about badly count off the remaining time to the next level. This happens at high levels, from around 600 lvl +. Where is the problem?

Lua:
function checkExpSpeed()
  local player = g_game.getLocalPlayer()
  if not player then return end

  local currentExp = player:getExperience()
  local currentTime = g_clock.seconds()
  if player.lastExps ~= nil then
    player.expSpeed = (currentExp - player.lastExps[1][1])/(currentTime - player.lastExps[1][2])
    onLevelChange(player, player:getLevel(), player:getLevelPercent())
  else
    player.lastExps = {}
  end
  table.insert(player.lastExps, {currentExp, currentTime})
  if #player.lastExps > 30 then
    table.remove(player.lastExps, 1)
  end
end



  if localPlayer.expSpeed ~= nil then
     local expPerHour = math.floor(localPlayer.expSpeed * 3600)
     if expPerHour > 0 then
        local nextLevelExp = expForLevel(localPlayer:getLevel()+1)
        local hoursLeft = (nextLevelExp - localPlayer:getExperience()) / expPerHour
        local minutesLeft = math.floor((hoursLeft - math.floor(hoursLeft))*60)
        hoursLeft = math.floor(hoursLeft)
        text = text .. '\n\n' .. tr('Next level in %d hours and %d minutes.', hoursLeft, minutesLeft)
        text = text .. '\n(' .. tr('%d of experience per hour)', expPerHour)
     end
  end
  text = text .. '\n\nTotal experience: ' .. tr('%s', localPlayer:getExperience())
  setSkillPercent('level', percent, text)

Thanks for help!
 
Top