• 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 script Tp for level

Madusa

Active Member
Joined
Sep 8, 2022
Messages
138
Reaction score
43
Location
Egypt
I created a hunting town and I want each magic forcefield to have a certain level of about 15 hunting spots and I want this to be from level 1500+ 1600 1700 1800 1900 And so I want it to be in one text after putting x y z and a unique identifier for each of them
Can someone professional help me in lua tfs 1.2 8.0
Thanks in advance to everyone, I wish you and me good luck
 
Solution
It does not work and there are no errors
When I stand on teleportation, nothing happens
I did everything you said 100% right.
I've seen I have an old text like that you can edit better
Or fix the problem of text that does not work
Thank you for everything

Lua:
function onStepIn(cid, item, pos)
Tembel = {x=398,y=1008,z=7}
target = {x=454,y=397,z=7}
reqlevel = 700
level = getPlayerLevel(cid)

if level < reqlevel then
doTeleportThing(cid, Tembel)
doSendMagicEffect(Tembel, 10)
doPlayerSendTextMessage(cid, 25, "Sorry You Must Be Level 700 Or Higher To Enter This Place")
else
doTeleportThing(cid, target)
doSendMagicEffect(target, 10)
doPlayerSay(cid, "Welcome On Hunting {2} 700 Place", TALKTYPE_ORANGE_1)
end
end
change
Lua:
function...
It's likely that nobody fully understands your request.
I certainly don't.

Explain it better, please.
 
Explain it better, please.
When you have a hunting place that is closed by a door of level 2000, you can not go to it until you are level 2000 I want a text like that but for Tp
I do not want to use the doors, I want access to any tp at a certain level and that there is a message that prevents you from entering if you are at a lower level
Is everything clear now?
It's likely that nobody fully understands your request.
Thanks for explaining it to me
 
When you have a hunting place that is closed by a door of level 2000, you can not go to it until you are level 2000 I want a text like that but for Tp
I do not want to use the doors, I want access to any tp at a certain level and that there is a message that prevents you from entering if you are at a lower level
Is everything clear now?

Thanks for explaining it to me
Place the actionId on the tile underneath the teleporter.
When placing the teleport on the tile, ensure it doesn't have a destination set.

Place into data/scripts
Lua:
local config = {
--[actionId]
    [45001] = {destination = Position(1000, 1000, 7), levelRequirement = 2000},
    [45002] = {destination = Position(1000, 1000, 7), levelRequirement = 1500},
    [45003] = {destination = Position(1000, 1000, 7), levelRequirement = 8000}
}

local teleportTiles = MoveEvent()
teleportTiles:type("stepin")

function teleportTiles.onStepIn(creature, item, position, fromPosition)
    player = Player(player)
    if not player then
        return true
    end
   
    local index = config[item:getActionId()]
    local teleportDestination = index.destination
   
    if player:getLevel() < index.levelRequirement then
        player:say("Requires level " .. index.levelRequirement, TALKTYPE_MONSTER_SAY)
        teleportDestination = fromPosition
    end
   
    player:teleportTo(teleportDestination)
    return true
end

for actionId, _ in pairs(config)
    teleportTiles:aid(actionId)
end
teleportTiles:register()
 
Last edited:
Place the actionId on the tile underneath the teleporter.
When placing the teleport on the tile, ensure it doesn't have a destination set.

Place into data/scripts
Lua:
local config = {
--[actionId]
    [45001] = {destination = Position(1000, 1000, 7), levelRequirement = 2000},
    [45002] = {destination = Position(1000, 1000, 7), levelRequirement = 1500},
    [45003] = {destination = Position(1000, 1000, 7), levelRequirement = 8000}
}

local teleportTiles = MoveEvent()
teleportTiles:type("stepin")

function yellowPillow.onStepIn(creature, item, position, fromPosition)
    player = Player(player)
    if not player then
        return true
    end
  
    local index = config[item:getActionId()]
    local teleportDestination = index.destination
  
    if player:getLevel() < index.levelRequirement then
        player:say("Requires level " .. index.levelRequirement, TALKTYPE_MONSTER_SAY)
        teleportDestination = fromPosition
    end
  
    player:teleportTo(teleportDestination)
    return true
