diff --git a/New Text Document.txt b/New Text Document.txt index 1dc6e3b..db0efca 100644 --- a/New Text Document.txt +++ b/New Text Document.txt @@ -1 +1 @@ -next: 17723 \ No newline at end of file +next: 17729 \ No newline at end of file diff --git a/data/actions/actions.xml b/data/actions/actions.xml index e05c8ad..1d4936f 100644 --- a/data/actions/actions.xml +++ b/data/actions/actions.xml @@ -239,7 +239,7 @@ - + diff --git a/data/actions/scripts/misc/skill_trainer.lua b/data/actions/scripts/misc/skill_trainer.lua index a35d2c6..a41a360 100644 --- a/data/actions/scripts/misc/skill_trainer.lua +++ b/data/actions/scripts/misc/skill_trainer.lua @@ -1,13 +1,13 @@ local statues = { - [2032] = SKILL_SWORD, - [18489] = SKILL_AXE, - [18490] = SKILL_CLUB, - [18491] = SKILL_DISTANCE, - [18492] = SKILL_MAGLEVEL + [17725] = SKILL_SWORD, + [17724] = SKILL_AXE, + [17726] = SKILL_CLUB, + [17727] = SKILL_DISTANCE, + [17728] = SKILL_MAGLEVEL } function onUse(player, item, fromPosition, target, toPosition, isHotkey) - local skill = statues[item:getId()] + local skill = statues[item:getActionId()] if not player:isPremium() then player:sendCancelMessage(RETURNVALUE_YOUNEEDPREMIUMACCOUNT) return true @@ -16,8 +16,15 @@ function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:isPzLocked() then return false end - + + local entreePrice = 1000 + if player:getBankBalance() < entreePrice then + player:sendCancelMessage("You do not have 1000 gold coins in your bank account balance to participate in offline training.") + return true + end + player:setOfflineTrainingSkill(skill) + player:setBankBalance(player:getBankBalance() - entreePrice) player:remove() return true end diff --git a/data/creaturescripts/scripts/offlinetraining.lua b/data/creaturescripts/scripts/offlinetraining.lua index 325f6dd..fd651b5 100644 --- a/data/creaturescripts/scripts/offlinetraining.lua +++ b/data/creaturescripts/scripts/offlinetraining.lua @@ -10,7 +10,8 @@ function onLogin(player) player:setOfflineTrainingSkill(-1) if offlineTime < 600 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be logged out for more than 10 minutes to start offline training.") + player:setBankBalance(player:getBankBalance() + 1000) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be logged out for more than 10 minutes to start offline training. Your 1000 gold coins entree fee were returned to your bank account.") return true end diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index 5f51c2d..4f4089d 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -1,5 +1,38 @@ +local trainingStatues = {17724, 17725, 17726, 17727, 17728} + function Player:onLook(thing, position, distance) local description = "You see " .. thing:getDescription(distance) + + if thing:isItem() and thing:getId() == 2028 then + if isInArray(trainingStatues, thing:getActionId()) then + local trainingTime = math.min(43200, self:getOfflineTrainingTime() / 1000) + local text = "You have" + 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 offline training time remaining.", text) + + description = string.format(description .. "%s", text) + end + end + if self:getGroup():getAccess() then if thing:isItem() then description = string.format("%s\nItem ID: %d", description, thing:getId()) diff --git a/data/world792/map.otbm b/data/world792/map.otbm index ee85a5a..f3c589a 100644 Binary files a/data/world792/map.otbm and b/data/world792/map.otbm differ