Scripts

    Player on screen alarm ignoring friends

    Plays an alarm when you see player that is not in whitelist

    local whitelist = {
        "FriendName1", 
        "FriendName2", 
        "FriendName3",
    }
    
    local function isInWhitelist(playerName)
        local selfName = getSelfName()
        for _, name in ipairs(whitelist) do
            if playerName == name then
                return true
            end
            if selfName ~= nil and playerName == selfName then
                return true
            end
        end
        return false
    end
    
    local function checkForPlayers()
        local players = getScreenPlayers()
        for _, player in ipairs(players) do
            local playerName = getCreatureName(player)
            if playerName and not isInWhitelist(playerName) then
                playSound("playerOnScreen.wav")
                break
            end
        end
    end
    
    autoRun(1000, checkForPlayers)

    Player with white/red/black skull on screen alarm

    local function alarm()
        local players = getScreenPlayers()
        for _, player in ipairs(players) do
            if getSkull(player) >= 3 then
                playSound("playerOnScreen.wav")
                break
            end
        end
    end
    
    autoRun(1000, alarm)

    Logout if any player on screen

    Checks only players visible on screen

    local function f()
        if #getScreenPlayers() > 1 then
            xlog()
            sleep(1000)
        end
    end
    
    autoRun(100, f)

    Logout if any player on screen (multifloor)

    Checks all player. On screen and on higher/lower levels.

    local function logoutMultifloor()
        local selfName = getSelfName()
        if selfName == nil then
            return
        end
        for i, creature in ipairs(getCreaturesMultiFloor()) do
            if isPlayer(creature) and getCreatureName(creature) ~= selfName then
                xlog()
                sleep(500)
                return
            end
        end
    end
    
    autoRun(100, logoutMultifloor)

    Logout if no blank runes

    local ITEM_ID = 3147 -- blank rune
    
    local function f()
        if getItemCount(ITEM_ID) == 0 then
            xlog()
            sleep(1000)
        end
    end
    
    autoRun(1000, f)

    Drop items on the ground

    Change ITEMS_TO_DROP to add more items

    local ITEMS_TO_DROP = {
        3264, -- sword
        3286, -- mace
    }
    
    local function f()
        for _, itemId in ipairs(ITEMS_TO_DROP) do
            dropItem(itemId, 1)
        end
    end
    
    autoRun(300, f)

    Use torch and drop on ground

    Useful when hunting monsters that drop torches. It will light up the respawn

    local INACTIVE_TORCH_ID = 2920
    local ACTIVE_TORCH_ID = 2921
    
    local function f()
        if getItemCount(INACTIVE_TORCH_ID) then
            useItemInContainer(INACTIVE_TORCH_ID)
        end
        if getItemCount(ACTIVE_TORCH_ID) then
            dropItem(ACTIVE_TORCH_ID , 1)
        end
    end
    
    autoRun(200, f)

    Spear pickup and equip

    Pickup spears from ground if your character is near it. Moves corpses when spear is under it. Also puts spears from backpack to hand

    local SPEAR_ID = 3277
    local BACKPACK_ID = 2854
    
    local function f()
        if getItemCount(SPEAR_ID) > 1 then
            equipItem(RIGHT_HAND_SLOT, SPEAR_ID, 5)
            sleep(math.random(200,300))
        end
        collectNearbyGroundItemMoveCorpses(BACKPACK_ID, SPEAR_ID)
        sleep(math.random(300, 500))
    end
    
    autoRun(100, f)

    Equip ammo (arrow, bolts)

    Equip ammo from open backpacks to arrow slot. Edit AMMO_ID

    local AMMO_ID = 7368
    
    local function f()
      equipItem(AMMO_SLOT, AMMO_ID , 100)
      sleep(math.random(100000, 200000))
    end
    
    autoRun(1, f)

    Auto energy ring

    Equip energy ring at low hp and remove it at high hp. Edit ID or HPPCs for custom values

    local E_RING_ID = 3051
    local EQUIPED_E_RING_ID = 3088
    local UNEQUIP_HPPC = 80
    local EQUIP_HPPC = 40
    
    local function f()
      local equippedRingId = getInventoryItemId(RING_SLOT)
      local hppc = getPlayerHppc()
      if equippedRingId == EQUIPED_E_RING_ID and hppc >= UNEQUIP_HPPC then
        unequip(RING_SLOT)
        return
      end
      if hppc <= EQUIP_HPPC and equipedRingId ~= EQUIPED_E_RING_ID then
        equipItem(RING_SLOT, E_RING_ID, 1)
      end
    end
    
    autoRun(100, f)

    Auto life ring

    Equip life ring at low mp and remove it at higher mp. Edit ID or MPPCs for custom values

    local LIFE_RING_ID = 3052
    local EQUIPED_LIFE_RING_ID = 3089
    local UNEQUIP_MPPC = 10
    local EQUIP_MPPC = 5
    
    local function f()
      local equippedRingId = getInventoryItemId(RING_SLOT)
      local mppc = getPlayerMppc()
      if equippedRingId == EQUIPED_LIFE_RING_ID and mppc >= UNEQUIP_MPPC then
        unequip(RING_SLOT)
        return
      end
      if mppc <= EQUIP_MPPC and equipedRingId ~= EQUIPED_LIFE_RING_ID then
        equipItem(RING_SLOT, LIFE_RING_ID, 1)
      end
    end
    
    autoRun(1000, f)

    Auto follow friend (map click)

    Edit followedPlayer to the name of friend you want to follow. This will use map clicks for walking so targeting can be enabled

    local followedPlayer = "Pan Tadeusz"
    
    local function f()
        local followed = getCreatureByName(followedPlayer)
        mapClickChase(followed)
    end
    
    autoRun(20, f)

    Heal friend by name (auto exura sio)

    Uses Exura sio on friend if below certain HP%

    local SIO_FRIEND_NAME = "MyFriend"
    local SIO_HPPC = 80
    
    local function heal()
        local friend = getCreatureByName(SIO_FRIEND_NAME)
        if friend == nil then
            return
        end
        if getCreatureHppc(friend) <= SIO_HPPC then
            talk('exura sio "' .. SIO_FRIEND_NAME)
        end
    end
    
    autoRun(500, heal)

    Heal friends with UH

    Uses UH on friend if below certain HP%

    local UH_RUNE_ID = 3160
    local UH_HPPC = 40
    
    local FRIEND_LIST = {
        "FRIEND1",
        "FRIEND2",
    }
    
    local function isFriend(creature)
        for _, friend in ipairs(FRIEND_LIST) do
            if friend == getCreatureName(creature) then
                return true
            end
        end
        return false
    end
    
    local function autoUh()
        for _, friend in ipairs(getScreenPlayers()) do
            if isFriend(friend) and getCreatureHppc(friend) <= UH_HPPC then
                useItemFromOpenContainerOnThing(UH_RUNE_ID, friend)
                sleep(1000)
                return
            end
        end
    end
    
    autoRun(300, autoUh)

    Mana train

    Uses Spell above % mana

    local MANA_PERCENT = 60  -- change
    local MANA_TRAIN_SPELL = "utevo lux" -- change
    
    local function manaTrain()
        if getPlayerMppc() >= MANA_PERCENT then
            talk(MANA_TRAIN_SPELL)
        end
    end
    
    autoRun(2000, manaTrain)

    custom mana fluid

    Uses mana fluid when low mana

    local CUSTOM_MANA_FLUID_ID = 7480
    local CUSTOM_MANA_FLUID_SUBTYPE = 0
    local MANA_PERCENT = 60
    
    local function useCustomManaFluid()
        if getPlayerMppc() <= MANA_PERCENT then
            useItemWithSubtypeFromOpenContainerOnSelf(CUSTOM_MANA_FLUID_ID, CUSTOM_MANA_FLUID_SUBTYPE)
            sleep(2000)
        end
    end
    
    autoRun(500, useCustomManaFluid)

    Report (spy) players on screens with private message

    This script sends private message for every player that is on the screen. Useful for MC character that spies if someone is entering spawn

    Change PLAYER_TO_SEND_MSG

    local PLAYER_TO_SEND_MSG = "Papryka" -- edit this name to character which should receive msgs
    local EXHAUST = 4000 -- milliseconds delay for each reported player that comes on screen
    
    local EXHAUST_TABLE = {}
    
    local function shouldReportPlayer(playerName)
        return EXHAUST_TABLE[playerName] == nil or EXHAUST_TABLE[playerName] < nowMs()
    end
    
    local function reportPlayersOnPriv()
        local selfName = getSelfName()
        if selfName == nil then
            return
        end
        for index, player in ipairs(getScreenPlayers()) do
            local playerName = getCreatureName(player)
            if playerName ~= selfName then
                if shouldReportPlayer(playerName) then
                    talkPrivate(PLAYER_TO_SEND_MSG, playerName)
                    EXHAUST_TABLE[playerName] = nowMs() + EXHAUST
                end
            end
        end
    end
    
    
    autoRun(500, reportPlayersOnPriv)

    Organize loot from ground to backpack of backpacks

    Make backpacks of backpacks and run script to put items from ground to this backpack. This script will open next backpack if the current one is full

    Change LOOT_BACKPACK_ID and LOOT_BAG_CAPACITY

    local LOOT_BACKPACK_ID = 2853
    local LOOT_BAG_CAPACITY = 8
    local ITEMS_TO_PUSH = {
        3264, -- sword
        3286, -- mace
    }
    
    local function collectFromGround()
        for i, v in ipairs(ITEMS_TO_PUSH) do
            collectNearbyGroundItem(LOOT_BACKPACK_ID, v)
            sleep(300)
        end
    end
    
    local function openNextBackpack()
        for index, container in ipairs(getOpenContainers()) do
            if getId(getContainerItem(container)) == LOOT_BACKPACK_ID then
                local items = getItems(container)
                if #items >= LOOT_BAG_CAPACITY then
                    for index, item in ipairs(items) do
                        if getId(item) == LOOT_BACKPACK_ID then
                            open(item, container)
                            sleep(500)
                            return
                        end
                    end
                end
            end
        end
    end
    
    autoRun(500, openNextBackpack)
    autoRun(500, collectFromGround)

    Move lootbag under your character

    Change LOOT_BAG_ID to custom if needed

    local LOOT_BAG_ID = 2853
    
    local function getItemsAroundPlayer(x, y, z)
    	return {
    		getTopUseItem(x - 1, y - 1, z),
    		getTopUseItem(x, y - 1, z),
    		getTopUseItem(x + 1, y - 1, z),
    		getTopUseItem(x - 1, y, z),
    		getTopUseItem(x + 1, y, z),
    		getTopUseItem(x - 1, y + 1, z),
    		getTopUseItem(x, y + 1, z),
    		getTopUseItem(x + 1, y + 1, z),
    	}
    end
    
    local function f()
    	local pos = getSelfPosition()
    	for _, item in ipairs(getItemsAroundPlayer(pos.x, pos.y, pos.z)) do
    		if getId(item) == LOOT_BAG_ID then
    			moveItem(item, pos.x, pos.y, pos.z)
    			return
    		end
    	end
    end
    
    autoRun(100, f)

    Skin corpses (tibia 8.0 protocol compatible)

    local SKIN_CORPSE_IDS = { -- Add new ids that should be skinned
        4272,
        4057,
    }
    
    local SKIN_ITEM_ID = 5942
    
    local function skin()
        for _, id in ipairs(SKIN_CORPSE_IDS) do
            local used = useInventoryItemOnNearbyGroundItem(SKIN_ITEM_ID, id)
            if used then
                sleep(300)
            end
        end
    end
    
    autoRun(300, skin)

    Skin corpses (tibia 7.4 protocol compatible)

    local SKIN_CORPSE_IDS = { -- Add new ids that should be skinned
        4272,
        4057,
    }
    
    local SKIN_ITEM_ID = 5942
    
    local function skin()
        for _, id in ipairs(SKIN_CORPSE_IDS) do
            local used = useItemFromOpenContainerOnNearbyGroundItem(SKIN_ITEM_ID, id)
            if used then
                sleep(300)
            end
        end
    end
    
    autoRun(300, skin)

    Stack items

    stacks every 3 seconds

    autoRun(3000, stackItems)

    Trap assitant

    Moves nearby closed trap under player and opens them

    
    local CLOSED_TRAP_ID = 3481
    local DELAY = 500 --miliseconds
    
    local function f()
        local pos = getSelfPosition()
        for x = pos.x - 1, pos.x + 1 do
            for y = pos.y - 1, pos.y + 1 do
                local thing = getTopMoveThing(x, y, pos.z)
                if pos.x == x and pos.y == y then
                    if getId(thing) == CLOSED_TRAP_ID then
                        useItem(thing)
                        sleep(DELAY)
                        return
                    end
                else
                    if getId(thing) == CLOSED_TRAP_ID then
                        moveItem(thing, pos.x, pos.y, pos.z)
                        sleep(DELAY)
                        return
                    end
                end
            end
        end
    end
    
    autoRun(100, f)