Skymagnum

Untitled

May 13th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. local function heal(uid, info, mana)
  2.     if not isCreature(uid) then
  3.         return true
  4.     end
  5.  
  6.     local level = getPlayerLevel(uid)
  7.     for _, v in ipairs(info) do
  8.         if level >= v.level.min and level <= v.level.max then
  9.             if mana then
  10.                 if not getTileInfo(getThingPos(uid)).protection then
  11.                     doCreatureAddMana(uid, v.mana.reg)
  12.                 end
  13.  
  14.                 addEvent(heal, v.mana.interval * 1000, uid, info, true)
  15.             else
  16.                 if not getTileInfo(getThingPos(uid)).protection then
  17.                     doCreatureAddHealth(uid, v.hp.reg)
  18.                 end
  19.  
  20.                 addEvent(heal, v.hp.interval * 1000, uid, info)
  21.             end
  22.  
  23.             break
  24.         end
  25.     end
  26.    
  27.     return true
  28. end
  29.  
  30. function onLogin(cid)
  31.  
  32. local vocations = {
  33.     [1] = {
  34.         {level = {min = 0, max = 10}, hp = {reg = 10, interval = 1}, mana = {reg = 5, interval = 1}},
  35.         {level = {min = 11, max = 30}, hp = {reg = 50, interval = 0.2}, mana = {reg = 10, interval = 2}},
  36.     }
  37. }
  38.  
  39.     if vocations[getPlayerVocation(cid)] then
  40.         heal(cid, vocations[getPlayerVocation(cid)], true)
  41.         heal(cid, vocations[getPlayerVocation(cid)])
  42.     end
  43.    
  44.     return true
  45. end
Advertisement
Add Comment
Please, Sign In to add comment