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

[TFS 0.4] 2x SPELL REQUEST

Hashirama479

World of Ninja
Joined
Dec 19, 2016
Messages
536
Solutions
6
Reaction score
74
I would like to request two spells xD

1. When you target someone and using that spell, the player gets tped next to you

2. When you use the spell you can run for atleast 10 secs and when the 10 secs are done, you get tped back to the position where you have used the spell xD

thats all, sorry if my english is kinda bad now haha
if you do not understand what I mean I can explain better xD
 
Solution
@Aled @Hashirama479
If you are going to use storages remember that player can die within this time or just logout, if it happen the script wont change the storage and the spell will be bugged for him for forever. So best option is to add line to login.lua which deleting storage.
Code:
setPlayerStorageValue(cid, 1500, -1)
I did mention that but then I changed my mind and just put
LUA:
    addEvent(function()
        if creature then
            setPlayerStorageValue(creature,storage,-1)
        end
    end,cooldown*1000)
change creature to cid he make scripts for tf 1.+
There is no reason that script will not work for TFS 0.4
Sorry guys im stupid, i just seen now i request exhastion time on the...
LUA:
function onCastSpell(creature, variant)
    local target = getCreatureTarget(player)
    doTeleportThing(target, getCreaturePosition(creature))
    return true
end
LUA:
function onCastSpell(creature, variant)
    local toPos = getCreaturePosition(creature)
    addEvent(function()
        doTeleportThing(creature, toPos)
    end,10*1000)
    return true
end
These things are very easily achievable if you take the time to read up on some tutorials
Don't expect free handouts every day
 
I got a small problem, I cant add exhastion time on that spell somehow can you please help me?

LUA:
function onCastSpell(creature, variant)
    local target = getCreatureTarget(player)
    doTeleportThing(target, getCreaturePosition(creature))
    return true
end
 
Probably best done with storage values
LUA:
function onCastSpell(creature, variant)
    local cooldown = 8 -- seconds
    local target = getCreatureTarget(player)
    local storage = 1500
    addEvent(function()
        if creature then
            setPlayerStorageValue(creature,storage,-1)
        end
    end,cooldown*1000)
    if getPlayerStorageValue(creature,storage) ~= 1 then
        setPlayerStorageValue(creature,storage,1)
        doTeleportThing(target, getCreaturePosition(creature))
    else
        doSendMagicEffect(getCreaturePosition(creature), CONST_ME_POFF)
        doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "This spell is on cooldown!")
        return false
    end
    return true
end
 
Last edited:
@Aled @Hashirama479
If you are going to use storages remember that player can die within this time or just logout, if it happen the script wont change the storage and the spell will be bugged for him for forever. So best option is to add line to login.lua which deleting storage.
Code:
setPlayerStorageValue(cid, 1500, -1)
 
I got a error:
cdbd7ddda40c2f05675c629feb7d56e1.png

Gyazo - cdbd7ddda40c2f05675c629feb7d56e1.png
 
LUA:
function onCastSpell(cid, var)
    local cooldown = 8 -- seconds
    local target = getCreatureTarget(cid)
    local storage = 1500
    addEvent(function()
        if cid then
            setPlayerStorageValue(cid,storage,-1)
        end
    end,cooldown*1000)
    if getPlayerStorageValue(cid,storage) ~= 1 then
        setPlayerStorageValue(cid,storage,1)
        doTeleportThing(target, getCreaturePosition(cid))
    else
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This spell is on cooldown!")
        return false
    end
    return true
end
 
LUA:
function onCastSpell(cid, var)
   local storage = xxxx
   local exhaustTime = 8

   if getPlayerStorageValue(cid, storage) > os.time() then
   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This spell is on cooldown!")
   return false
   end

    local target = getCreatureTarget(cid)
    doTeleportThing(target, getCreaturePosition(cid))

     setPlayerStorageValue(cid, storage, os.time() + exhaustTime)

    return true
end
?
 
Last edited:
Sorry guys im stupid, i just seen now i request exhastion time on the wrong spell...

LUA:
function onCastSpell(creature, variant)
    local toPos = getCreaturePosition(creature)
    addEvent(function()
        doTeleportThing(creature, toPos)
    end,10*1000)
    return true
end

Thats the right now, sorry for wasting ur guys time..

EDIT:

Probably best done with storage values
LUA:
function onCastSpell(creature, variant)
    local cooldown = 8 -- seconds
    local target = getCreatureTarget(player)
    local storage = 1500
    addEvent(function()
        if creature then
            setPlayerStorageValue(creature,storage,-1)
        end
    end,cooldown*1000)
    if getPlayerStorageValue(creature,storage) ~= 1 then
        setPlayerStorageValue(creature,storage,1)
        doTeleportThing(target, getCreaturePosition(creature))
    else
        doSendMagicEffect(getCreaturePosition(creature), CONST_ME_POFF)
        doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "This spell is on cooldown!")
        return false
    end
    return true
end

That script is also working xD thanks for it too
 
Last edited:
@Aled @Hashirama479
If you are going to use storages remember that player can die within this time or just logout, if it happen the script wont change the storage and the spell will be bugged for him for forever. So best option is to add line to login.lua which deleting storage.
Code:
setPlayerStorageValue(cid, 1500, -1)
I did mention that but then I changed my mind and just put
LUA:
    addEvent(function()
        if creature then
            setPlayerStorageValue(creature,storage,-1)
        end
    end,cooldown*1000)
change creature to cid he make scripts for tf 1.+
There is no reason that script will not work for TFS 0.4
Sorry guys im stupid, i just seen now i request exhastion time on the wrong spell...

LUA:
function onCastSpell(creature, variant)
    local toPos = getCreaturePosition(creature)
    addEvent(function()
        doTeleportThing(creature, toPos)
    end,10*1000)
    return true
end

Thats the right now, sorry for wasting ur guys time..

EDIT:



That script is also working xD thanks for it too
LUA:
function onCastSpell(creature, variant)
    local cooldown = 10 -- seconds
    local storage = 1501
    local toPos = getCreaturePosition(creature)
    addEvent(function()
        if creature then
            setPlayerStorageValue(creature,storage,-1)
        end
    end,cooldown*1000)
    if getPlayerStorageValue(creature,storage) ~= 1 then
        setPlayerStorageValue(creature,storage,1)
        addEvent(function()
            if creature then
                doTeleportThing(creature, toPos)
            end
        end,10*1000)
    else
        doSendMagicEffect(getCreaturePosition(creature), CONST_ME_POFF)
        doPlayerSendTextMessage(creature, MESSAGE_INFO_DESCR, "This spell is on cooldown!")
        return false
    end
    return true
end
We are human, we are all stupid
 
Solution
i know i don't say anything about script he said error i told him change creature to cid that all .... i know player and creature = cid

have fun and good joob :D
As far as I know, TFS 1.x marked the introduction of metamethods which is what prompted the change from cid to creature/player and so on.
But they are just arbitrary variables, what matters is its position in the function onCastSpell(arg1,arg2)
It doesn't matter what name you use, so long as its in the right place and consistent throughout the function
 
Back
Top