• 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 advanced teleporter

Rudixx

New Member
Joined
Aug 3, 2007
Messages
246
Reaction score
0
Location
England
Currently I am working on real tibia enchant system. Player enter for example Ice gate and he is teleported to place where he can change the gems, but he point is when he is going back he should be teleported to same city from which he came. So for example, if player go to svargrond and enter ice gate, he will appear on okolnir enchanted isle and when enter mystic flame he is supposed to be in svargrond again and when player enter ice gate in venore and then enter same mystic flame he is supposed to be again in venore. I have no idea how to write it. Maybe something with TownID, if player enter gate with townid = 1 then he back to this town, I dunno. Anyone have idea how to make that script?
 
Just use a simple script such as this one?

PHP:
function onStepIn(cid, item, position, fromPosition)

    local newPos = {x = 100, y = 100, z = 7} 
	
	           doTeleportThing(cid, newPos)
			    doSendMagicEffect(newPos,10)
				
  end

Use uniqueIDs for the flames.
Change the newPos to the location you them to go to when entering the blue flame..
 
You don't understand what I said. There is about 11 cities, all these cities are teleporting you to same place for example if you enter ice gate on each city it will take you to the same place, for example okolnir. Then on okolnir you have mystic flame which will take you back to the city from which you came.
 
Code:
function onUse(cid, item, fromPosition, toPosition)
local temple = getTownTemplePosition(getPlayerTown(cid))
	if item.itemid == 1945 then
		doTeleportThing(cid,temple,TRUE)
		doTransformItem(item.uid, item.itemid + 1)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Gracias por preferir Trekes.")
	else
		doTransformItem(item.uid, item.itemid - 1)
	end
end
Change onUse to onStepIn :)
 
It will check from witch City player came by his TownID so if I am citizen of Ab'dendriel and I enter TP from Svargrond it will tp me back to ab'dendriel.
 
if i understand you...this should help you as example.

PHP:
local Stor = 4545

local BackACT = 1313 --mystic flames action id

local From = 
    {
        [1] = {x=777, y=777, z=7},    --to Venore flame
        [2] = {x=666, y=666, z=6},    --to Svargrond flame
        [3] = {x=555, y=555, z=5}     --to Any place flame
    }
    
--Put Unique ids to the gates.
local To = 
    {
        [2121] = {{x=444, y=444, z=4}, 1}, --Flame from venore
        [2122] = {{x=333, y=333, z=3}, 2}, --Flame from svargoond
        [2123] = {{x=222, y=222, z=2}, 3}  --Flame from any place
    }
    
function onStepIn(cid, item, position, fromPosition)
    if To[item.uid] then
        doTeleportThing(cid, To[item.uid][1], FALSE)
        setPlayerStorageValue(cid, Stor, To[item.uid][2])
    elseif item.actionid == BackACT then
        if From[getPlayerStorageValue(cid, Stor)] then
            doTeleportThing(cid, From[getPlayerStorageValue(cid, Stor)], FALSE)
        else
            --if the player does not have a storage he will be teleported here
            doTeleportThing(cid, {x=1000, y=1000, z=7}, FALSE)
        end
    end
    return TRUE
end
 
here :

local To =
{
[
2121] = {{x=444, y=444, z=4}, 1}, --Flame from venore
[2122] = {{x=333, y=333, z=3}, 2}, --Flame from svargoond
[2123] = {{x=222, y=222, z=2}, 3} --Flame from any place
}


example the gate from venore have the unique id 2121 and it gives the storage value 1

and here

local From
=
{
[
1] = {x=777, y=777, z=7}, --to Venore flame
[2] = {x=666, y=666, z=6}, --to Svargrond flame
[3] = {x=555, y=555, z=5} --to Any place flame
}


you should put the storage value .
1 = venore and the pos where you will go back.
 
Damn it's almost good but... I will explain more.

There are four gates and about 11 cities like on real tibia:

Svargrond gates:
Code:
<movevent event="StepIn" uniqueid="50018" script="svargrond/earth.lua" />
<movevent event="StepIn" uniqueid="50019" script="svargrond/ice.lua" />
<movevent event="StepIn" uniqueid="50020" script="svargrond/energy.lua" />
<movevent event="StepIn" uniqueid="50021" script="svargrond/fire.lua" />

