• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Tfs 1.2 Versperoth (add unique id to tp)

undead mage

Active Member
Joined
Mar 25, 2012
Messages
364
Solutions
2
Reaction score
47
Location
Amsterdam
Hi I was wondering if someone could help me to add a unique id to the teleport that spawns when versperoth gets killed and you walk on the hole.

Code:
-- add unique id when dead

local teleportPosition = Position(337, 514, 10)

local function transformTeleport()
    local teleportItem = Tile(teleportPosition):getItemById(1387)
    if not teleportItem then
        return
    end

    teleportItem:transform(18463)
end

local function clearArena()
    local spectators = Game.getSpectators(Position(350, 547, 10), false, false, 12, 12, 12, 12)
    local exitPosition = Position(249, 548, 10)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
            spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You were teleported out by the gnomish emergency device.')
        else
            spectator:remove()
        end
    end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() ~= 'versperoth' then
        return true
    end

    Game.setStorageValue(GlobalStorage.Versperoth.Battle, 2)
    addEvent(Game.setStorageValue, 30 * 60 * 1000, GlobalStorage.Versperoth.Battle, 0)

    local holeItem = Tile(teleportPosition):getItemById(18462)
    if holeItem then
        holeItem:transform(1387)
    end
    Game.createMonster('abyssador', Position(348, 543, 10))

    addEvent(transformTeleport, 30 * 60 * 1000)
    addEvent(clearArena, 32 * 60 * 1000)
    return true
end
 
change:
Code:
    if holeItem then
        holeItem:transform(1387)
    end

to
Code:
    if holeItem then
        holeItem:transform(1387)
        holeItem:setActionId(12345)
        -- depreciated -- holeItem:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 12345)
    end
 
Last edited:
change:
Code:
    if holeItem then
        holeItem:transform(1387)
    end

to
Code:
    if holeItem then
        holeItem:transform(1387)
        holeItem:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 12345)
    end
Thanks!

If I remember correctly uids can't be changed/assigned in 1.2, you should use aid instead.
So if unique doesn't work should it be (ITEM_ATTRIBUTE_ACTIONID, XXXX) ?
 
Will it also work with
holeItem:setUniqueId(12345) ?
no
function doesn't even exist (or at least shouldn't)
you shouldn't set unique ids ingame because it's considered unsafe
this is why it's forbidden in setAttribute function when you try to use uniqueid as the attribute key
 
Back
Top