adrianoswatt

CastleSystem - Action

Oct 16th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1. local temple = {x=1342, y=1606, z=5} -- destination position
  2. local level = 50 -- level to ues this command
  3. local loadingTime = 0 -- in seconds -- How long you have to wait until teleported
  4. local storage = 154154
  5. local gSto = 123123 -- Global Storage que Salva Guild Dominante do Castelo
  6. local exhaust = 0 -- Time until you can cast this command again
  7.  
  8. function countDown(n, cid)
  9.     if getPlayerStorageValue(cid, storage) == 1 then
  10.         local pos = getPlayerPosition(cid)
  11.         local playerPos = getThingPos(cid)
  12.         if getPlayerStorageValue(cid, storage + 1) == playerPos.x and getPlayerStorageValue(cid, storage + 2) == playerPos.y then
  13.             if getCreatureCondition(cid, CONDITION_INFIGHT) == false then
  14.                 if(n > 0) then
  15.                     doSendAnimatedText(pos, n, TEXTCOLOR_RED)
  16.                     doSendMagicEffect(pos, 7)
  17.                     addEvent(countDown, 1000, n - 1, cid)
  18.                 else
  19.                     doSendAnimatedText(pos, "I'M OUT!", TEXTCOLOR_RED)
  20.                     doSendMagicEffect(pos, CONST_ME_POFF)
  21.                     doTeleportThing(cid, temple)
  22.                     doSendMagicEffect(temple, CONST_ME_TELEPORT)
  23.                     setPlayerStorageValue(cid, storage, 0)
  24.                     doRemoveConditions(cid, false)
  25.                 end
  26.             else
  27.                 doPlayerSendCancel(cid, 'Command canceled. Get out of fight!')
  28.                 setPlayerStorageValue(cid, storage, 0)
  29.             end
  30.         else
  31.             doPlayerSendCancel(cid, 'Command canceled. You are moving!')
  32.             setPlayerStorageValue(cid, storage, 0)
  33.         end
  34.     end
  35. end
  36.  
  37. function onSay(cid, words, param, channel, position)
  38. if getGlobalStorageValue(gSto) == getPlayerGuildId(cid) then
  39.     if exhaustion.get(cid, 101) then
  40.         doPlayerSendCancel(cid, 'You can use this command only once per 10 seconds.')
  41.     return true
  42.     end
  43.     exhaustion.set(cid, 101, exhaust)
  44.     if isPlayerPzLocked(cid) then
  45.         doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"You cannot use this command while you are pz locked.")
  46.     return true
  47.     end
  48.     if getCreatureCondition(cid, CONDITION_INFIGHT) then
  49.         return doPlayerSendCancel(cid, 'You can\'t use this command in fight.')
  50.     end
  51.     if getPlayerLevel(cid) < level then
  52.         return doPlayerSendCancel(cid, 'You need to be from level '..level..' to use this command.')
  53.     end
  54.     local pos = getThingPos(cid)
  55.     setPlayerStorageValue(cid, storage + 1, pos.x)
  56.     setPlayerStorageValue(cid, storage + 2, pos.y)
  57.     setPlayerStorageValue(cid, storage, 1)
  58.     countDown(loadingTime, cid)
  59. else
  60.     return doPlayerSendCancel(cid, 'Your Guild isn\'t the owner from Castle.')
  61. end
  62. return true
  63. end
Advertisement
Add Comment
Please, Sign In to add comment