Venore gates:
Code:
<movevent event="StepIn" uniqueid="50118" script="svargrond/earth.lua" />
<movevent event="StepIn" uniqueid="50119" script="svargrond/ice.lua" />
<movevent event="StepIn" uniqueid="50120" script="svargrond/energy.lua" />
<movevent event="StepIn" uniqueid="50121" script="svargrond/fire.lua" />

Carlin gates etc:
Code:
<movevent event="StepIn" uniqueid="50218" script="svargrond/earth.lua" />
<movevent event="StepIn" uniqueid="50219" script="svargrond/ice.lua" />
<movevent event="StepIn" uniqueid="50220" script="svargrond/energy.lua" />
<movevent event="StepIn" uniqueid="50221" script="svargrond/fire.lua" />

If you enter earth gate it will teleport you randomly to two locations: tiquanda or venore swamps:
Code:
<movevent event="StepIn" actionid="50022" script="svargrond/earth.lua" />

If you enter ice gate it will teleport you randomly to two locations: okolnir or folda:
Code:
<movevent event="StepIn" actionid="50023" script="svargrond/ice.lua" />

If you enter energy gate it will teleport you randomly to two locations: ankrahmun or darashia:
Code:
<movevent event="StepIn" actionid="50024" script="svargrond/energy.lua" />

If you enter fire gate it will teleport you randomly to two locations: thais or poh:
Code:
<movevent event="StepIn" actionid="50025" script="svargrond/fire.lua" />

So if you enter for example ice gate it will take you to okolnir or folda then if you enter flame on okolnir or folda it will take you back to the city from which you entered gate.

Can you change the script a little bit for me please?
 
PHP:
local Stor = 4545

local ActionsIds = {50022, 50023, 50024, 50025}

local Back = 
    {
        [1] = {x=777, y=777, z=7},    --SVARGROND back position.
        [2] = {x=666, y=666, z=6},    --VENORE back position
        [3] = {x=555, y=555, z=5}     --CARLIN back position.
    }

--Put Unique ids to the gates.
local From = 
    {
        --From Svargrond.
        [50018] = {"Earth", 1}, 
        [50019] = {"Ice", 1}, 
        [50020] = {"Energy", 1}, 
        [50021] = {"Fire", 1},
        --From Venore.
        [50118] = {"Earth", 2},
        [50119] = {"Ice", 2}, 
        [50120] = {"Energy", 2}, 
        [50121] = {"Fire", 2},
        --From Carlin
        [50218] = {"Earth", 3},
        [50219] = {"Ice", 3}, 
        [50220] = {"Energy", 3}, 
        [50221] = {"Fire", 3}        
    }
    
--Here the random 2 positions ~
local Locations = 
    {
        ["Earth"] = 
            {
                {x=444, y=444, z=4},
                {x=445, y=445, z=5}
            },
        ["Ice"] = 
            {
                {x=454, y=454, z=4},
                {x=455, y=455, z=5}
            },
        ["Energy"] = 
            {
                {x=554, y=554, z=4},
                {x=555, y=555, z=5}
            },
        ["Fire"] = 
            {
                {x=654, y=654, z=4},
                {x=655, y=655, z=5}
            }
    }
    
function onStepIn(cid, item, position, fromPosition)
    local Gate = From[item.uid]
    if Gate then
        doTeleportThing(cid, Locations[Gate[1]][math.random(1, 2)], FALSE)
        setPlayerStorageValue(cid, Stor, Gate[2])
    elseif isInArray(ActionsIds, item.actionid) == TRUE then
        if Back[getPlayerStorageValue(cid, Stor)] then
            doTeleportThing(cid, Back[getPlayerStorageValue(cid, Stor)], FALSE)
        else
            --if the player does not have a storage he will be teleported here
            doTeleportThing(cid, {x=1000, y=1000, z=7}, FALSE)
        end
    end
    return TRUE
end
 
