Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onUse(cid, item, frompos, item2, topos)
- -- Config --
- local hearthstone = 36000
- local messageenter = "Home sweet home!"
- local cdtime = 20*60 -- cooldown time in minutes(20minutes)
- -- Config End --
- -- Action --
- if getCreatureCondition(cid, CONDITION_INFIGHT) == false then
- if (getPlayerStorageValue(cid, hearthstone) == 0) or --never used
- ((os.time() - getPlayerStorageValue(cid, hearthstone)) >= cdtime) then --Cooldown expired
- doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
- doSendMagicEffect(getCreaturePosition(cid), 12)
- doPlayerSendTextMessage(cid,2, messageenter)
- setPlayerStorageValue(cid, hearthstone, os.time())
- else
- local remaining = cdtime - (os.time() - getPlayerStorageValue(cid, hearthstone))
- if remaining >= 60 then
- doPlayerSendCancel(cid, "You have to wait "..math.ceil(remaining/60).." minutes to enter again.")
- else
- doPlayerSendCancel(cid, "You have to wait "..math.ceil(remaining).." seconds to enter again.")
- end
- end
- else
- doPlayerSendCancel(cid, "You cannot use the rune while in a fight.")
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement