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

need some help with this script (teleport pad system)

ElefanteAfrican

Active Member
Joined
Jul 4, 2016
Messages
46
Reaction score
25
ef7bae2cf5ea3e9a24de46163730f550.png

Code:
function onStepIn(player, item
, fromPosition, target, toPosition, isHotkey)
local tile = Tile(target:getPosition())
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end
        end
    end
end
 
are you sure these are the right parameters for this function?

found this:
function onStepIn(cid, item, position, fromPosition)

what's your TFS version?
 
Its onStepIn function which means you cannot have target / isHotkey in there. Not sure what you are trying to do with the code
 
i made some mess there XD, this is the original script

errorscript.png
XML:
floo_powder = {
    tileID = 24618,
    unlockMsg = "You have unlocked ",
-- Window Configuration
    titleMsg = "Floo Powder Teleport System",
    mainMsg = "Select a location to be teleported too.\n\nYou are currently at:\n",
-- End Window Configuration

-- Teleport Spots
    teleport_spots = {
        [1] = {
            name = "Karmia", -- Name of the spot (What is shown in the window)
            storage = 10001, -- This storage tells the system what spots are unlocked
            uid = 2291, -- The unique ID of the teleport spot "This is more for your records really.. "
            direction = DIRECTION_SOUTH, -- This is the direction your player will face when he is teleported to another pad IT MUST BE CAPITALS!
            description = "Karmia Temple",
        },
     
        [2] = {
            name = "Harry Potter",
            storage = 10023,
            uid = 2311,
            direction = DIRECTION_SOUTH,
            description = "Shops!",
        },
    },
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(target:getPosition())
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end
        end
    end
end

MOVEMENTS
XML:
function onStepIn(player, item, position, fromPosition)

local index = nil
for i = 1, #floo_powder.teleport_spots do
    if floo_powder.teleport_spots[i].uid == item.uid then
        index = i
        break
    end
end

    if index == nil then
        print("Error::Cannot find the tile Unique ID in your config table.")
        return true
    end
    
    if player:getStorageValue(floo_powder.teleport_spots[index].storage) < 1 then
        player:setStorageValue(floo_powder.teleport_spots[index].storage, 1)
        player:say(floo_powder.unlockMsg..floo_powder.teleport_spots[index].name.."!", TALKTYPE_MONSTER_SAY)
    end
end
 
Last edited:
try this

actions:

Lua:
floo_powder = {
    tileID = 24618,
    unlockMsg = "You have unlocked ",
    titleMsg = "Floo Powder Teleport System", -- Window Configuration Title
    mainMsg = "Select a location to be teleported too.\n\nYou are currently at:\n",  -- Window Configuration Message

    teleport_spots = {
        [1] = {
            name = "Karmia", -- Name of the spot (What is shown in the window)
            storage = 10001, -- This storage tells the system what spots are unlocked
            uid = 2291, -- The unique ID of the teleport spot "This is more for your records really.. "
            direction = DIRECTION_SOUTH, -- This is the direction your player will face when he is teleported to another pad IT MUST BE CAPITALS!
            description = "Karmia Temple",
        },
        [2] = {
            name = "Harry Potter",
            storage = 10023,
            uid = 2311,
            direction = DIRECTION_SOUTH,
            description = "Shops!",
        },
    },
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local items = Tile(player:getPosition()):getItems()
if items then
    for i = 1, #items do
        if items[i]:getId() == floo_powder.tileID then
            player:sendFlooPowderWindow(items[i]:getUniqueId(), target)
            return true
        end
    end
end

return true
end

Movements:

Lua:
function onStepIn(player, item, position, fromPosition)
local index = nil
for i = 1, #floo_powder.teleport_spots do
    if floo_powder.teleport_spots[i].uid == item.uid then
        index = i
        break
    end
end

if index == nil then
    print("Error::Cannot find the tile Unique ID in your config table.")
    return true
end

if player:getStorageValue(floo_powder.teleport_spots[index].storage) < 1 then
    player:setStorageValue(floo_powder.teleport_spots[index].storage, 1)
    player:say(floo_powder.unlockMsg..floo_powder.teleport_spots[index].name.."!", TALKTYPE_MONSTER_SAY)
end

return true
end
 
Back
Top