Sorry for bother Nahruto but if you could add one more thing I would really appreciate it:

  • levplayer = getPlayerLevel(cid)
  • prof = getPlayerVocation(cid)
  • if isPlayer(cid) == TRUE then
  • if isPremium(cid) == TRUE then
  • if levplayer >= 30 then
  • if prof == 0 or prof == 2 or prof == 6 or prof == 10 then
  • doSendMagicEffect(pos, CONST_ME_TELEPORT)

For Earth and Ice gate first, for Energy and Fire second:

  1. else
    doCreatureSay(cid, "Only Premium Druids of level 30 or higher are able to enter this portal.", TALKTYPE_ORANGE_1)
  2. else
    doCreatureSay(cid, "Only Premium Sorcerers of level 30 or higher are able to enter this portal.", TALKTYPE_ORANGE_1)

Thanks!
 
PHP:
local Stor = 4545

local ActionsIds = {50022, 50023, 50024, 50025}

local Back = 
    {
        [1] = {x=777, y=777, z=7},    --SVARGROND back position.
        [2] = {x=666, y=666, z=6},    --VENORE back position
        [3] = {x=555, y=555, z=5}     --CARLIN back position.
    }

--Put Unique ids to the gates.
local From = 
    {
        --From Svargrond.
        [50018] = {"Earth", 1, {2, 6}}, 
        [50019] = {"Ice", 1, {2, 6}}, 
        [50020] = {"Energy", 1, {1, 5}}, 
        [50021] = {"Fire", 1, {1, 5}},
        --From Venore.
        [50118] = {"Earth", 2, {2, 6}},
        [50119] = {"Ice", 2, {2, 6}}, 
        [50120] = {"Energy", 2, {1, 5}}, 
        [50121] = {"Fire", 2, {1, 5}},
        --From Carlin
        [50218] = {"Earth", 3, {2, 6}},
        [50219] = {"Ice", 3, {2, 6}}, 
        [50220] = {"Energy", 3, {1, 5}}, 
        [50221] = {"Fire", 3, {1, 5}}        
    }

--Here the random 2 positions ~
local Locations = 
    {
        ["Earth"] = 
            {
                {x=444, y=444, z=4},
                {x=445, y=445, z=5}
            },
        ["Ice"] = 
            {
                {x=454, y=454, z=4},
                {x=455, y=455, z=5}
            },
        ["Energy"] = 
            {
                {x=554, y=554, z=4},
                {x=555, y=555, z=5}
            },
        ["Fire"] = 
            {
                {x=654, y=654, z=4},
                {x=655, y=655, z=5}
            }
    }

function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) == TRUE then
        if isPremium(cid) == TRUE then
            if getPlayerLevel(cid) >= 30 then
                local Gate = From[item.uid]
                if Gate then
                    if isInArray(Gate[3], getPlayerVocation(cid)) == TRUE or getPlayerAccess(cid) >= 3 then
                        local nPos = Locations[Gate[1]][math.random(1, 2)]
                        doTeleportThing(cid, nPos, FALSE)
                        doSendMagicEffect(nPos, CONST_ME_TELEPORT)
                        setPlayerStorageValue(cid, Stor, Gate[2])
                    else
                        if Gate[3][1] == 2 then    VocName = "Druids" else VocName = "Sorcerers" end
                        doCreatureSay(cid, "Only Premium ".. VocName .." of level 30 or higher are able to enter this portal.", TALKTYPE_ORANGE_1)
                    end
                elseif isInArray(ActionsIds, item.actionid) == TRUE then
                    if Back[getPlayerStorageValue(cid, Stor)] then
                        local backPos = Back[getPlayerStorageValue(cid, Stor)]
                        doTeleportThing(cid, backPos, FALSE)
                        doSendMagicEffect(backPos, CONST_ME_TELEPORT)
                    else
                        --if the player does not have a storage he will be teleported here
                        doTeleportThing(cid, {x=1000, y=1000, z=7}, FALSE)
                        doSendMagicEffect({x=1000, y=1000, z=7}, CONST_ME_TELEPORT)
                    end
                end
            else
                doPlayerSendCancel(cid,"NO LEVEL CANCEL MESSAGE.")
            end
        else
            doPlayerSendCancel(cid,"NO PREMIUM CANCEL MESSAGE.")
        end
    end
    return TRUE
end
 
