Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. function onUse(cid, item, frompos, item2, topos)
  2. -- Config --
  3.     local hearthstone = 36000
  4.     local messageenter = "Home sweet home!"
  5.     local cdtime = 20*60 -- cooldown time in minutes(20minutes)
  6. -- Config End --
  7.  
  8. -- Action --
  9.     if getCreatureCondition(cid, CONDITION_INFIGHT) == false then
  10.         if (getPlayerStorageValue(cid, hearthstone) == 0) or --never used
  11.             ((os.time() - getPlayerStorageValue(cid, hearthstone)) >= cdtime) then --Cooldown expired
  12.                 doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  13.                 doSendMagicEffect(getCreaturePosition(cid), 12)
  14.                 doPlayerSendTextMessage(cid,2, messageenter)
  15.                 setPlayerStorageValue(cid, hearthstone, os.time())
  16.         else
  17.             local remaining = cdtime - (os.time() - getPlayerStorageValue(cid, hearthstone))
  18.             if remaining >= 60 then
  19.                 doPlayerSendCancel(cid, "You have to wait "..math.ceil(remaining/60).." minutes to enter again.")
  20.             else
  21.                 doPlayerSendCancel(cid, "You have to wait "..math.ceil(remaining).." seconds to enter again.")
  22.             end
  23.         end
  24.     else
  25.         doPlayerSendCancel(cid, "You cannot use the rune while in a fight.")
  26.     end
  27. return true
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement