• 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 0.X Add time onUse

Forkz

Well-Known Member
Joined
Jun 29, 2020
Messages
380
Solutions
1
Reaction score
89
Hi otlanders,

I would like to add a time to use this item, could anyone help me?

Lua:
function onUse(cid, item, frompos, item2, topos)
local config = {
    protect = false, -- precisa estar em protection zone
    battle = false, -- precida estar sem battle
    removeItem = false -- remover item ao usar
}
local pos = getTownTemplePosition(getPlayerTown(cid)) -- posição para ser teleportado      
local playerPos = getCreaturePosition(cid)
local levelplayer = 1
   
    if ((levelplayer and getPlayerLevel(cid) < levelplayer)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you need to be level 100 or higher.")  
        return false
    end
        if config.protect and not getTilePzInfo(playerPos) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need to be in the protection zone to teleport.")
        return false
        elseif config.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need your battle to leave to teleport.")
        return false
    end
        if config.removeItem then
            doRemoveItem(item.uid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Now you can request your supreme vocation to the lord of vocation.")
        doSendMagicEffect(playerPos, CONST_ME_POFF)
        doTeleportThing(cid, pos)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
        return true
end
 
Solution
Lua:
function onUse(cid, item, frompos, item2, topos)
local config = {
    protect = false, -- precisa estar em protection zone
    battle = false, -- precida estar sem battle
    removeItem = false, -- remover item ao usar
    exhaustedstorage = 1111111111, -- storage used to set exhaustion
    exhaustedtime = 10 -- exhaust (seconds)
}
local pos = getTownTemplePosition(getPlayerTown(cid)) -- posição para ser teleportado
local playerPos = getCreaturePosition(cid)
local levelplayer = 1
    if (os.time() < getPlayerStorageValue(cid, config.exhaustedstorage)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
        return false
    end
    if ((levelplayer and getPlayerLevel(cid) < levelplayer)) then...
Don't know if that's what you requested.

Lua:
function onUse(cid, item, frompos, item2, topos)
local config = {
    protect = false, -- precisa estar em protection zone
    battle = false, -- precida estar sem battle
    removeItem = false -- remover item ao usar
    exhaustedstorage = 1111111111 -- storage used to set exhaustion
    exhaustedtime = 10 -- exhaust (seconds)
}
local pos = getTownTemplePosition(getPlayerTown(cid)) -- posição para ser teleportado 
local playerPos = getCreaturePosition(cid)
local levelplayer = 1
    if (os.time() < getPlayerStorageValue(cid, config.exhaustedstorage)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
        return false
    end
    if ((levelplayer and getPlayerLevel(cid) < levelplayer)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you need to be level 100 or higher.")
        return false
    end
        if config.protect and not getTilePzInfo(playerPos) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need to be in the protection zone to teleport.")
        return false
        elseif config.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need your battle to leave to teleport.")
        return false
    end
        if config.removeItem then
            doRemoveItem(item.uid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Now you can request your supreme vocation to the lord of vocation.")
        doSendMagicEffect(playerPos, CONST_ME_POFF)
        doTeleportThing(cid, pos)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
        setPlayerStorageValue(cid, config.exhaustedstorage, os.time() + config.exhaustedtime)
        return true
end
 
Don't know if that's what you requested.

Lua:
function onUse(cid, item, frompos, item2, topos)
local config = {
    protect = false, -- precisa estar em protection zone
    battle = false, -- precida estar sem battle
    removeItem = false -- remover item ao usar
    exhaustedstorage = 1111111111 -- storage used to set exhaustion
    exhaustedtime = 10 -- exhaust (seconds)
}
local exhaustedstorage = 1111111111 -- storage used to set exhaustion
local exhaustedtime = 10 -- exhaust (seconds)
local pos = getTownTemplePosition(getPlayerTown(cid)) -- posição para ser teleportado 
local playerPos = getCreaturePosition(cid)
local levelplayer = 1
    if (os.time() < getPlayerStorageValue(cid, config.exhaustedstorage)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
        return false
    end
    if ((levelplayer and getPlayerLevel(cid) < levelplayer)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you need to be level 100 or higher.")
        return false
    end
        if config.protect and not getTilePzInfo(playerPos) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need to be in the protection zone to teleport.")
        return false
        elseif config.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need your battle to leave to teleport.")
        return false
    end
        if config.removeItem then
            doRemoveItem(item.uid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Now you can request your supreme vocation to the lord of vocation.")
        doSendMagicEffect(playerPos, CONST_ME_POFF)
        doTeleportThing(cid, pos)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
        setPlayerStorageValue(cid, config.exhaustedstorage, os.time() + config.exhaustedtime)
        return true
end
[Error - LuaInterface::loadFile] data/actions/scripts/custom/goldenfalcon.lua:6: '}' expected (to close '{' at line 2) near 'exhaustedstorage'
[Error - Event::checkScript] Cannot load script (data/actions/scripts/custom/goldenfalcon.lua)
data/actions/scripts/custom/goldenfalcon.lua:6: '}' expected (to close '{' at line 2) near 'exhaustedstorage'
 
[Error - LuaInterface::loadFile] data/actions/scripts/custom/goldenfalcon.lua:6: '}' expected (to close '{' at line 2) near 'exhaustedstorage'
[Error - Event::checkScript] Cannot load script (data/actions/scripts/custom/goldenfalcon.lua)
data/actions/scripts/custom/goldenfalcon.lua:6: '}' expected (to close '{' at line 2) near 'exhaustedstorage'

Lua:
function onUse(cid, item, frompos, item2, topos)
local config = {
    protect = false, -- precisa estar em protection zone
    battle = false, -- precida estar sem battle
    removeItem = false, -- remover item ao usar
    exhaustedstorage = 1111111111, -- storage used to set exhaustion
    exhaustedtime = 10 -- exhaust (seconds)
}
local pos = getTownTemplePosition(getPlayerTown(cid)) -- posição para ser teleportado
local playerPos = getCreaturePosition(cid)
local levelplayer = 1
    if (os.time() < getPlayerStorageValue(cid, config.exhaustedstorage)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
        return false
    end
    if ((levelplayer and getPlayerLevel(cid) < levelplayer)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you need to be level 100 or higher.")
        return false
    end
        if config.protect and not getTilePzInfo(playerPos) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need to be in the protection zone to teleport.")
        return false
        elseif config.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need your battle to leave to teleport.")
        return false
    end
        if config.removeItem then
            doRemoveItem(item.uid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Now you can request your supreme vocation to the lord of vocation.")
        doSendMagicEffect(playerPos, CONST_ME_POFF)
        doTeleportThing(cid, pos)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
        setPlayerStorageValue(cid, config.exhaustedstorage, os.time() + config.exhaustedtime)
        return true
end
 
Lua:
function onUse(cid, item, frompos, item2, topos)
local config = {
    protect = false, -- precisa estar em protection zone
    battle = false, -- precida estar sem battle
    removeItem = false, -- remover item ao usar
    exhaustedstorage = 1111111111, -- storage used to set exhaustion
    exhaustedtime = 10 -- exhaust (seconds)
}
local pos = getTownTemplePosition(getPlayerTown(cid)) -- posição para ser teleportado
local playerPos = getCreaturePosition(cid)
local levelplayer = 1
    if (os.time() < getPlayerStorageValue(cid, config.exhaustedstorage)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
        return false
    end
    if ((levelplayer and getPlayerLevel(cid) < levelplayer)) then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you need to be level 100 or higher.")
        return false
    end
        if config.protect and not getTilePzInfo(playerPos) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need to be in the protection zone to teleport.")
        return false
        elseif config.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You need your battle to leave to teleport.")
        return false
    end
        if config.removeItem then
            doRemoveItem(item.uid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Now you can request your supreme vocation to the lord of vocation.")
        doSendMagicEffect(playerPos, CONST_ME_POFF)
        doTeleportThing(cid, pos)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
        setPlayerStorageValue(cid, config.exhaustedstorage, os.time() + config.exhaustedtime)
        return true
end
working!
 
Solution

Similar threads

Back
Top