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

Pay exp for Time Problem

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
188
Reaction score
9
GitHub
Jarek123
Hello guy I use Tfs 1.5 And when I click on lever I have this error in console How I can fix it?

error
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/online/exp3.lua:onUse
luaAddEvent(). Argument #3 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/actions/scripts/online/exp3.lua:24: in function <data/actions/scripts/online/exp3.lua:7>


script

Code:
local teleportPosition = {x=32487, y=32570, z=14}
local templePosition = {x=160, y=54, z=7}
local magicCoinId = 10558
local amountRequired = 100
local cooldownInSeconds = 5

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 Online Points to Go!")
        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 3H.")
        end
    end, 10800000, cid)
    return true
end
 
Solution
Lua:
local teleportPosition = Position(32487, 32570, 14)
local templePosition = Position(160, 54, 7)
local magicCoinId = 10558
local amountRequired = 100
local cooldownInSeconds = 5

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local lastTeleportTime = player:getStorageValue(38387)
    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        player:sendCancelMessage("You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not player:removeItem(magicCoinId, amountRequired) then
        player:sendCancelMessage("You need 100 Online Points to Go!")
        return true
    end...
Lua:
local teleportPosition = Position(32487, 32570, 14)
local templePosition = Position(160, 54, 7)
local magicCoinId = 10558
local amountRequired = 100
local cooldownInSeconds = 5

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local lastTeleportTime = player:getStorageValue(38387)
    if lastTeleportTime and os.time() - lastTeleportTime < cooldownInSeconds then
        player:sendCancelMessage("You must wait " .. cooldownInSeconds .. " seconds before using this command again.")
        return true
    end

    if not player:removeItem(magicCoinId, amountRequired) then
        player:sendCancelMessage("You need 100 Online Points to Go!")
        return true
    end

    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(teleportPosition)
    teleportPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(38387, os.time())

    addEvent(function(cid)
        local p = Player(cid)
        if p then
            p:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            p:teleportTo(templePosition)
            teleportPosition:sendMagicEffect(CONST_ME_TELEPORT)
            p:sendTextMessage(MESSAGE_STATUS_WARNING, "You have been teleported back to the temple after 3H.")
        end
    end, 10800000, player:getId())
    return true
end
 
Solution
Thank you for help :)
Now Is error
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/online/exp1.lua:onUse
data/actions/scripts/online/exp1.lua:21: attempt to call method 'sendMagicEffect' (a nil value)
stack traceback:
        [C]: in function 'sendMagicEffect'
        data/actions/scripts/online/exp1.lua:21: in function <data/actions/scripts/online/exp1.lua:7>
 
Did you copy everything? Including the local variables at the top?

Lua:
local teleportPosition = Position(32487, 32570, 14)
local templePosition = Position(160, 54, 7)
local magicCoinId = 10558
local amountRequired = 100
local cooldownInSeconds = 5
 
No sorry ,now working perfect bro ;) thank you very much
I have problem too with event snowball meybe you can help me bro ?
 
Last edited:
Back
Top