is there anything here that indicates how much fast i can raise up my skill or is it…
- User
is there anything here that indicates how much fast i can raise up my skill or is it only about time limit of training local offlineTraining = CreatureEvent("OfflineTraining")
function offlineTraining.onLogin(player) local lastLogout = player:getLastLogout() local offlineTime = lastLogout ~= 0 and math.min(os.time() - lastLogout, 86400 * 21) or 0 local offlineTrainingSkill = player:getOfflineTrainingSkill() if offlineTrainingSkill == SKILL_NONE then player:addOfflineTrainingTime(offlineTime * 1000) return true end
codeplayer:setOfflineTrainingSkill(SKILL_NONE) if offlineTime < 600 then player:sendTextMessage(MESSAGE_OFFLINE_TRAINING, "You must be logged out for more than 10 minutes to start offline training.") return true end local trainingTime = math.max(0, math.min(offlineTime, math.min(43200, player:getOfflineTrainingTime() / 1000))) player:removeOfflineTrainingTime(trainingTime * 1000) local remainder = offlineTime - trainingTime if remainder > 0 then player:addOfflineTrainingTime(remainder * 1000) end if trainingTime < 60 then return true end local text = "During your absence you trained for" local hours = math.floor(trainingTime / 3600) if hours > 1 then text = string.format("%s %d hours", text, hours) elseif hours == 1 then text = string.format("%s 1 hour", text) end local minutes = math.floor((trainingTime % 3600) / 60) if minutes ~= 0 then if hours ~= 0 then text = string.format("%s and", text) end if minutes > 1 then text = string.format("%s %d minutes", text, minutes) else text = string.format("%s 1 minute", text) end end text = string.format("%s.", text) player:sendTextMessage(MESSAGE_OFFLINE_TRAINING, text) local vocation = player:getVocation() local promotion = vocation:getPromotion() local topVocation = not promotion and vocation or promotion local tries = nil if table.contains({ SKILL_CLUB, SKILL_SWORD, SKILL_AXE, SKILL_DISTANCE }, offlineTrainingSkill) then local modifier = topVocation:getBaseAttackSpeed() / 1000 tries = (trainingTime / modifier) / (offlineTrainingSkill == SKILL_DISTANCE and 4 or 2) elseif offlineTrainingSkill == SKILL_MAGLEVEL then local gainTicks = topVocation:getManaGainTicks() / 1000 if gainTicks == 0 then gainTicks = 1 end tries = trainingTime * (vocation:getManaGainAmount() / gainTicks) end local updateSkills = false if tries then updateSkills = player:addOfflineTrainingTries(offlineTrainingSkill, tries * configManager.getFloat(configKeys.RATE_OFFLINE_TRAINING_SPEED)) end if updateSkills then player:addOfflineTrainingTries(SKILL_SHIELD, trainingTime / 4) end return true - Assistant
The script you've provided is for an offline training system in a game, likely a multiplayer online game. It includes logic for how skills are improved during a player's offline time. Here's a breakdown of the relevant parts:
-
Offline Time Calculation:
- The script calculates
offlineTimebased on the player's last logout and the current time, capping at a maximum of 21 days (86400 seconds per day).
- The script calculates
-
- User
if i change the training time logic will it continue training after 12 hours?
- Assistant
In the script, the offline training time is limited by the line:
lualocal trainingTime = math.max(0, math.min(offlineTime, math.min(43200, player:getOfflineTrainingTime() / 1000)))This line ensures that the
trainingTimeis no more than 12 hours (43200 seconds).If you wish to allow training to continue after 12 hours, you need to adjust this logic. Here are a couple of ways you could modify the script:
-
Remove the 12-hour Limitation:
- Change this line to remove the
math.min(43200, ...)condition. This would then only limit by either or the player's available offline training time.
- Change this line to remove the
-