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

Action TFS 0.3.x teleport like DIABLO 2

beliar34

Member
Joined
Feb 28, 2012
Messages
307
Solutions
7
Reaction score
11
Hello i made simple script that teleport us like teleport in diablo 2
First use : teleport to temple
Second use : teleport back to place where you use first tp :)
third use : teleport to temple and loop is going on
To use you cant have PZ

Script :
Code:
function onUse(cid, item, frompos, item2, topos)
    local temple = getPlayerMasterPos(cid)
    local graczpos = getPlayerPosition(cid)
    if hasCondition(cid, CONDITION_INFIGHT) == false then
    if ((getPlayerStorageValue(cid, 80000) == 0) or (getPlayerStorageValue(cid, 80000) == -1)) then
            setPlayerStorageValue(cid,80001,graczpos.x)
            setPlayerStorageValue(cid,80002,graczpos.y)
            setPlayerStorageValue(cid,80003,graczpos.z)
            setPlayerStorageValue(cid,80000,1)
            doTeleportThing(cid,temple)
            doSendMagicEffect(temple, 41)
        elseif getPlayerStorageValue(cid, 80000) == 1 then
            doTeleportThing(cid, {x = getPlayerStorageValue(cid, 80001), y = getPlayerStorageValue(cid, 80002), z = getPlayerStorageValue(cid, 80003)})
            setPlayerStorageValue(cid,80000,0)
        end
    else
        doCreatureSay(cid, "Cant teleport with PZ.", TALKTYPE_ORANGE_1)
    end
end
 
I concur that it should work as intended.
I made a more restrictive rune like this, and did it in the same manner.
 
@Xikini can you post your script here ?
Well, I mean..
It wasn't something I was going to release. xD

I'm not exactly proud of this script, but here it is. :c

It's a 'hunting rune'.
Can be used forever.

Upon first use, you get teleported to your temple position. A 'portal' with your name on it is created at the spot you used the rune.
(notes: must be out of combat to use.)
(notes: since we used this sprite exclusively as a unique portal in multiple scripts, this item is set to decay after 1 hour in items.xml)

Upon second use, you get teleported back to your hunting grounds. Rune is then set on a 1 hour cooldown.
(notes: 5 minute anti double-click, because players were complaining that they double clicked the rune and lost it's ability for 1 hour.)
(notes: Must be in a PZ zone, to return to their hunting location.)
Lua:
-- <action actionid="46100" event="script" value="hunting_rune.lua"/>

local storage = {
   [1] = 49001, -- so we know if portal is active or not.
   [2] = 49002, -- x
   [3] = 49003, -- y
   [4] = 49004, -- z
   [5] = 49005, -- anti-double click
   [6] = 49006, -- needed something to hold the string data
   [7] = 49007  -- portal timer
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if exhaustion.check(cid, storage[5]) then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "You are exhausted. You can use the hunting rune again in ".. os.date("!%M:%S", getPlayerStorageValue(cid, storage[6]) - os.time()) ..".")
       return true
   end
   if getCreatureCondition(cid, CONDITION_INFIGHT) == true then
       doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "You may not use this rune while in-fight!")
       return true
   end
   if getPlayerStorageValue(cid, storage[1]) < 1 then
       pos = getCreaturePosition(cid)
       setPlayerStorageValue(cid, storage[2], pos.x)
       setPlayerStorageValue(cid, storage[3], pos.y)
       setPlayerStorageValue(cid, storage[4], pos.z)
       setPlayerStorageValue(cid, storage[1], 1)
       kkk = doCreateItem(13934, 1, pos)
       doItemSetAttribute(kkk, "description", "" .. getCreatureName(cid) .. "'s Portal.")
       doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
       exhaustion.set(cid, storage[5], 5)
       exhaustion.set(cid, storage[7], 60 * 60)
       setPlayerStorageValue(cid, storage[6], (os.time() + 5))
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been returned to town. You have 1 hour to return to last known position.")
   elseif getPlayerStorageValue(cid, storage[1]) == 1 then
       if getTilePzInfo(getCreaturePosition(cid)) == TRUE then
           if exhaustion.check(cid, storage[7]) then
               x = getPlayerStorageValue(cid, storage[2])
               y = getPlayerStorageValue(cid, storage[3])
               z = getPlayerStorageValue(cid, storage[4])
               pos = {x = x, y = y, z = z}
               doTeleportThing(cid, pos, FALSE)
               exhaustion.set(cid, storage[5], 60 * 60)
               setPlayerStorageValue(cid, storage[6], (os.time() + 60 * 60))
               doRemoveItem(getTileItemById(pos, 13934).uid)
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been returned to your last known position. Hunting Rune on 1 hour cooldown.")
           else
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It has been over 1 hour. No longer able to teleport to last known position. When you use the hunting rune next you will be teleported to town.")
           end
           setPlayerStorageValue(cid, storage[1], 0)
       else
           doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
           doPlayerSendCancel(cid, "You must use this rune in a protection zone to return to your last known position.")
       end
   end

   return true
end
 
Well, I mean..
It wasn't something I was going to release. xD

I'm not exactly proud of this script, but here it is. :c

It's a 'hunting rune'.
Can be used forever.

Upon first use, you get teleported to your temple position. A 'portal' with your name on it is created at the spot you used the rune.
(notes: must be out of combat to use.)
(notes: since we used this sprite exclusively as a unique portal in multiple scripts, this item is set to decay after 1 hour in items.xml)

