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?
Thanks for help!
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!