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

Teleport Player Spell

Hashirama479

World of Ninja
Joined
Dec 19, 2016
Messages
536
Solutions
6
Reaction score
74
Hey Otland! I need a teleport player spell! How it should working like? If you got someone in target you using the spell then you get with the player teleported to position 1500,1500,7 and after 10 sec you get kicked out from there then you must wait 120 sec to cast the spell again xD im using tfs 0.4 :p thanks!
 
Last edited:
Solution
Im not sure if this one will work, idk how to code spells.
spells.xml
Code:
    <instant name="TPenemy" words="blablabklablaa" lvl="160" mana="20" prem="0" range="5" casterTargetOrDirection="1" blockwalls="0" exhaustion="2000" needlearn="0" event="script" value="tpEnemy.lua">
       <vocation id="1"/>
       <vocation id="2"/>
       <vocation id="3"/>
       <vocation id="4"/>
   </instant>
tpEnemy.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

czekaj = coroutine.yield
function czekanie(c)
    if(coroutine.status(c) ~= 'dead') then
        local _, czas = coroutine.resume(c)
        addEvent(czekanie...
Im not sure if this one will work, idk how to code spells.
spells.xml
Code:
    <instant name="TPenemy" words="blablabklablaa" lvl="160" mana="20" prem="0" range="5" casterTargetOrDirection="1" blockwalls="0" exhaustion="2000" needlearn="0" event="script" value="tpEnemy.lua">
       <vocation id="1"/>
       <vocation id="2"/>
       <vocation id="3"/>
       <vocation id="4"/>
   </instant>
tpEnemy.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

czekaj = coroutine.yield
function czekanie(c)
    if(coroutine.status(c) ~= 'dead') then
        local _, czas = coroutine.resume(c)
        addEvent(czekanie, czas, c)
    end
end
function zacznijCzekac(f)
    if(type(f) == 'function') then
        local c = coroutine.create(f)
        czekanie(c)
    end
end

function onCastSpell(cid, var)
   local config = {
       player1_position = {x = 1000, y = 1000, z = 7},
       player2_position = {x = 1000, y = 1000, z = 7},
       time_back = 10,
       storage = 11111,
       cooldown = 120
   }
   if(os.time() - getPlayerStorageValue(cid, config.storage)) < config.cooldown then
       doPlayerSendCancel(cid, "You are exhausted.")
       doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
       return false
   end
   local target = variantToNumber(var)
   local ppos = getCreaturePosition(cid)
   local tpos = getCreaturePosition(target)
   zacznijCzekac(function()
   if isPlayer(target) then
       doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
       doTeleportThing(cid, config.player1_position)
       doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
       doSendMagicEffect(getCreaturePosition(target), CONST_ME_POFF)
       doTeleportThing(target, config.player2_position)
       doSendMagicEffect(getCreaturePosition(target), CONST_ME_TELEPORT)
       setPlayerStorageValue(cid, config.storage, os.time())
       czekaj(config.time_back * 1000)
           if isPlayer(cid) then
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
               doTeleportThing(cid, ppos)
               doSendMagicEffect(ppos, CONST_ME_TELEPORT)
           end
           if isPlayer(target) then
               doSendMagicEffect(getCreaturePosition(target), CONST_ME_POFF)
               doTeleportThing(target, tpos)
               doSendMagicEffect(tpos, CONST_ME_TELEPORT)
           end
   end
   end)
   return doCombat(cid, combat, var)
end
 
Last edited:
Solution
Tired it out and it didnt tp the players.. xD here the error

5f4fbe4b190846d7879088b1eaad13de.png

Gyazo - 5f4fbe4b190846d7879088b1eaad13de.png

EDIT: Seems like the coultdown does not work too :p
 
Ok now it tps the players as supposed but the coultdown is still not working :p here the error:

62f9db2491edd04c06af2663a25f8249.png

Gyazo - 62f9db2491edd04c06af2663a25f8249.png

Yo seems like I have forgot to say something.. when they get tped in that room they should get kicked out after the 10 sec and getting back to the old place where the spell has been used.. you get me? :p
 
Last edited by a moderator:
You shouldnt need to set a exhaustin the lua script....You can set cooldown on the spell in spells.xml

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

 local config = {
 time_back = 10 --in seconds
 storageX = 11111,
 storageY = 11112,
 storageZ = 11113,
 position = {x = 1500, y = 1500, z = 7}
 }

function onCastSpell(cid, var)
   local target = variantToNumber(var)

   
   if isPlayer(target) then
    doCombat(cid, combat, var)
      setPlayerStorageValue(cid, config.storageX, getPlayerPosition(cid).x)
      setPlayerStorageValue(cid, config.storageY, getPlayerPosition(cid).y)
      setPlayerStorageValue(cid, config.storageZ, getPlayerPosition(cid).z)

      setPlayerStorageValue(target, config.storageX, getPlayerPosition(target).x)
      setPlayerStorageValue(target, config.storageY, getPlayerPosition(target).y)
      setPlayerStorageValue(target, config.storageZ, getPlayerPosition(target).z)

       doTeleportThing(cid, config.position)
       doTeleportThing(target, config.position)
       doSendMagicEffect(getCreaturePosition(target), CONST_ME_TELEPORT)
       doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
      return addEvent(teleportBack, config.time_back * 1000, cid, target)
   end
end

function teleportBack(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        POS1 = {x = getPlayerStorageValue(cid, config.storageX), y = getPlayerStorageValue(cid, config.storageY), z = getPlayerStorageValue(cid, config.storageZ)}
        POS2 = {x = getPlayerStorageValue(target, config.storageX), y = getPlayerStorageValue(target, config.storageY), z = getPlayerStorageValue(target, config.storageZ)}
        doTeleportThing(cid, POS1)
        doTeleportThing(cid, POS2)
        doSendMagicEffect(getCreaturePosition(target), CONST_ME_TELEPORT)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end
end
 
Last edited:
Last edited by a moderator:
The most idiot idea ever xD bcus if you set it at spells.xml then you cant use any other spell :p

Unless you set it for conjure instead of instant spell. Then it will only exhaust spells that you don't really use when fighting or if your not lazy and want to do it right you can make a new spell group for spells like that.

Not good to call someone an idiot when you can even make the script yourself.
 
Back
Top