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

Timer Problem

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
188
Reaction score
9
GitHub
Jarek123
Hello guys I use tfs 0.4 tibia 8.6 and I have this script
Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local magicCoinId = 6527
local amountRequired = 100

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins To Go IN!")
        return true
    end
  
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)
    return true
end

and I would like do When Player go to exp Have a time and after this time Teleport him to temple 160,54,7 how I can do it?
Post automatically merged:

Any One ?help me please
Post automatically merged:

Up
 
Last edited:
Solution
try this
If it works wait for mateus to take the script and edit it inside his one so he can receive the solution:)
I have tested it and it worked for me

Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 6527
local amountRequired = 100
local cooldownInSeconds = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lastTeleportTime = getPlayerStorageValue(cid, 38387)
    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        doPlayerSendCancel(cid, "You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not doPlayerRemoveItem(cid, magicCoinId...
You can use addEvent for this


Lua:
addEvent(function(cid, pos)  
if Player(cid) then
     doTeleportThing(cid, pos)
end
end, 60000, cid, pos)

where 60000 its a time after addevent will be executed
 
Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local magicCoinId = 6527
local amountRequired = 100

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins To Go IN!")
        return true
    end
 
addEvent(function(cid, pos)  
if Player(cid) then
     doTeleportThing(cid, pos)
end
end, 60000, cid, pos)

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)
    return true
end
Post automatically merged:

Like that bro? and I would like when is after time Player is teleport to temple 160,54,7 how I can doi it ?
 
Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 6527
local amountRequired = 100
local cooldownInSeconds = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lastTeleportTime = getPlayerStorageValue(cid, 38387)

    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        doPlayerSendCancel(cid, "You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins to enter!")
        return true
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)

    setPlayerStorageValue(cid, 38387, os.time())
    addEvent(function(cid)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        doTeleportThing(cid, templePosition)
        doSendMagicEffect(templePosition, CONST_ME_TELEPORT)
    end, 1000, 1, cid)

    return true
end
 
Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 6527
local amountRequired = 100
local cooldownInSeconds = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lastTeleportTime = getPlayerStorageValue(cid, 38387)

    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        doPlayerSendCancel(cid, "You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins to enter!")
        return true
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)

    setPlayerStorageValue(cid, 38387, os.time())
    addEvent(function(cid)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        doTeleportThing(cid, templePosition)
        doSendMagicEffect(templePosition, CONST_ME_TELEPORT)
    end, 1000, 1, cid)

    return true
end
Lua:
30:48] In a timer event called from:
[17:30:48] data/actions/scripts/specialcave/exp1.lua:onUse
[17:30:48] Description:
[17:30:48] (LuaInterface::luaGetThingPosition) Thing not found

[17:30:48] [Error - Action Interface]
[17:30:48] In a timer event called from:
[17:30:48] data/actions/scripts/specialcave/exp1.lua:onUse
[17:30:48] Description:
[17:30:48] (LuaInterface::luaDoTeleportThing) Thing not found
Post automatically merged:

can any one help me?please guys
 
Last edited:
try.
Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 6527
local amountRequired = 100
local cooldownInSeconds = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lastTeleportTime = getPlayerStorageValue(cid, 38387)

    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        doPlayerSendCancel(cid, "You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins to enter!")
        return true
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)

    setPlayerStorageValue(cid, 38387, os.time())
    addEvent(function(cid)
        if isPlayer(cid) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, templePosition)
            doSendMagicEffect(templePosition, CONST_ME_TELEPORT)
        else
            print("Invalid player character id in timer event: " .. tostring(cid))
        end
    end, 1000, 1, cid)

    return true
end
 
Is in console

Invalid player character id in timer event: 1
But no teleport to temple After 60seconds
Post automatically merged:

Every time I looking fo like that script Pay hunt for time but I can not find ;/
 
Last edited:
I put a printout for debugging to see where the error is in the ID or in the player.

Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 6527
local amountRequired = 100
local cooldownInSeconds = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lastTeleportTime = getPlayerStorageValue(cid, 38387)

    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        doPlayerSendCancel(cid, "You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins to enter!")
        return true
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)

    setPlayerStorageValue(cid, 38387, os.time())
    
 
    local playerID = cid
    addEvent(function(playerID)
        print("Timer event running for player ID: " .. tostring(playerID)) -- Debug message
        if isPlayer(playerID) then
            doSendMagicEffect(getCreaturePosition(playerID), CONST_ME_TELEPORT)
            doTeleportThing(playerID, templePosition)
            doSendMagicEffect(templePosition, CONST_ME_TELEPORT)
        else
            print("Player disconnected or invalid during timer event for player ID: " .. tostring(playerID)) -- Debug message
        end
    end, 1000, 1, playerID)

    return true
end
 
Code:
Timer event running for player ID: 1
Player disconnected or invalid during timer event for player ID: 1

No Teleport;/
Post automatically merged:

I want when Player go to Pay hunt for 100 event coins after 60second teleport him to temple after 60seconds and when want back to pay hunt must second time pay 100 event coins
 
Last edited:
Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 6527
local amountRequired = 100
local cooldownInSeconds = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lastTeleportTime = getPlayerStorageValue(cid, 38387)

    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        doPlayerSendCancel(cid, "You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins to enter!")
        return true
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)

    setPlayerStorageValue(cid, 38387, os.time())

    local playerID = cid
    addEvent(function(playerID)
        if isPlayer(playerID) then
            doSendMagicEffect(getCreaturePosition(playerID), CONST_ME_TELEPORT)
            doTeleportThing(playerID, templePosition)
            doSendMagicEffect(templePosition, CONST_ME_TELEPORT)
            doPlayerSendTextMessage(playerID, MESSAGE_STATUS_WARNING, "You have been teleported back to the temple after 60 seconds.")
        else
            print("Player disconnected or invalid during timer event for player ID: " .. tostring(playerID)) -- Debug message
        end
    end, 60000, 1, playerID)

    return true
end
 
try this
If it works wait for mateus to take the script and edit it inside his one so he can receive the solution:)
I have tested it and it worked for me

Lua:
local teleportPosition = {x=32351, y=31994, z=7}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 6527
local amountRequired = 100
local cooldownInSeconds = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lastTeleportTime = getPlayerStorageValue(cid, 38387)
    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        doPlayerSendCancel(cid, "You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not doPlayerRemoveItem(cid, magicCoinId, amountRequired) then
        doPlayerSendCancel(cid, "You need 100 Event Coins to enter!")
        return true
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, teleportPosition)
    doSendMagicEffect(teleportPosition, CONST_ME_TELEPORT)
    setPlayerStorageValue(cid, 38387, os.time())

    addEvent(function(cid)
        if isPlayer(cid) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, templePosition)
            doSendMagicEffect(templePosition, CONST_ME_TELEPORT)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have been teleported back to the temple after 60 seconds.")
        end
    end, 60000, cid)
    return true
end
 
Solution
I love you guys <3 Working
I have question is possible add When player is inside hunt next platyers can not go to hunt when is player inside must wait for finish first player ?
Post automatically merged:

:(
 
Last edited:
I love you guys <3 Working
I have question is possible add When player is inside hunt next platyers can not go to hunt when is player inside must wait for finish first player ?
Post automatically merged:

:(

it is possible yes but u must create a new thread for it since u requested something different :D
Create it and we will help you
 
Back
Top