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

Item needed to enter teleport (but don't take it out)

GuilleMoniz

New Member
Joined
Dec 5, 2016
Messages
23
Reaction score
3
Hello folks!

TSF 1.0
8.60

Im working in a custom quest, and Im doing one of my "good ideas" of new custom quest! But I need a script who ask you to have (backpack or set) an "X" item for example: Ferumbra's Hat to enter the teleport, but without taking it from you...

For example. If I have the ferumbra's hat on my bp, the teleport let me enter, but not taking it as payment. Just like a "pass ticket lol"...


Idk if it sounds weird, but i'll show after pictures of the quest so you guys could apreciatte my idea hahaha thanks in advance!
 
Solution
here example:
Lua:
local config = {
    needItem = { id = 2160, count = 1, remove = true },
    nextPos = { x = 1000, y = 1000, z = 1000 }
}

function onStepIn(player, item, position, fromPos)
if isPlayer(player) then
    local it = getPlayerItemCount(player, config.needItem.id)
    if it >= config.needItem.count then
        if config.needItem.remove then
            doPlayerRemoveItem(player, config.needItem.id, config.needItem.count)
        end
        doTeleportThing(player, config.nextPos, false)
        doSendMagicEffect(config.nextPos, CONST_ME_TELEPORT)
    else
        doTeleportThing(player, fromPos, true)
        doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
        doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, 'Sorry...
Try this:

Lua:
local passItem = 5903 -- your item id here
local passPos = Position(1000,1000,7) -- your new position here

function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        local player = Player(cid)
        local canPass = player:getItemById(passItem)
        if canPass then
            player:teleportTo(passPos)
            passPos:sendMagicEffect(CONST_ME_TELEPORT)
        else
            player:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don\'t have the required items.")
        end
    end
    return true
end
 
Try this:

Lua:
local passItem = 5903 -- your item id here
local passPos = Position(1000,1000,7) -- your new position here

function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        local player = Player(cid)
        local canPass = player:getItemById(passItem)
        if canPass then
            player:teleportTo(passPos)
            passPos:sendMagicEffect(CONST_ME_TELEPORT)
        else
            player:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don\'t have the required items.")
        end
    end
    return true
end


[15/08/2017 20:03:34] data/actions/scripts/feruhat.lua:2: attempt to call global 'Position' (a nil value)
[15/08/2017 20:03:34] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/feruhat.lua)

Any idea how to solve this? thanks !!
 
[15/08/2017 20:03:34] data/actions/scripts/feruhat.lua:2: attempt to call global 'Position' (a nil value)
[15/08/2017 20:03:34] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/feruhat.lua)

Any idea how to solve this? thanks !!

Lua:
local passItem = 5903 -- your item id here
local passPos = {x=1000,y=1000,z=7} -- your new position here
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        local player = Player(cid)
        local canPass = player:getItemById(passItem)
        if canPass then
            player:teleportTo(passPos)
            Position(passPos):sendMagicEffect(CONST_ME_TELEPORT)
        else
            player:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don\'t have the required items.")
        end
    end
    return true
end

But really static is right, updating to 1.2 will save you a lot of trouble.
 
Lua:
local passItem = 5903 -- your item id here
local passPos = {x=1000,y=1000,z=7} -- your new position here
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        local player = Player(cid)
        local canPass = player:getItemById(passItem)
        if canPass then
            player:teleportTo(passPos)
            Position(passPos):sendMagicEffect(CONST_ME_TELEPORT)
        else
            player:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don\'t have the required items.")
        end
    end
    return true
end

But really static is right, updating to 1.2 will save you a lot of trouble.
still won't work because the Position constructor doesn't exist in 1.0 apparently
have to use doSendMagicEffect(passPos, CONST_ME_TELEPORT)
 
There's a way I can update to 1.2 without loss my current job? Im pretty new in coding. I know a lot about tibia (the game) but i get kinda loss when creating scripts haha

Its a bit of a chore but download the newer version and don't just copy the files over to the new folder, you have to go through your files individually and update your new content there. Program like winmerge could be useful.
 
here example:
Lua:
local config = {
    needItem = { id = 2160, count = 1, remove = true },
    nextPos = { x = 1000, y = 1000, z = 1000 }
}

function onStepIn(player, item, position, fromPos)
if isPlayer(player) then
    local it = getPlayerItemCount(player, config.needItem.id)
    if it >= config.needItem.count then
        if config.needItem.remove then
            doPlayerRemoveItem(player, config.needItem.id, config.needItem.count)
        end
        doTeleportThing(player, config.nextPos, false)
        doSendMagicEffect(config.nextPos, CONST_ME_TELEPORT)
    else
        doTeleportThing(player, fromPos, true)
        doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
        doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, 'Sorry, you no have 1 crystal coin.')
    end
end
return true
end
 
Solution
here example:
Lua:
local config = {
    needItem = { id = 2160, count = 1, remove = true },
    nextPos = { x = 1000, y = 1000, z = 1000 }
}

function onStepIn(player, item, position, fromPos)
if isPlayer(player) then
    local it = getPlayerItemCount(player, config.needItem.id)
    if it >= config.needItem.count then
        if config.needItem.remove then
            doPlayerRemoveItem(player, config.needItem.id, config.needItem.count)
        end
        doTeleportThing(player, config.nextPos, false)
        doSendMagicEffect(config.nextPos, CONST_ME_TELEPORT)
    else
        doTeleportThing(player, fromPos, true)
        doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
        doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, 'Sorry, you no have 1 crystal coin.')
    end
end
return true
end


Thank you! it worked like a gem ^^
 
Back
Top