Thing you did above with messages is not working it's return:
Code:
attempt to index field '?' (a nil value)
stack traceback

This message will appear if player is on free account or player have lower level than 30 or player is not druid:

Code:
doCreatureSay(cid, "Only Premium Druids of level 30 or higher are able to enter this portal.", TALKTYPE_ORANGE_1)

This message will appear if player is on free account or player have lower level than 30 or player is not sorcerer:

Code:
doCreatureSay(cid, "Only Premium Sorcerers of level 30 or higher are able to enter this portal.", TALKTYPE_ORANGE_1)
 
this should work and the old one too lol

PHP:
local Stor = 4545

local ActionsIds = {50022, 50023, 50024, 50025}

local Back = 
    {
        [1] = {x=777, y=777, z=7},    --SVARGROND back position.
        [2] = {x=666, y=666, z=6},    --VENORE back position
        [3] = {x=555, y=555, z=5}     --CARLIN back position.
    }

--Put Unique ids to the gates.
local From = 
    {
        --From Svargrond.
        [50018] = {"Earth", 1, {2, 6}}, 
        [50019] = {"Ice", 1, {2, 6}}, 
        [50020] = {"Energy", 1, {1, 5}}, 
        [50021] = {"Fire", 1, {1, 5}},
        --From Venore.
        [50118] = {"Earth", 2, {2, 6}},
        [50119] = {"Ice", 2, {2, 6}}, 
        [50120] = {"Energy", 2, {1, 5}}, 
        [50121] = {"Fire", 2, {1, 5}},
        --From Carlin
        [50218] = {"Earth", 3, {2, 6}},
        [50219] = {"Ice", 3, {2, 6}}, 
        [50220] = {"Energy", 3, {1, 5}}, 
        [50221] = {"Fire", 3, {1, 5}}        
    }

--Here the random 2 positions ~
local Locations = 
    {
        ["Earth"] = 
            {
                {x=1013, y=897, z=6},
                {x=1013, y=898, z=6}
            },
        ["Ice"] = 
            {
                {x=454, y=454, z=4},
                {x=455, y=455, z=5}
            },
        ["Energy"] = 
            {
                {x=1013, y=897, z=6},
                {x=1013, y=898, z=6}
            },
        ["Fire"] = 
            {
                {x=654, y=654, z=4},
                {x=655, y=655, z=5}
            }
    }
    
local function MoveBack(cid, fromPosition, n)
    if n == 2 then VocName = "Druids" else VocName = "Sorcerers" end
    doCreatureSay(cid, "Only Premium ".. VocName .." of level 30 or higher are able to enter this portal.", TALKTYPE_ORANGE_1)
    doTeleportThing(cid, fromPosition, TRUE)
end

function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) == TRUE then
        local Gate = From[item.uid]
        if Gate then
            if isPremium(cid) == TRUE then
                if getPlayerLevel(cid) >= 30 then
                    if isInArray(Gate[3], getPlayerVocation(cid)) == TRUE or getPlayerAccess(cid) >= 3 then
                        local nPos = Locations[Gate[1]][math.random(1, 2)]
                        doTeleportThing(cid, nPos, FALSE)
                        doSendMagicEffect(nPos, CONST_ME_TELEPORT)
                        setPlayerStorageValue(cid, Stor, Gate[2])
                    else
                        MoveBack(cid, fromPosition, Gate[3][1])
                    end
                else
                    MoveBack(cid, fromPosition, Gate[3][1])
                end
            else
                MoveBack(cid, fromPosition, Gate[3][1])
            end
        elseif isInArray(ActionsIds, item.actionid) == TRUE then
            if Back[getPlayerStorageValue(cid, Stor)] then
                local backPos = Back[getPlayerStorageValue(cid, Stor)]
                doTeleportThing(cid, backPos, FALSE)
                doSendMagicEffect(backPos, CONST_ME_TELEPORT)
            else
                --if the player does not have a storage he will be teleported here
                doTeleportThing(cid, {x=1000, y=1000, z=7}, FALSE)
                doSendMagicEffect({x=1000, y=1000, z=7}, CONST_ME_TELEPORT)
            end
        end
    end
    return TRUE
end
 
Back
Top Bottom