Ir para conteúdo

[Encerrado] [Encerrado] Offline Training Script Bug


Posts Recomendados

Prezados, Gostaria de saber qual o problema do script de Offline Training , os personagens não conseguem sequer logar no servidor. Vou postar o script.

Obrigado a todos desde já

 

 

  1. Citar

     

    1. function onLogin(player)
    2.     local lastLogout = player:getLastLogout()
    3.     local offlineTime = lastLogout ~=  math.min(os.time() - lastLogout, 86400 * 21) or 0
    4.     local offlineTrainingSkill = player:getOfflineTrainingSkill(1)
    5.     if offlineTrainingSkill == -1 then
    6.         player:addOfflineTrainingTime(offlineTime * 1000)
    7.         return true
    8.     end
    9.     player:setOfflineTrainingSkill(-1)
    10.     if offlineTime < 600 then
    11.         player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be logged out for more than 10 minutes to start offline training.")
    12.         return true
    13.     end
    14.     local trainingTime = math.max(0, math.min(offlineTime, math.min(43200, player:getOfflineTrainingTime() / 1000)))
    15.     player:removeOfflineTrainingTime(trainingTime * 1000)
    16.     local remainder = offlineTime - trainingTime
    17.     if remainder > 0 then
    18.         player:addOfflineTrainingTime(remainder * 1000)
    19.     end
    20.     if trainingTime < 60 then
    21.         return true
    22.     end
    23.     local text = "During your absence you trained for"
    24.     local hours = math.floor(trainingTime / 3600)
    25.     if hours > 1 then
    26.         text = string.format("%s %d hours", text, hours)
    27.     elseif hours == 1 then
    28.         text = string.format("%s 1 hour", text)
    29.     end
    30.     local minutes = math.floor((trainingTime % 3600) / 60)
    31.     if minutes ~= 0 then
    32.         if hours ~= 0 then
    33.             text = string.format("%s and", text)
    34.         end
    35.         if minutes > 1 then
    36.             text = string.format("%s %d minutes", text, minutes)
    37.         else
    38.             text = string.format("%s 1 minute", text)
    39.         end
    40.     end
    41.     text = string.format("%s.", text)
    42.     player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
    43.     local vocation = player:getVocation()
    44.     local promotion = vocation:getPromotion()
    45.     local topVocation = not promotion and vocation or promotion
    46.     local updateSkills = false
    47.     if isInArray({SKILL_CLUB, SKILL_SWORD, SKILL_AXE, SKILL_DISTANCE}, offlineTrainingSkill) then
    48.         local modifier = topVocation:getAttackSpeed() / 1000
    49.         updateSkills = player:addOfflineTrainingTries(offlineTrainingSkill, (trainingTime / modifier) / (offlineTrainingSkill == SKILL_DISTANCE and 4 or 2))
    50.     elseif offlineTrainingSkill == SKILL_MAGLEVEL then
    51.         local gainTicks = topVocation:getManaGainTicks() * 2
    52.         if gainTicks == 0 then
    53.             gainTicks = 1
    54.         end
    55.         updateSkills = player:addOfflineTrainingTries(SKILL_MAGLEVEL, trainingTime * (vocation:getManaGainAmount() / gainTicks))
    56.     end
    57.     if updateSkills then
    58.         player:addOfflineTrainingTries(SKILL_SHIELD, trainingTime / 4)
    59.     end
    60.     return true
    61. end
       
    62.  

     

     

Link para o comentário
Compartilhar em outros sites

  • 7 months later...
Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...