• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Teleporter

Jayle

New Member
Joined
Dec 2, 2012
Messages
1
Reaction score
0
Hi all, I'm new to .lua scripting and would like to know how to do something like this:

Create a script that allows a person to go through a portal and pick their vocation. I also need a script that allows a user to "use" it and become a specific vocation.


Any help would be great! My server stats: The Forgotten Server - Version 0.2.14




EDIT: I fixed a few things but it makes a clone of the person in the spot it teleports them to.
What causes this?

Current script:
function onStepIn(cid, item, position, fromPosition)
local toPos = {x = 1045, y = 1032, z = 7}

if getPlayerVocation(cid) > 0 then
doPlayerSetVocation(cid, 4)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You are now a knight!")
doTeleportThing(cid, toPos)

{x = 1045, y = 1034, z = 7}
else
doPlayerSendCancel(cid, 'Sorry, you are currently not able to access this area.')
end
return true
end
 
Last edited:
Does this work?

Looking for a simple:

Player enter teleport
If lvl 8<9> then teleport
(Player gets teleported to a room with 1 tp for each vocation)
Player enter teleport
Set vocation


@Xikini
 
Does this work?

Looking for a simple:

Player enter teleport
If lvl 8<9> then teleport
(Player gets teleported to a room with 1 tp for each vocation)
Player enter teleport
Set vocation


@Xikini
put ActionId onto the tile underneath the teleporter.
Teleporter must be 'blank'. No position / co-ordinates set.
scripts go into data/scripts as a .lua file.
LUA:
local teleportLocation = Position(1000, 1000, 7)
local actionId = 11111
local minimumLevel = 8

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

function moveEvent.onStepIn(player, item, position, fromPosition)
    if not player or player:getLevel() < minimumLevel then
        player:teleportTo(fromPosition)
        return true
    end
    player:teleportTo(teleportLocation)
    return true
end

moveEvent:aid(actionId)
moveEvent:register()
LUA:
local config = {
  --[actionId]
    [11111] = {newVocation = 1, teleportLocation = Position(1000, 1000, 7)},
    [22222] = {newVocation = 2, teleportLocation = Position(1000, 1000, 7)},
    [33333] = {newVocation = 3, teleportLocation = Position(1000, 1000, 7)},
    [44444] = {newVocation = 4, teleportLocation = Position(1000, 1000, 7)}
}
local minimumLevel = 8

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

function moveEvent.onStepIn(player, item, position, fromPosition)
    if not player or player:getLevel() < minimumLevel then
        player:teleportTo(fromPosition)
        return true
    end
    local index = config[item:getActionId()]
    player:setVocation(Vocation(index.newVocation))
    player:teleportTo(index.teleportLocation)
    return true
end

for v, k in pairs(config) do
    moveEvent:aid(v)
end

moveEvent:register()
 
Back
Top