Upon second use, you get teleported back to your hunting grounds. Rune is then set on a 1 hour cooldown.
(notes: 5 minute anti double-click, because players were complaining that they double clicked the rune and lost it's ability for 1 hour.)
(notes: Must be in a PZ zone, to return to their hunting location.)
Lua:
-- <action actionid="46100" event="script" value="hunting_rune.lua"/>

local storage = {
   [1] = 49001, -- so we know if portal is active or not.
   [2] = 49002, -- x
   [3] = 49003, -- y
   [4] = 49004, -- z
   [5] = 49005, -- anti-double click
   [6] = 49006, -- needed something to hold the string data
   [7] = 49007  -- portal timer
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if exhaustion.check(cid, storage[5]) then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "You are exhausted. You can use the hunting rune again in ".. os.date("!%M:%S", getPlayerStorageValue(cid, storage[6]) - os.time()) ..".")
       return true
   end
   if getCreatureCondition(cid, CONDITION_INFIGHT) == true then
       doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "You may not use this rune while in-fight!")
       return true
   end
   if getPlayerStorageValue(cid, storage[1]) < 1 then
       pos = getCreaturePosition(cid)
       setPlayerStorageValue(cid, storage[2], pos.x)
       setPlayerStorageValue(cid, storage[3], pos.y)
       setPlayerStorageValue(cid, storage[4], pos.z)
       setPlayerStorageValue(cid, storage[1], 1)
       kkk = doCreateItem(13934, 1, pos)
       doItemSetAttribute(kkk, "description", "" .. getCreatureName(cid) .. "'s Portal.")
       doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
       exhaustion.set(cid, storage[5], 5)
       exhaustion.set(cid, storage[7], 60 * 60)
       setPlayerStorageValue(cid, storage[6], (os.time() + 5))
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been returned to town. You have 1 hour to return to last known position.")
   elseif getPlayerStorageValue(cid, storage[1]) == 1 then
       if getTilePzInfo(getCreaturePosition(cid)) == TRUE then
           if exhaustion.check(cid, storage[7]) then
               x = getPlayerStorageValue(cid, storage[2])
               y = getPlayerStorageValue(cid, storage[3])
               z = getPlayerStorageValue(cid, storage[4])
               pos = {x = x, y = y, z = z}
               doTeleportThing(cid, pos, FALSE)
               exhaustion.set(cid, storage[5], 60 * 60)
               setPlayerStorageValue(cid, storage[6], (os.time() + 60 * 60))
               doRemoveItem(getTileItemById(pos, 13934).uid)
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been returned to your last known position. Hunting Rune on 1 hour cooldown.")
           else
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It has been over 1 hour. No longer able to teleport to last known position. When you use the hunting rune next you will be teleported to town.")
           end
           setPlayerStorageValue(cid, storage[1], 0)
       else
           doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
           doPlayerSendCancel(cid, "You must use this rune in a protection zone to return to your last known position.")
       end
   end

   return true
end
Hello, sir i've tested your script but it has a bug, gonna explain now:
1-. player use rune
2-. player get tp to temple (success)
3-. player spawn an check-point item on used position (id: 13934, i changed it to 11796)
4-. player tries to tp back but fail (message appear: It has been over 1 hour. No longer able to teleport to last known position. When you use the hunting rune next you will be teleported to town.)

note: using tfs 0.4 trunk 3777 rev12

what could be the failure?
 
Hello, sir i've tested your script but it has a bug, gonna explain now:
1-. player use rune
2-. player get tp to temple (success)
3-. player spawn an check-point item on used position (id: 13934, i changed it to 11796)
4-. player tries to tp back but fail (message appear: It has been over 1 hour. No longer able to teleport to last known position. When you use the hunting rune next you will be teleported to town.)

note: using tfs 0.4 trunk 3777 rev12

what could be the failure?
data/lib/034-exhaustion.lua
-- here is the one I use.
Lua:
exhaustion =
{
   check = function (cid, storage)
       if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
           return false
       end

       return getPlayerStorageValue(cid, storage) >= os.time()
   end,

   get = function (cid, storage)
       if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
           return false
       end

       local exhaust = getPlayerStorageValue(cid, storage)
       if(exhaust > 0) then
           local left = exhaust - os.time()
           if(left >= 0) then
               return left
           end
       end

       return false
   end,

   set = function (cid, storage, time)
       setPlayerStorageValue(cid, storage, os.time() + time)
   end,

   make = function (cid, storage, time)
       local exhaust = exhaustion.get(cid, storage)
       if(not exhaust) then
           exhaustion.set(cid, storage, time)
           return true
       end

       return false
   end
}
 
data/lib/034-exhaustion.lua
-- here is the one I use.
Lua:
exhaustion =
{
   check = function (cid, storage)
       if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
           return false
       end

       return getPlayerStorageValue(cid, storage) >= os.time()
   end,

   get = function (cid, storage)
       if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
           return false
       end

       local exhaust = getPlayerStorageValue(cid, storage)
       if(exhaust > 0) then
           local left = exhaust - os.time()
           if(left >= 0) then
               return left
           end
       end

       return false
   end,

   set = function (cid, storage, time)
       setPlayerStorageValue(cid, storage, os.time() + time)
   end,

   make = function (cid, storage, time)
       local exhaust = exhaustion.get(cid, storage)
       if(not exhaust) then
           exhaustion.set(cid, storage, time)
           return true
       end

       return false
   end
}

yeah, i have running that library but still wont teleport back to. :S
 
Back
Top