Untitled - MARKUP 4.50 KB
                                
                                    setDefaultTab("Tools")
UI.Separator()
local trainingDummy = { 28565, 28558, 28559, 28560 } --// Training Dummy IDs
local paladinId = 35288 --// Excercise Bow ID
local knightId = 35285  --// Exercise Melee ID (By default Sword)
local mageId = 35289    --// Exercise Magic ID (By default Wand)
local distanceDummy = 4 --// Self-distance from the dummy


--[[
    If you want 100% afk experience I recommend settings up like:
    At: "Ingame Script Editor" set:
    CaveBot.setOn() 

    And on a CaveBot Script:

    exerciseDummy()
    schedule(1000, function() CaveBot.setOff() end)
    return true

    -------------------------------------------------------------

    By default there's ONLY "Ferumbras Training Dummy" IDs, if you're using a non-ferumbras dummy, add the IDs.

    --------------------------------------------------------------

    If you want to use per example different knights with different skills, you can set them below
    player_name = character name
    knightId = the id you want to use
]]

local playerName = player:getName()
if playerName == "player name" then
    knightId = 35287
elseif playerName == "player_name" then
    knightId = 28552
elseif playerName == "player_name" then
    mageId = 28552 
elseif playerName == "player_name" then
    paladinId = 28552   
end

function exerciseDummy()
    for _, tile in ipairs(g_map.getTiles(posz())) do
    --// Checks distance within character and tile
        if getDistanceBetween(pos(), tile:getPosition()) <= distanceDummy then
        --// Get items on top of the floor 
            local item = tile:getTopUseThing()
        --// Checks if the item has the same ID as our table.
            if item and table.find(trainingDummy, item:getId()) then
        --// Checks our vocation, in this case if paladin then use exercise bow.
                if voc() == 2 or voc() == 12 then
                    --tile:setText("Dummy Found RP")
                    item:setMarked("#2eb9ff")
                    --autoWalk(item:getPosition(), 20, {
                    --    ignoreNonPathable = true,
                    --    precision = 0,
                    --    marginMin = 1,
                    --    marginMax = 1
                    --})
                    g_game.useInventoryItemWith(paladinId, item)
                    return true
                end
        --// Checks our vocation, in this case if knight then use melee exercise weapon.
                if voc() == 1 or voc() == 11 then 
                    --tile:setText("Dummy Found EK")
                    item:setMarked("#2eb9ff")
                    autoWalk(item:getPosition(), 20, {
                        ignoreNonPathable = true,
                        precision = 0,
                        marginMin = 1,
                        marginMax = 1
                    })
                    schedule(2000, function() g_game.useInventoryItemWith(knightId, item) end)
                end
            --// Checks our vocation, in this case if mage then use wand or rod weapon.
                if voc() == 3 or voc() == 13 or voc() == 4 or voc() == 14 then
                    --tile:setText("Dummy Found Mage")
                    item:setMarked("#2eb9ff")
                    --autoWalk(item:getPosition(), 20, {
                    --    ignoreNonPathable = true,
                    --    precision = 0,
                    --    marginMin = 1,
                    --    marginMax = 1
                    --})
                    g_game.useInventoryItemWith(mageId, item)
                    return true
                end
        end
    end
end
end

UI.Button("Exercise Dummy", function()
    exerciseDummy()
end)

onTextMessage(function(mode, text)
    if string.match(text, "You have changed position. Training has stopped.") then
        print("[Error] "..text)
        schedule(5000, function() exerciseDummy() end)
    end
    if string.match(text, "This exercise dummy can only be used after a 20 second cooldown.") then
        print("[Error] "..text)
        exerciseDummy()
    end
    if string.match(text, "Your training weapon has disappeared.") then
        print("[Error] "..text)
        exerciseDummy()
    end
  end)
                                
                            

Paste Hosted With By Wklejamy.pl