exhaustion =
{
check = function (cid, storage)
return getPlayerStorageValue(cid, storage) >= os.time(t)
end,
get = function (cid, storage)
local exhaust = getPlayerStorageValue(cid, storage)
if(exhaust > 0) then
local left = exhaust - os.time(t)
if(left >= 0) then
return left
end
end
return false
end,
set = function (cid, storage, time)
setPlayerStorageValue(cid, storage, os.time(t) + time)
end,
make = function (cid, storage, time)
local exhaust = exhaustion.get(cid, storage)
if(not exhaust) then
exhaustion.set(cid, storage, time)
return true
end
return false
end
}
local newpos = {x=861, y=698, z=7}
local time = 8--in second
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local cid = player:getId()
if exhaustion.check(cid, 1605) then
return doPlayerSendCancel(cid, "Please Wait "..exhaustion.get(cid,1605).." seconds.") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
if not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
doSendMagicEffect(getPlayerPosition(cid), 2)
doTeleportThing(cid,newpos)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
doCreatureSay(cid, "TELEPORTED!!" ,TALKTYPE_ORANGE_1)
exhaustion.set(cid, 1605, time)
else
doPlayerSendTextMessage(cid,25,"You can't use the teleport scroll if you are PZ LOCKED!!")
end
return true
end