Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local MyLocal = {}
  2. MyLocal.players = {}
  3. MyLocal.time = 30
  4. MyLocal.magicEffect = 124
  5.  
  6. local function stopMove(cid)
  7.     if isCreature(cid) then
  8.         MyLocal.players[cid] = nil
  9.         setPlayerStorageValue(cid, "playerCanMoveDirection", 0)
  10.     if not exhaustion.check(cid, "airtrapped")  then
  11.             doCreatureSetNoMove(cid, false)
  12.     end
  13.         doPlayerAddExaust(cid, "earth", "track", earthExausted.track)  
  14.     end  
  15. end
  16.  
  17. local function MoveAutomatic(cid, speed)
  18.          if not isCreature(cid) then
  19.             stopMove(cid)
  20.             return false
  21.          end
  22.  
  23.          if MyLocal.players[cid] == nil then
  24.             return false
  25.          end
  26.  
  27.          local time = MyLocal.players[cid].timeEnd
  28.          local playerPos = getThingPos(cid)
  29.          local posToGo = getPositionByDirection(playerPos, getCreatureLookDir(cid), 1)
  30.  
  31.          if getPlayerCanWalk({player = cid, position = posToGo, createTile = true, checkPZ = true, checkHouse = true, checkWater = true}) and not exhaustion.check(cid, "airtrapped") then
  32.             doTeleportThing(cid, posToGo)
  33.             doSendMagicEffect(playerPos, MyLocal.magicEffect)
  34.             if time <= os.time() then
  35.                 stopMove(cid)
  36.             else
  37.                 addEvent(MoveAutomatic, speed, cid, speed)  
  38.             end
  39.         else
  40.             stopMove(cid)
  41.             return false
  42.         end
  43. end
  44.  
  45. local function formulaLevel(cid)
  46.     local level = getPlayerLevel(cid)*1.3
  47.     if level >= 200 then
  48.         return 200
  49.     else
  50.         return level
  51.     end
  52. end
  53.  
  54. function onCastSpell(cid, var)
  55.         if not isPlayer(cid) then
  56.             return false
  57.         end  
  58.  
  59.         if getSpellCancels(cid, "earth") == true then
  60.             return false
  61.         end
  62.  
  63.         if getPlayerExaust(cid, "earth", "track") == false then
  64.             return false
  65.         end
  66.  
  67.         if MyLocal.players[cid] == nil then
  68.             if getPlayerHasStun(cid) then
  69.                 doPlayerAddExaust(cid, "earth", "track", earthExausted.track)    
  70.                 return true
  71.             end
  72.             local newPos = getPositionByDirection(getThingPos(cid), getCreatureLookDir(cid))
  73.             if not getPlayerCanWalk({player = cid, position = newPos, createTile = true, checkPZ = true, checkHouse = true, checkWater = true}) then
  74.                 doPlayerSendCancelEf(cid, "It isn't possible use this fold here.")
  75.                 return false
  76.             end
  77.             MyLocal.players[cid] = {timeEnd = os.time()+MyLocal.time}
  78.             MoveAutomatic(cid, 300-formulaLevel(cid))
  79.             setCreatureNoMoveTime(cid, MyLocal.time*1000)
  80.             workAllCdAndAndPrevCd(cid, "earth", "track", MyLocal.time, 1)
  81.             setPlayerStorageValue(cid, "playerCanMoveDirection", os.time()+MyLocal.time)
  82.             return true
  83.          else
  84.             doPlayerSendCancelEf(cid, "You're already using this fold.")
  85.             return false
  86.          end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement