Advertisement
Guest User

Untitled

a guest
Jul 12th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. --# Hunting room by Ukzz&Rer #--
  2.  
  3. HUNTINGROOMS_CREATURE_TIMELEFT = 5123
  4. HUNTINGROOMS_RESPAWN_EXHAUST = 10
  5. HUNTINGROOMS_TOKEN_ITEMID = 2311
  6. DEFAULT_EXHAUSTION_STORAGE = 41231
  7.  
  8. HUNTINGROOMS = {
  9.     [11001] = {
  10.         name = "Nazwa rooma",
  11.         monster = "Demon",
  12.         cost = 1,
  13.         time = 900,
  14.         _player = nil
  15.     }
  16. }
  17.  
  18. function checkExhausted(cid, storage, val)
  19.     if(not exhaustion.check(cid, storage)) then
  20.         exhaustion.set(cid, storage, val)
  21.         return true
  22.     else
  23.         doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  24.         doPlayerSendCancel(cid, "You are exhausted.")
  25.         return false
  26.     end
  27. end
  28.  
  29.  
  30. --# Hunting room by Ukzz&Rer #--
  31.  
  32. function onUse(cid, item, fromPosition, itemEx, toPosition)
  33.     if(not(HUNTINGROOMS[item.actionid] and checkExhausted(cid, DEFAULT_EXHAUSTION_STORAGE, 2))) then
  34.         return true
  35.     end
  36.    
  37.     local obj = HUNTINGROOMS[item.actionid]
  38.    
  39.     if(obj._player ~= nil) then
  40.         local timeleft = getPlayerStorageValue(_player, HUNTINGROOMS_CREATURE_TIMELEFT) - os.time()
  41.         return doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Sorry, room is occupied for " .. timeleft ..  " seconds more.")
  42.     end
  43.    
  44.     if(doPlayerRemoveItem(cid, HUNTINGROOMS_TOKEN_ITEMID, obj.cost) ~= true) then
  45.         return doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Sorry, you don't have " .. obj.cost .. " token/s to enter.")
  46.     end
  47.    
  48.     doTeleportThing(cid, {x = fromPosition.x, y = fromPosition.y - 5, z = fromPosition.z})
  49.     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You enter to " .. obj.name .. " hunting room.")
  50.     setPlayerStorageValue(cid, HUNTINGROOMS_CREATURE_TIMELEFT, os.time()+obj.time)
  51.     obj._player = cid
  52.    
  53.     return true
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement