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

Lua tfs 1.2 cash teleport

tibia10gogo

New Member
Joined
Apr 14, 2016
Messages
8
Reaction score
2
Can someone update for me this script please? It works on 8.6, but now I need to update it to tfs 1.2.
It is cash teleport :)

Code:
local config = {
[7751] = { else_text = 'You need to have 15cc', item_ID = 2160, item_count = 15, pos = {x=30715, y=32296, z=7} },
}

function onStepIn(cid, item, position, fromPosition)
    local aid = Item(item.uid, "aid")
    if(config[aid].item_count <= getPlayerItemCount(cid, config[aid].item_ID)) then
        doTeleportThing(cid, config[aid].pos)
        doPlayerRemoveItem(cid, 2160, 15)

    else
        doPlayerSendCancel(cid, else_text)
        doTeleportThing(cid, getCreatureLastPosition(cid))
       

    end
    return true
end
 
Can someone update for me this script please? It works on 8.6, but now I need to update it to tfs 1.2.
It is cash teleport :)

Code:
local config = {
[7751] = { else_text = 'You need to have 15cc', item_ID = 2160, item_count = 15, pos = {x=30715, y=32296, z=7} },
}

function onStepIn(cid, item, position, fromPosition)
    local aid = Item(item.uid, "aid")
    if(config[aid].item_count <= getPlayerItemCount(cid, config[aid].item_ID)) then
        doTeleportThing(cid, config[aid].pos)
        doPlayerRemoveItem(cid, 2160, 15)

    else
        doPlayerSendCancel(cid, else_text)
        doTeleportThing(cid, getCreatureLastPosition(cid))
      

    end
    return true
end
You should post this on request not on support.
 
Code:
local config = {
    [7751] = {itemId = 2160, countId = 15, text = 'You must have 15 crystal coins to step on this tile.', newPosition = Position(30715,32296,7}
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end
  
    local tmpTeleport = config[item.actionid]
    if not tmpTeleport then
        return true
    end
  
    if not player:removeItem(tmpTeleport.itemId, tmpTeleport.countId) then
        player:say(tmpTeleport.text, TALKTYPE_MONSTER_SAY)
        player:teleportTo(fromPosition)
        return true
    end
  
    player:teleportTo(tmpTeleport.newPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
 
Code:
local config = {
    [7751] = {itemId = 2160, countId = 15, text = 'You must have 15 crystal coins to step on this tile.', newPosition = Position(30715,32296,7}
}

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

    local tmpTeleport = config[item.actionid]
    if not tmpTeleport then
        return true
    end

    if not player:removeItem(tmpTeleport.itemId, tmpTeleport.countId) then
        player:say(tmpTeleport.text, TALKTYPE_MONSTER_SAY)
        player:teleportTo(fromPosition)
        return true
    end

    player:teleportTo(tmpTeleport.newPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
I am a little shocked :p

But why create player twice?
Sure it could be a monster or npc which stepped on the tile, this why you can use isPlayer(), the parameter creature is just a place holder its similar with cid being a place holder.

Also there was a small error in the code
Code:
local config = {
    [7751] = {itemId = 2160, countId = 15,, newPosition = Position(30715,32296,7) }
}

function onStepIn(creature, item, position, fromPosition)
    local tmpTeleport = config[item.actionid]
    local position = nil
    if not creature:isPlayer() or not tmpTeleport then
        return true
    end
 
    if creature:getItemCount(tmpTeleport.itemId) >= tmpTeleport.countId then
        creature:removeItem(tmpTeleport.itemId, tmpTeleport.countId)
        position = tmpTeleport.newPosition
    else
        creature:say('You must have ' .. tmpTeleport.countId .. ' crystal coins to step on this tile.', TALKTYPE_MONSTER_SAY)
        position = fromPosition
    end
 
    creature:teleportTo(position)
    creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
 
Back
Top