• 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!

Teleport if have item

_M4G0_

Intermediate OT User
Joined
Feb 6, 2016
Messages
550
Solutions
17
Reaction score
108
If the player has the item in the backpack teleport to pos
tfs 1.2
LUA:
local config = {
    [64000] = {doll = 11211, pos = Position(32039, 31783, 10)},
    [64001] = {doll = 13949, pos = Position(32123, 31831, 9)},
    [64002] = {doll = 13570, pos = Position(32082, 31842, 10)},
    [64003] = {doll = 11754, pos = Position(32116, 31862, 9)},
    [64004] = {doll = 16106, pos = Position(32058, 31799, 10)},
    [64005] = {doll = 21471, pos = Position(6242, 6919, 7)},
    [64006] = {doll = 11144, pos = Position(32157, 31838, 10)},
    [64007] = {doll = 13581, pos = Position(6266, 6896, 8)},
    [64008] = {doll = 21472, pos = Position(5844, 6743, 8)},
    [64009] = {doll = 20625, pos = Position(32118, 31883, 10)},
    [64010] = {doll = 18527, pos = Position(32133, 32186, 11)},
    [64011] = {doll = 16104, pos = Position(31986, 31846, 9)},
    [64012] = {doll = 12668, pos = Position(31994, 31842, 10)},
    [64013] = {doll = 9003, pos = Position(32032, 31862, 9)}
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local targetPosition = config[item.uid]
    if not targetPosition then
        return true
    end
    if player:getItemById(targetPosition.doll) > 0 then
    player:teleportTo(targetPosition.pos)
    position:sendMagicEffect(CONST_ME_TELEPORT)
    targetPosition:sendMagicEffect(CONST_ME_TELEPORT)
    else
    player:teleportTo(Position(32133, 32183, 11))
end
    return true
end
 
Solution
it should work just fine for you
except you're comparing it with a number, > 0
just do if player:getItemById(targetPosition.doll) then
it should work just fine for you
except you're comparing it with a number, > 0
just do if player:getItemById(targetPosition.doll) then
 
Solution
Back
Top