local config = {
tileActionId = 9000, -- Tile actionId in RME
exhaustTime = 40, -- Exhaust time in minutes.
allowNoneVoc = false -- Set to true to allow the None(0) vocation
debugMode = true, -- Sets exhaustTime to 20 seconds. Change to false in live environment.
experience = 100000,
addSkills = true,
skill_types = {SKILL_AXE, SKILL_SWORD, SKILL_CLUB, SKILL_DISTANCE, SKILL_SHIELD, SKILL_FIST},
skill_tries = 100000,
addMagic = true,
magic_tries = 100000,
}
--dont edit below
local store = {}
local function removeExhaust(key)
if store[key] then
store[key] = nil
end
return
end
local gainXpAndSkills = MoveEvent()
function gainXpAndSkills.onStepIn(player, item, position, fromPosition)
--do basic checks
if not player:isPlayer() or (not config.allowNoneVoc and player:getVocation():getId() == 0) then
return false
end
local now = os.time()
local playerId = player:getGuid()
local key = ('%d:%d:%d:%d'):format(playerId, position.x, position.y, position.z)
--check for exhaust
if store[key] then
player:teleportTo(fromPosition)
position:sendMagicEffect(CONST_ME_POFF)
fromPosition:sendMagicEffect(CONST_ME_POFF)
local remainder = store[key] - now
local hours = floor(remainder / 3600)
local minutes = floor((remainder % 3600) / 60)
local seconds = remainder % 60
local remainderString = ("%02dh:%02dm:%02ds"):format(hours, minutes, seconds)
player:sendTextMessage(MESSAGE_STATUS_SMALL , ('You can use this again in %s'):format(remainderString))
return true
end
--add exp
player:addExperience(config.experience, true)
--add skill tries
if config.addSkills then
for _, skill_type in ipairs(config.skill_types) do
player:addSkillTries(skill_type, config.skill_tries)
end
end
--add mana tries
if config.addMagic then
player:addManaSpent(config.magic_tries)
end
--schedule the exhaust removal for the future
local _exhaustTime = config.debugMode and 20 or (config.exhaustTime * 60)
addEvent(removeExhaust, _exhaustTime * 1000, key)
store[key] = now + _exhaustTime
return true
end
gainXpAndSkills:aid(config.tileActionId)
gainXpAndSkills:register()