This timer on the teleportscroll isn't working. When I use it i only get the cancelmessage "You can only use this scroll once every hour."
What's wrong with the timer?
What's wrong with the timer?
PHP:
function onUse(cid, item)
local compareTime = 60 * 60 * 1000
local scroll = 1959
local currentValue = getPlayerStorageValue(cid, 9897)
if currentValue == -1 then
currentValue = os.time()
end
if hasCondition(cid, CONDITION_INFIGHT) == TRUE and item.itemid == scroll then
doPlayerSendCancel(cid, "You may not use this scroll while in-fight!")
return FALSE
end
if (os.time() - currentValue) >= compareTime and hasCondition(cid, CONDITION_INFIGHT) == FALSE and item.itemid == scroll then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doPlayerSendTextMessage(cid,19,"You have been teleported to your home town!")
setPlayerStorageValue(cid, 9897, os.time())
else
doPlayerSendCancel(cid, "You can only use this scroll once every hour.")
end
return TRUE
end