Advertisement
eliteprime

Continuous Health Regeneration Script 3.0

Aug 20th, 2013
5,951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1.     --Creators: AelitePrime and H® Shaft
  2.     --Script Name: Continuous Health Regeneration Script
  3.     --Website: http://phasorscripts.wordpress.com/
  4.     --Xfire: eliteprime14789x, and nervebooger2012
  5.     --Version: 3.0
  6.    
  7.     --Reason for Update:
  8.         -- More Features
  9.  
  10.        
  11. -- time (in seconds) in between each incremental increase in health
  12. time = 10
  13.  
  14. -- Max health of a player
  15. max_health = 1
  16.  
  17. -- Max amount of health the script will regen to.
  18. max_health_regen = max_health
  19.  
  20. -- Number of regens, back to max_health_regen, a player gets per life. If you want to disable set to nil
  21. max_regens = nil
  22.  
  23. -- Number of times the re-generator will give you health for each regen.
  24. -- If you want to disable it then just make it equal to nil
  25. -- Example: 1
  26.     -- player_health = 0.1
  27.     -- increment = 0.1
  28.     -- max_health_regen = 1
  29.     -- regen_count = 5
  30.     -- re-generator will stop when you have 0.6 health.
  31. -- Example: 2
  32.     -- player_health = 0.1
  33.     -- increment = 0.1
  34.     -- max_health_regen = 0.5
  35.     -- regen_count = 5
  36.     -- re-generator will stop when you have 0.5 health.
  37. -- So the system works like this: player_health = (increment*regen_count)+player_health unless its greather than max_health_regen, then player_health = max_health_regen
  38. regen_count = nil
  39.  
  40. -- increments in which the health is regenerated.
  41. increment = 0.1
  42.  
  43. -- Do not Modify
  44. regens = {}
  45. regening = {}
  46. count = {}
  47.  
  48. function GetRequiredVersion()
  49.     return 200
  50. end
  51.  
  52. function OnScriptLoad(process, game, persistent)
  53.     set_regen = registertimer(time * 1000, "regenerator")
  54. end
  55.  
  56. function OnGameEnd(stage)
  57.     if stage == 1 then
  58.         removetimer(set_regen)
  59.     end
  60. end
  61.  
  62. function OnPlayerSpawn(player)
  63.     regens[player] = 0
  64.     regening[player] = false
  65.     count[player] = 0
  66.     writefloat(getobject(getplayerobjectid(player)) + 0xE0, max_health)
  67. end
  68.  
  69. function OnDamageApplication(receiving, causing, tagid, hit, backtap)
  70.     if receiving then
  71.         local r_player = objectidtoplayer(receiving)
  72.         if r_player then
  73.             count[r_player] = 0
  74.         end
  75.     end
  76. end
  77.  
  78. function regenerator(id, c)
  79.     for player = 0,15 do
  80.         if getplayer(player) then
  81.             local bool = true
  82.             local m_playerObjId = getplayerobjectid(player)
  83.             if m_playerObjId then
  84.                 local m_object = getobject(m_playerObjId)
  85.                 local player_health = round(readfloat(m_object + 0xE0),1)
  86.                 if tonumber(max_regens) then
  87.                     if regening[player] and player_health == max_health_regen then
  88.                         regening[player] = false
  89.                         regens[player] = (regens[player] or 0) + 1
  90.                     end
  91.                     if (regens[player] or 0) >= max_regens then
  92.                         bool = false
  93.                     end
  94.                 end
  95.                 if tonumber(regen_count) and (count[player] or 0) >= regen_count then
  96.                     bool = false
  97.                 end
  98.                 if bool and player_health < max_health_regen then
  99.                     regening[player] = true
  100.                     count[player] = (count[player] or 0) + 1
  101.                     writefloat(m_object + 0xE0, player_health + increment)
  102.                     if player_health > max_health then
  103.                         writefloat(m_object + 0xE0, max_health)
  104.                     end
  105.                 end
  106.             end
  107.         end
  108.     end
  109.     return true
  110. end
  111.  
  112. function round(val, decimal)
  113.     return math.floor((val * 10^(decimal or 0)) + 0.5) / (10^(decimal or 0))
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement