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

[TFS 1.4] Simple teleport scroll script

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,085
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
Here's a simple teleport scroll script that teleports you to x, y, z and checks for battle status.
Lua:
-- Simple teleport scroll script
local testAction = Action() -- this is our header, the first thing we have to write (except for configuration tables and such)

local destination = {x=1002, y=1002, z=5} -- Change your destination here.

function testAction.onUse(cid, item, fromPosition, target, toPosition, isHotkey) -- now we can design the action itself
    if getCreatureCondition(cid, CONDITION_INFIGHT) == false then -- check if player is in a fight
    doTeleportThing(cid, destination) -- send player to position above at destination
    doPlayerSendTextMessage(cid, 19, "Your teleport scroll has been destroyed while you used its magic.") -- send scroll use message
    item:remove() -- remove the scroll
    else
        doPlayerSendTextMessage(cid, 22, "You cant teleport while in battle.") -- send cancel msg 
    end
    return true
end

testAction:id(5952) -- now its taking an item as id instead of an action id.
testAction:register() -- this is our footer, it has to be the last function executed
 
Hello, how to add cooldown to re-use?

Thanks and nice script, tested and working.
Here, this should do the trick
Lua:
-- Simple teleport scroll script
local testAction = Action() -- this is our header, the first thing we have to write (except for configuration tables and such)

local config = {
    storage = 1000, -- Storage for timer
    time = 2, -- Time in seconds being multiplied by 60 down below. so 2 minutes.
    destination = {x=1002, y=1002, z=5}, -- Change your destination here.
}

function testAction.onUse(cid, item, fromPosition, target, toPosition, isHotkey) -- now we can design the action itself
    if getPlayerStorageValue(cid, config.storage) - os.time() > 1 then
        doPlayerSendTextMessage(cid, 22, "You must wait "..config.time.." minutes before using this scroll again.") -- Send cancel message
        return false
    end
    if getCreatureCondition(cid, CONDITION_INFIGHT) == false then -- check if player is in a fight
        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 60) -- Setting storage + 2 times 60, so two mins.
        doTeleportThing(cid, config.destination) -- send player to position above at destination
        doPlayerSendTextMessage(cid, 19, "Your teleport scroll has been destroyed while you used its magic.") -- send scroll use message
        item:remove() -- remove the scroll
    else
        doPlayerSendTextMessage(cid, 22, "You cant teleport while in battle.") -- send cancel msg 
    end
    return true
end

testAction:id(5952) -- now its taking an item as id instead of an action id.
testAction:register() -- this is our footer, it has to be the last function executed
 
Here, this should do the trick
Lua:
-- Simple teleport scroll script
local testAction = Action() -- this is our header, the first thing we have to write (except for configuration tables and such)

local config = {
    storage = 1000, -- Storage for timer
    time = 2, -- Time in seconds being multiplied by 60 down below. so 2 minutes.
    destination = {x=1002, y=1002, z=5}, -- Change your destination here.
}

function testAction.onUse(cid, item, fromPosition, target, toPosition, isHotkey) -- now we can design the action itself
    if getPlayerStorageValue(cid, config.storage) - os.time() > 1 then
        doPlayerSendTextMessage(cid, 22, "You must wait "..config.time.." minutes before using this scroll again.") -- Send cancel message
        return false
    end
    if getCreatureCondition(cid, CONDITION_INFIGHT) == false then -- check if player is in a fight
        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 60) -- Setting storage + 2 times 60, so two mins.
        doTeleportThing(cid, config.destination) -- send player to position above at destination
        doPlayerSendTextMessage(cid, 19, "Your teleport scroll has been destroyed while you used its magic.") -- send scroll use message
        item:remove() -- remove the scroll
    else
        doPlayerSendTextMessage(cid, 22, "You cant teleport while in battle.") -- send cancel msg
    end
    return true
end

testAction:id(5952) -- now its taking an item as id instead of an action id.
testAction:register() -- this is our footer, it has to be the last function executed
Works perfect, thanks :D.

Only if possible, could you tell me how to add a effect?, like poof when dissapear and teleport effect when appear in the position, not really nessesary but would be cool.

But really thanks for all the help, :D
 
Back
Top