• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction teleport to UID in map, TFS 1.1

Marcus

User.postCount++;
Joined
Nov 14, 2015
Messages
1,074
Solutions
10
Reaction score
393
Location
Sweden
If you have an unique id in the map that you can't really locate, or you need to find it fast, you can use this talkaction to teleport your gm directly to where it is.

/uid 4444
will bring you to whatever item has unique id 4444

talkactions.xml
PHP:
<talkaction words="/uid" separator=" " script="go_to_uid.lua" />

go_to_uid.lua
PHP:
function onSay(player, words, param)
    if player:getGroup():getId() < 3 then
        return true
    end
    item = Item(math.floor(param))
    if item then
        pos = item:getPosition()
        if pos then
            pos.x = pos.x+1
            player:teleportTo(pos)
        else
            player:sendTextMessage(18, "position not found")
        end
    else
        player:sendTextMessage(18, "Item not found")
    end
    return true
end
 
If you are going to teleport to an unknown location you should check for the closest free tile of that position. So you can use getClosestFreePosition to check so you don't get stuck in a wall.
https://github.com/otland/forgotten...6ada65d9cd472a2/data/lib/core/creature.lua#L1

So your script could look like this.
Code:
function onSay(player, words, param)
    if player:getGroup():getId() < 3 then
        return false
    end
    item = Item(param)
    if item then
        local pos = Creature:getClosestFreePosition(item:getPosition())
        if pos.x == 0 then
            player:sendTextMessage(18, "position not found.")
        else
            return player:teleportTo(pos)
        end
    else
        player:sendTextMessage(18, "Item not found")
    end
    return false
end
 
if you have enough access to use that command odds are you can also use something like /a, so you would never get stuck anyway, and you know exactly which tile has uid instead of looking at all 9 next to you
 
If you are going to teleport to an unknown location you should check for the closest free tile of that position. So you can use getClosestFreePosition to check so you don't get stuck in a wall.
https://github.com/otland/forgotten...6ada65d9cd472a2/data/lib/core/creature.lua#L1

So your script could look like this.
Code:
function onSay(player, words, param)
    if player:getGroup():getId() < 3 then
        return false
    end
    item = Item(param)
    if item then
        local pos = Creature:getClosestFreePosition(item:getPosition())
        if pos.x == 0 then
            player:sendTextMessage(18, "position not found.")
        else
            return player:teleportTo(pos)
        end
    else
        player:sendTextMessage(18, "Item not found")
    end
    return false
end

Your admin can always teleport to a tile even if it's only a backpack in empty space.
And once you want to find an UID, you don't want any script telling you "floor not found", you want to get there no matter what to find out where it was and maybe what it is.
 
From my personal experience.
Do not set or use uniuqeID's for anything other than comparing if 2 item userdatas are the same.
 
From my personal experience.
Do not set or use uniuqeID's for anything other than comparing if 2 item userdatas are the same.
You should never use same UID twice, NEVER.. it's "Unique ID" and it could fuck some things up real bad if you use twice :)
 
Back
Top