end

for actionId, _ in pairs(config)
    teleportTiles:aid(actionId)
end
teleportTiles:register()
I knew it wouldn't work because such texts are for a source 1.3 iam use 1.2
 
I knew it wouldn't work because such texts are for a source 1.3 iam use 1.2
Sorry.

Single actionid for all tiles.
Little bit more manual setup for the positions.
Lua:
--[[

    <movevent event="StepIn" actionid="45001" script="teleportTiles.lua" />

]]--


local config = {
    {tilePosition = Position(1000, 1000, 7), destination = Position(1000, 1000, 7), levelRequirement = 2000},
    {tilePosition = Position(1000, 1000, 7), destination = Position(1000, 1000, 7), levelRequirement = 1500},
    {tilePosition = Position(1000, 1000, 7), destination = Position(1000, 1000, 7), levelRequirement = 8000}
}

function onStepIn(creature, item, position, fromPosition)
    player = Player(player)
    if not player then
        return true
    end
  
    local index = 0
    for i == 1, #config do
        if position == config[i].tilePosition then
            index = i
            break
        end
    end
  
    if index == 0 then
        player:teleportTo(fromPosition)
        print("Error in teleportTiles. Position not found in table. Position(" .. position.x .. ", " .. position.y .. ", " .. position.z .. ")")
        return true
    end
  
    index = config[index]
    local teleportDestination = index.destination
  
    if player:getLevel() < index.levelRequirement then
        player:say("Requires level " .. index.levelRequirement, TALKTYPE_MONSTER_SAY)
        teleportDestination = fromPosition
    end
  
    player:teleportTo(teleportDestination)
    return true
end
 
[Warning - Event::checkScript] Can not load script: scripts/teleportTiles.lua
data/movements/scripts/teleportTiles.lua:14: '=' or 'in' expected near '=='
You don't have to be sorry, I'm so sorry for wasting your time helping me
 
[Warning - Event::checkScript] Can not load script: scripts/teleportTiles.lua
data/movements/scripts/teleportTiles.lua:14: '=' or 'in' expected near '=='

You don't have to be sorry, I'm so sorry for wasting your time helping me
line 21
change
Lua:
for i == 1, #config do
to
Lua:
for i = 1, #config do
 
line 21
change
Lua:
for i == 1, #config do
to
Lua:
for i = 1, #config do
It does not work and there are no errors
When I stand on teleportation, nothing happens
I did everything you said 100% right.
I've seen I have an old text like that you can edit better
Or fix the problem of text that does not work
Thank you for everything

Lua:
function onStepIn(cid, item, pos)
Tembel = {x=398,y=1008,z=7}
target = {x=454,y=397,z=7}
reqlevel = 700
level = getPlayerLevel(cid)

if level < reqlevel then
doTeleportThing(cid, Tembel)
doSendMagicEffect(Tembel, 10)
doPlayerSendTextMessage(cid, 25, "Sorry You Must Be Level 700 Or Higher To Enter This Place")
else
doTeleportThing(cid, target)
doSendMagicEffect(target, 10)
doPlayerSay(cid, "Welcome On Hunting {2} 700 Place", TALKTYPE_ORANGE_1)
end
end
 
It does not work and there are no errors
When I stand on teleportation, nothing happens
I did everything you said 100% right.
I've seen I have an old text like that you can edit better
Or fix the problem of text that does not work
Thank you for everything

Lua:
function onStepIn(cid, item, pos)
Tembel = {x=398,y=1008,z=7}
target = {x=454,y=397,z=7}
reqlevel = 700
level = getPlayerLevel(cid)

if level < reqlevel then
doTeleportThing(cid, Tembel)
doSendMagicEffect(Tembel, 10)
doPlayerSendTextMessage(cid, 25, "Sorry You Must Be Level 700 Or Higher To Enter This Place")
else
doTeleportThing(cid, target)
doSendMagicEffect(target, 10)
doPlayerSay(cid, "Welcome On Hunting {2} 700 Place", TALKTYPE_ORANGE_1)
end
end
change
Lua:
function onStepIn(creature, item, position, fromPosition)
to
Lua:
function onStepIn(player, item, position, fromPosition)
 
Solution
Back
Top