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

OTClient Passing a teleport and removing an item. TFS 1.3?

Latorre01

New Member
Joined
Aug 14, 2019
Messages
22
Reaction score
2
This script is from the Pits of Inferno Quest. I want to remove the item as we pass the teleport so it can be used only one time. As we passa the teleport the item desapears. Thanks

local destinations = {
[2000] = Position(32791, 32331, 10),
[2001] = Position(32791, 32327, 10)
}

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

if player:getItemCount(1970) < 1 then
player:teleportTo(fromPosition)
return true
end

player:teleportTo(destinations[item.uid])
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
 
Solution
Just add item:remove() if you want to remove the teleport

otherwise add player:removeItem(itemid, 1)

Code:
local destinations = {
[2000] = Position(32791, 32331, 10),
[2001] = Position(32791, 32327, 10)
}

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

if player:getItemCount(1970) < 1 then
player:teleportTo(fromPosition)
return true
end

player:teleportTo(destinations[item.uid])
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
item:remove()
return true
end
Just add item:remove() if you want to remove the teleport

otherwise add player:removeItem(itemid, 1)

Code:
local destinations = {
[2000] = Position(32791, 32331, 10),
[2001] = Position(32791, 32327, 10)
}

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

if player:getItemCount(1970) < 1 then
player:teleportTo(fromPosition)
return true
end

player:teleportTo(destinations[item.uid])
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
item:remove()
return true
end
 
Solution
Just add item:remove() if you want to remove the teleport

otherwise add player:removeItem(itemid, 1)

Code:
local destinations = {
[2000] = Position(32791, 32331, 10),
[2001] = Position(32791, 32327, 10)
}

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

if player:getItemCount(1970) < 1 then
player:teleportTo(fromPosition)
return true
end

player:teleportTo(destinations[item.uid])
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
item:remove()
return true
end
Thank you
 
Back
Top